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

javax0.jamal.prog.analyzer.Expression1 Maven / Gradle / Ivy

There is a newer version: 2.8.1
Show newest version
package javax0.jamal.prog.analyzer;

import javax0.jamal.api.BadSyntax;
import javax0.jamal.prog.commands.Operation;

/**
 * An expression1 ::=
 * 
 * expression2 '==' expression1
 * expression2 '!=' expression1
 * expression2 '<' expression1
 * expression2 '<=' expression1
 * expression2 '>' expression1
 * expression2 '>=' expression1
 * expression2
 * 
*/ public class Expression1 { public static javax0.jamal.prog.commands.Expression analyze(final Lex.List lexes) throws BadSyntax { if (lexes.isEmpty()) { throw new BadSyntax("Expression is empty"); } if (lexes.is("not")) { lexes.next(); final var op = new Operation("not", null, Expression1.analyze(lexes)); return op; } var expression3 = Expression2.analyze(lexes); if (lexes.is("==") || lexes.is("!=") || lexes.is("<") || lexes.is("<=") || lexes.is(">") || lexes.is(">=")) { final var op = lexes.next().text; return new Operation(op, expression3, Expression1.analyze(lexes)); } return expression3; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy