sjm.examples.midimath
Class MidiloopNot
java.lang.Object
|
+--sjm.examples.midimath.MidiloopNot
- public class MidiloopNot
- extends java.lang.Object
This class creates and uses a parser that aims
to recognize simple arithmetic expressions, but gets
caught in a loop. Allowable expressions include the
use of multiplication, addition and parentheses. The
grammar for this language is:
expression = term ('+' term)*;
term = factor ('*' factor)*;
factor = '(' expression ')' | Num;
This class implements this grammar as a utility class,
and avoids looping while building the subparsers.
|
Method Summary |
Parser |
expression()
Returns a parser that will recognize a Midimath
expression. |
protected Parser |
factor()
Returns a parser that will recognize either
numbers, or arithmetic expressions in parentheses. |
static void |
main(java.lang.String[] args)
Demonstrate that this utility class does not loop. |
protected Parser |
term()
Returns a parser that will recognize arithmetic
expressions containing just multiplication. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
expression
protected static Sequence expression
MidiloopNot
public MidiloopNot()
expression
public Parser expression()
- Returns a parser that will recognize a Midimath
expression.
- Returns:
- a parser that will recognize a Midimath
expression
factor
protected Parser factor()
- Returns a parser that will recognize either
numbers, or arithmetic expressions in parentheses.
- Returns:
- a parser that will recognize either
numbers, or arithmetic expressions in
parentheses
main
public static void main(java.lang.String[] args)
- Demonstrate that this utility class does not loop.
term
protected Parser term()
- Returns a parser that will recognize arithmetic
expressions containing just multiplication.
- Returns:
- a parser that will recognize arithmetic
expressions containing just multiplication