parser
Class ExpressionParser

java.lang.Object
  |
  +--parser.ExpressionParser

public class ExpressionParser
extends Object

A parser, generated by notavaCC 0.65.

parseRoot(java.io.File) parses a text and generates an abstruct syntax tree. Nodes of the tree is sub-types of ExpressionParser.Node.

The class and any nested classes in the class are not synchronized.


Nested Class Summary
static interface ExpressionParser.Addition
          The node Addition.
static interface ExpressionParser.Default
          A namespace for the default implementations of the user-defined types.
static interface ExpressionParser.Division
          The node Division.
static interface ExpressionParser.Expression
          The node Expression.
static class ExpressionParser.LexicalAnalyzer
          Generates a sequence of tokens.
static interface ExpressionParser.Multiplication
          The node Multiplication.
static interface ExpressionParser.Node
          A node of the abstract syntax tree that is the result of parsing.
protected static class ExpressionParser.NodeInitializationParameters
          Contains non-public fields to create a node.
static interface ExpressionParser.Number
          The node Number.
static class ExpressionParser.ParseException
          Describes a error of a parsing.
static interface ExpressionParser.Root
          The node Root.
static interface ExpressionParser.Subtraction
          The node Subtraction.
static interface ExpressionParser.Token
          A token, which is a part of a parsed text.
static class ExpressionParser.Visitor
          A visitor of the visitor design pattern.
 
Field Summary
static int EOF_TOKEN
          Describes the EOF.
static int TOKEN_END_OF_LINE_COMMENT
          Describes the terminal END_OF_LINE_COMMENT.
static int TOKEN_INTEGER
          Describes the terminal INTEGER.
static int TOKEN_TRADITIONAL_COMMENT
          Describes the terminal TRADITIONAL_COMMENT.
static int TOKEN_WHITE_SPACES
          Describes the terminal WHITE_SPACES.
 
Constructor Summary
ExpressionParser()
           
 
Method Summary
protected  ExpressionParser.LexicalAnalyzer createLexicalAnalyzer(String sourceName, CharSequence text, int tabStop)
           
protected  ExpressionParser.Node createNode(int symbolID, ExpressionParser.NodeInitializationParameters parameters)
          Creates a node.
protected  ExpressionParser.Default.Node createNode(int symbolID, ExpressionParser.NodeInitializationParameters parameters, boolean compact)
          Creates a node.
protected  CharSequence getCharSequence(File file, String charsetName)
           
protected  CharSequence getCharSequence(Reader reader)
           
 ExpressionParser.Root parseRoot(ExpressionParser.LexicalAnalyzer analyzer)
          parses a Root.
 ExpressionParser.Root parseRoot(File file)
          parses a Root.
 ExpressionParser.Root parseRoot(String sourceName, CharSequence seq, int tabStop)
          parses a Root.
 ExpressionParser.Root parseRoot(String sourceName, File file, String charsetName, int tabStop)
          parses a Root.
 ExpressionParser.Root parseRoot(String sourceName, Reader reader, int tabStop)
          parses a Root.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EOF_TOKEN

public static final int EOF_TOKEN
Describes the EOF.

See Also:
Constant Field Values

TOKEN_WHITE_SPACES

public static final int TOKEN_WHITE_SPACES
Describes the terminal WHITE_SPACES.

See Also:
Constant Field Values

TOKEN_TRADITIONAL_COMMENT

public static final int TOKEN_TRADITIONAL_COMMENT
Describes the terminal TRADITIONAL_COMMENT.

See Also:
Constant Field Values

TOKEN_END_OF_LINE_COMMENT

public static final int TOKEN_END_OF_LINE_COMMENT
Describes the terminal END_OF_LINE_COMMENT.

See Also:
Constant Field Values

TOKEN_INTEGER

public static final int TOKEN_INTEGER
Describes the terminal INTEGER.

See Also:
Constant Field Values
Constructor Detail

ExpressionParser

public ExpressionParser()
Method Detail

createNode

protected ExpressionParser.Node createNode(int symbolID,
                                           ExpressionParser.NodeInitializationParameters parameters)
                                    throws ExpressionParser.ParseException
Creates a node. This is a factory method.

The type of the node to create is described by symbolID as follows.
symbolIDtype to create
Root.ID ExpressionParser.Root
Addition.ID ExpressionParser.Addition
Subtraction.ID ExpressionParser.Subtraction
Multiplication.ID ExpressionParser.Multiplication
Division.ID ExpressionParser.Division
Number.ID ExpressionParser.Number

The implementation by the ExpressionParser is equivalent to createNode(symbolID, parameters, false).

Parameters:
symbolID - the kind of the node to create.
parameters - the parameters to initialize the node.
Returns:
a created node.
ExpressionParser.ParseException
Since:
notavaCC 1.0

createNode

protected final ExpressionParser.Default.Node createNode(int symbolID,
                                                         ExpressionParser.NodeInitializationParameters parameters,
                                                         boolean compact)
Creates a node. The created node is a instance of a class in ExpressionParser.Default.

Parameters:
symbolID - the kind of the node to create. See createNode(int, ExpressionParser.NodeInitializationParameters).
parameters - the parameters to initialize the node.
compact - create a compact node, which have only labeled children.
Returns:
a created node.
Since:
notavaCC 1.0

getCharSequence

protected final CharSequence getCharSequence(File file,
                                             String charsetName)
                                      throws IOException,
                                             ExpressionParser.ParseException
IOException
ExpressionParser.ParseException

getCharSequence

protected final CharSequence getCharSequence(Reader reader)
                                      throws IOException,
                                             ExpressionParser.ParseException
IOException
ExpressionParser.ParseException

createLexicalAnalyzer

protected ExpressionParser.LexicalAnalyzer createLexicalAnalyzer(String sourceName,
                                                                 CharSequence text,
                                                                 int tabStop)
                                                          throws ExpressionParser.ParseException
ExpressionParser.ParseException

parseRoot

public ExpressionParser.Root parseRoot(File file)
                                throws IOException,
                                       ExpressionParser.ParseException
parses a Root.

IOException
ExpressionParser.ParseException

parseRoot

public ExpressionParser.Root parseRoot(String sourceName,
                                       File file,
                                       String charsetName,
                                       int tabStop)
                                throws IOException,
                                       ExpressionParser.ParseException
parses a Root.

IOException
ExpressionParser.ParseException

parseRoot

public ExpressionParser.Root parseRoot(String sourceName,
                                       Reader reader,
                                       int tabStop)
                                throws IOException,
                                       ExpressionParser.ParseException
parses a Root. reader will not be closed.

IOException
ExpressionParser.ParseException

parseRoot

public ExpressionParser.Root parseRoot(String sourceName,
                                       CharSequence seq,
                                       int tabStop)
                                throws ExpressionParser.ParseException
parses a Root.

ExpressionParser.ParseException

parseRoot

public ExpressionParser.Root parseRoot(ExpressionParser.LexicalAnalyzer analyzer)
                                throws ExpressionParser.ParseException
parses a Root.

ExpressionParser.ParseException