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 StructuredGrammerParser 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:
StructuredConsole
, Documentation
-
Interface Summary Interface Description GrammaticalRuleI Indicates rules for parsing structured code. -
Class Summary Class Description BlockRule Parse a statement block{ sequence }
.ControlNode A node representing a control statement such asbreak
orcontinue
.ControlRule Parsesbreak
andcontinue
statementsExpressionRule Parses an expression.IfNode A node representing an if statement.JavaForRule Parses a java-style for loopfor(i=0;i<10;++i) x+=i;
.JavaIfRule Parse a java style if statement:if(expr) statement [ else statement ]
JavaWhileRule Parse a Java-style while loopwhile(x<10) x=x+1;
LoopNode A node represents a looping construct such as afor
orwhile
loop.PossiblyTerminatedExpressionRule Parse an expression followed by an optional separator.SequenceNode A node representing a sequence of expressions.SequenceRule Parses a sequence of statementsSequenceSeparatorRule Parses a sequence of statements separated by a separatorStandardStructuredParser A structured parser with a java like grammar.StatementRule Parse a single statement from a list of possibilities.StructuredEvaluator An evaluator which works with structured programming.StructuredGrammarParser A grammar parser which works with structured programming.StructuredParser Base class for defining a parser for structured code.StructureNode Base class for all structure nodes, defines aneval
method.TerminatedExpressionRule Parse an expression followed by a separator. -
Enum Summary Enum Description LoopNode.ControlValues Special values to indicate break and continue statements Used byControlRule
andControlNode
.