[all packages] [package G4ip] [class hierarchy] [index]

public class G4ip.Parser

(source file: Parser.pizza)
java.lang.Object
   |
   +----G4ip.Parser

public class Parser
A left-to-right, rightmost-derivation parser.

The following grammar is implemented:

Formula ::= Id
| false
| ( Formula )
| Formula Binop Formula

Id is a string of lower case letters

Binop is either &, v, -> or <->

FormulaList ::= empty
| [ FormulaList ,]* Formula

The parser uses a stack where two actions are performed:

shift moves the next token to the top of the stack (getNextToken)
reduce chooses a grammar rule, X -> A B C; pops A, B, C from the top of the stack and pushes X onto the stack

Author:
Christian Urban

Constuctor Index

O Parser(String)

Methods

O getNextToken()
tokens are: identifiers( ) , & v -> <-> false and EOI
O parseFormula()
parses a single formula
O parseFormulae()
parses a list of formulae separated by commas
O reduce()
Implements the grammar rules.

Constructors

O Parser
public Parser(String init_in);

Methods

O getNextToken
public Token getNextToken()
  throws Exception;
tokens are: identifiers( ) , & v -> <-> false and EOI (end of input)

Overrides:
getNextToken in class Parser

O reduce

public void reduce();
Implements the grammar rules.

Overrides:
reduce in class Parser

O parseFormula

public Form parseFormula()
  throws Exception;
parses a single formula

Overrides:
parseFormula in class Parser

O parseFormulae

public Context parseFormulae()
  throws