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

de.prob.ltl.parser.semantic.VariableDefinition Maven / Gradle / Ivy

There is a newer version: 0.2.2
Show newest version
package de.prob.ltl.parser.semantic;

import de.prob.ltl.parser.LtlParser;
import de.prob.ltl.parser.LtlParser.Var_defContext;
import de.prob.ltl.parser.symboltable.Variable;
import de.prob.ltl.parser.symboltable.VariableTypes;

public class VariableDefinition extends AbstractSemanticObject {

	private Var_defContext context;

	private Variable variable;
	private Argument value;

	public VariableDefinition(LtlParser parser, Var_defContext context) {
		super(parser);

		this.context = context;
		if (this.context != null) {
			determineVariableInfo();

			checkInitialValue();
			// Define variable
			defineVariable(variable);
		}
	}

	private void determineVariableInfo() {
		VariableTypes type = VariableTypes.num;
		if (context.VAR() != null) {
			type = VariableTypes.var;
		} else if (context.SEQ_VAR() != null) {
			type = VariableTypes.seq;
		}
		if(context.ID() != null) {
			variable = createVariable(context.ID(), type);
			token = variable.getToken();
		}
	}

	private void checkInitialValue() {
		value = new Argument(parser, context.argument());
		if(variable != null) {
			VariableTypes type = variable.getType();
			VariableTypes types[] = new VariableTypes[] { type };
	
			boolean temp = variable.wasCalled();
			value.checkArgument(types);
			variable.setWasCalled(temp);
		}
	}

	public Variable getVariable() {
		return variable;
	}

	public Argument getValue() {
		return value;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy