All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.uscexp.blockformatpropertyfile.parser.AstElementTreeNode Maven / Gradle / Ivy

There is a newer version: 0.2.0-Beta
Show newest version
/*
 * Copyright (C) 2014 by haui - all rights reserved
 */
package com.github.uscexp.blockformatpropertyfile.parser;

import com.github.uscexp.blockformatpropertyfile.PropertyFile;
import com.github.uscexp.blockformatpropertyfile.PropertyStruct;
import com.github.uscexp.blockformatpropertyfile.interpreter.PropertyFileInterpreter;
import com.github.uscexp.grappa.extension.util.IStack;

/**
 * Command implementation for the PropertyFileParser rule: element.
 */
public class AstElementTreeNode extends AstBaseCommandTreeNode {

	public AstElementTreeNode(String rule, String value) {
		super(rule, value);
	}

	@Override
	protected void interpretAfterChilds(Long id)
			throws Exception {
		super.interpretAfterChilds(id);
		IStack stack = processStore.getStack();
		String typeName = (String) stack.pop();
		String elementName = (String) stack.pop();
		PropertyStruct pStruct = (PropertyStruct) stack.pop();
		pStruct.setName(elementName);
		pStruct.setType(typeName);
		PropertyFile propertyFile = (PropertyFile) processStore.getVariable(PropertyFileInterpreter.PROPERTY_FILE);
		propertyFile.put(elementName, pStruct);
		propertyFile.putElementByType(typeName, pStruct);
	}

}