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

net.sourceforge.plantuml.tim.EaterAffectation Maven / Gradle / Ivy

There is a newer version: 1.2024.8
Show newest version
// THIS FILE HAS BEEN GENERATED BY A PREPROCESSOR.
package net.sourceforge.plantuml.tim;

import net.sourceforge.plantuml.text.StringLocated;
import net.sourceforge.plantuml.tim.expression.TValue;

public class EaterAffectation extends Eater {

	public EaterAffectation(StringLocated sl) {
		super(sl.getTrimmed());
	}

	@Override
	public void analyze(TContext context, TMemory memory) throws EaterException, EaterExceptionLocated {
		skipSpaces();
		checkAndEatChar("!");
		skipSpaces();
		String varname = eatAndGetVarname();
		TVariableScope scope = TVariableScope.lazzyParse(varname);
		if (scope != null) {
			skipSpaces();
			if (peekChar() == '?' || peekChar() == '=') {
				// The variable itself is "local" or "glocal", which is not a good idea by the way
				scope = null;
			} else
				varname = eatAndGetVarname();
		}
		skipSpaces();
		boolean conditional = false;
		if (peekChar() == '?') {
			checkAndEatChar('?');
			conditional = true;
		}
		checkAndEatChar('=');
		if (conditional)
			if (memory.getVariable(varname) != null)
				return;

		skipSpaces();
		final TValue value = eatExpression(context, memory);
		memory.putVariable(varname, value, scope);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy