Building Parsers with Java

sjm.examples.query
Class ComparisonParser

java.lang.Object
  |
  +--sjm.examples.query.ComparisonParser

public class ComparisonParser
extends java.lang.Object

This utility class provides support to the Jaql parser, specifically for expression() and comparison() subparsers. The grammar this class supports is:

	
     comparison = arg operator arg;
     arg        = expression | QuotedString;
     expression = term ('+' term | '-' term)*;
     term       = factor ('*' factor | '/' factor)*;
     factor     = '(' expression ')' | Num | variable;
     variable   = Word;
     operator   = "<" | ">" | "=" | "<=" | ">=" | "!=";
 


Field Summary
protected  Sequence expression
           
protected  Speller speller
           
 
Constructor Summary
ComparisonParser(Speller speller)
          Construct a ComparisonParser that will consult the given speller for the proper spelling of variable names.
 
Method Summary
 Parser arg()
          Returns a parser that will recognize a comparison argument.
 Parser comparison()
          Returns a parser that will recognize a comparison.
protected  Parser divideFactor()
           
 Parser expression()
          Returns a parser that will recognize an arithmetic expression.
protected  Parser factor()
           
protected  Parser minusTerm()
           
protected  Parser operator()
           
protected  Parser plusTerm()
           
protected  Parser term()
           
protected  Parser timesFactor()
           
protected  Parser variable()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

expression

protected Sequence expression

speller

protected Speller speller
Constructor Detail

ComparisonParser

public ComparisonParser(Speller speller)
Construct a ComparisonParser that will consult the given speller for the proper spelling of variable names.
Method Detail

arg

public Parser arg()
Returns a parser that will recognize a comparison argument.

comparison

public Parser comparison()
Returns a parser that will recognize a comparison.

divideFactor

protected Parser divideFactor()

expression

public Parser expression()
Returns a parser that will recognize an arithmetic expression.

factor

protected Parser factor()

minusTerm

protected Parser minusTerm()

operator

protected Parser operator()

plusTerm

protected Parser plusTerm()

term

protected Parser term()

timesFactor

protected Parser timesFactor()

variable

protected Parser variable()

by Steve Metsker