Package com.singularsys.extensions.structure
package com.singularsys.extensions.structure
Provides limited support for block style programming with for, if
and while statements.
The structure package provides limited support for block style programming with if,
for and while statements. The exact syntax can be configurable to give a Java,
Pascal or Basic like syntax.
It is not intended to be a fully featured parser more a way to add some
structured programming elements like simple loops to Jep code.
The StandardStructuredParser provides a ready made parser with a java-like syntax.
It supports:
- Statements separated by semi-colons
x=5; y=x^2; - Blocks enclosed in curly-brackets
{ x=5; y=6; } - If statements
if(x==5) {y=6;} else {y=7;} - For statements
for(j=0;j<=10;++j) x+=j; - While statements
while(x<10) x+=2; - Break and continue statements inside looks.
Alternative syntaxes can be built up using the StructuredGrammarParser and a set of
GrammaticalRuleI. Rules are provided for most types of statements.
The StructuredEvaluator is used to evaluate sequences of expressions after parsing.
- Since:
- Jep 3.5 / Extensions 2.0
- See Also:
-
ClassDescriptionParse a statement block
{ sequence }.A node representing a control statement such asbreakorcontinue.ParsesbreakandcontinuestatementsParses an expression.Indicates rules for parsing structured code.A node representing an if statement.Parses a java-style for loopfor(i=0;i<10;++i) x+=i;.Parse a java style if statement:if(expr) statement [ else statement ]Parse a Java-style while loopwhile(x<10) x=x+1;A node represents a looping construct such as afororwhileloop.Special values to indicate break and continue statements Used byControlRuleandControlNode.Parse an expression followed by an optional separator.A node representing a sequence of expressions.Parses a sequence of statementsParses a sequence of statements separated by a separatorA structured parser with a java like grammar.Parse a single statement from a list of possibilities.An evaluator which works with structured programming.A grammar parser which works with structured programming.Base class for defining a parser for structured code.Base class for all structure nodes, defines anevalmethod.Parse an expression followed by a separator.