Building Parsers with Java

sjm.examples.tests
Class Dangle

java.lang.Object
  |
  +--sjm.examples.tests.Dangle

public class Dangle
extends java.lang.Object

This class provides an ambiguous parser in its statement method, which serves to show that the test classes can find ambiguity.

The grammar this class supports is:

 

     statement     = iff | ifelse | callCustomer | sendBill;
     iff           = "if" comparison statement;
     ifelse        = "if" comparison statement 
                     "else" statement;
     comparison    = '(' expression operator expression ')';
     expression    = Word | Num;
     operator      = '<' | '>' | '=' | "<=" | ">=" | "!=";
     optionalElse  = "else" statement | Empty;
     callCustomer  = "callCustomer" '('')' ';';
     sendBill      = "sendBill" '('')' ';';
 


Field Summary
protected static Alternation statement
           
 
Constructor Summary
Dangle()
           
 
Method Summary
static Parser callCustomer()
           
static Parser comparison()
           
static Parser expression()
           
static Parser ifelse()
           
static Parser iff()
           
static Parser operator()
           
static Parser sendBill()
           
static Parser statement()
          Return a parser that recognizes the grammar:
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

statement

protected static Alternation statement
Constructor Detail

Dangle

public Dangle()
Method Detail

callCustomer

public static Parser callCustomer()

comparison

public static Parser comparison()

expression

public static Parser expression()

ifelse

public static Parser ifelse()

iff

public static Parser iff()

operator

public static Parser operator()

sendBill

public static Parser sendBill()

statement

public static Parser statement()
Return a parser that recognizes the grammar:
     statement    = "if" comparison statement optionalElse |
                     callCustomer | sendBill;
 
Returns:
a parser that recognizes a statement

by Steve Metsker