Building Parsers with Java

sjm.examples.query
Class JaqlParser

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

public class JaqlParser
extends java.lang.Object

This class provides a parser that recognizes a select query, without any where clauses. "Jaql" stands for "Just Another Query Language". The grammar this class supports is:

	
     select        = "select" selectTerms "from" classNames
                     optionalWhere;
     selectTerms   = commaList(selectTerm);
     selectTerm    = expression;
     classNames    = commaList(className);
     className     = Word;
     optionalwhere = empty | "where" comparisons;
     comparisons   = commaList(comparison);
     commaList(p) = p (',' p)*;
 
This grammar uses expression and comparison from ComparisonParser.


Field Summary
protected static ComparisonParser comparisonParser
           
protected  Speller speller
           
 
Constructor Summary
JaqlParser(Speller speller)
          Construct a query language parser that will use the given speller to find the proper spelling of class and variable names.
 
Method Summary
protected  Parser className()
           
protected  Parser classNames()
           
protected static Sequence commaList(Parser p)
           
protected  Parser comparison()
           
 ComparisonParser comparisonParser()
          Return the parser to use for expression and comparison subparsers.
protected  Parser comparisons()
           
protected  Parser optionalWhere()
           
 Parser select()
          Returns a parser that will recognize a select statement.
protected  Parser selectTerm()
           
protected  Parser selectTerms()
           
 Parser start()
          Returns a parser that will recognize a select statement.
protected  Parser where()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

speller

protected Speller speller

comparisonParser

protected static ComparisonParser comparisonParser
Constructor Detail

JaqlParser

public JaqlParser(Speller speller)
Construct a query language parser that will use the given speller to find the proper spelling of class and variable names.
Method Detail

className

protected Parser className()

classNames

protected Parser classNames()

commaList

protected static Sequence commaList(Parser p)

comparison

protected Parser comparison()

comparisonParser

public ComparisonParser comparisonParser()
Return the parser to use for expression and comparison subparsers.

comparisons

protected Parser comparisons()

optionalWhere

protected Parser optionalWhere()

select

public Parser select()
Returns a parser that will recognize a select statement.
Returns:
a parser that will recognize a select statement.

selectTerm

protected Parser selectTerm()

selectTerms

protected Parser selectTerms()

start

public Parser start()
Returns a parser that will recognize a select statement.
Returns:
a parser that will recognize a select statement.

where

protected Parser where()

by Steve Metsker