Package com.tnsai.invariants
Class InvariantParser
java.lang.Object
com.tnsai.invariants.InvariantParser
Parses invariant strings into
InvariantExpression AST.
Supports expressions like:
state == ALIVEnumberOfLiveNeighbors >= 2 && numberOfLiveNeighbors <= 3birthCount > 0 || deathCount > 0!isEmpty()
Thread-safe: all mutable parsing state is held in a method-local Cursor.
- Author:
- TnsAI Team
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classException thrown when parsing fails. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionParses an invariant string into an expression tree.
-
Constructor Details
-
InvariantParser
public InvariantParser()
-
-
Method Details
-
parse
Parses an invariant string into an expression tree.- Parameters:
invariant- the invariant string- Returns:
- parsed expression
- Throws:
InvariantParser.InvariantParseException- if parsing fails
-