|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--parser.ExpressionParser
A parser, generated by notavaCC 0.66.
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)
|
static void |
main(String[] args)
Parses the given file(s) and prints the abstract syntax tree(s) generated. |
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 |
public static final int EOF_TOKEN
public static final int TOKEN_WHITE_SPACES
public static final int TOKEN_TRADITIONAL_COMMENT
public static final int TOKEN_END_OF_LINE_COMMENT
public static final int TOKEN_INTEGER
Constructor Detail |
public ExpressionParser()
Method Detail |
protected ExpressionParser.Node createNode(int symbolID, ExpressionParser.NodeInitializationParameters parameters) throws ExpressionParser.ParseException
The type of the node to create is described by symbolID
as follows.
symbolID | type 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)
.
symbolID
- the kind of the node to create.parameters
- the parameters to initialize the node.
ExpressionParser.ParseException
protected final ExpressionParser.Default.Node createNode(int symbolID, ExpressionParser.NodeInitializationParameters parameters, boolean compact)
ExpressionParser.Default
.
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.
protected final CharSequence getCharSequence(File file, String charsetName) throws IOException, ExpressionParser.ParseException
IOException
ExpressionParser.ParseException
protected final CharSequence getCharSequence(Reader reader) throws IOException, ExpressionParser.ParseException
IOException
ExpressionParser.ParseException
protected ExpressionParser.LexicalAnalyzer createLexicalAnalyzer(String sourceName, CharSequence text, int tabStop) throws ExpressionParser.ParseException
ExpressionParser.ParseException
public ExpressionParser.Root parseRoot(File file) throws IOException, ExpressionParser.ParseException
Root
.
IOException
ExpressionParser.ParseException
public ExpressionParser.Root parseRoot(String sourceName, File file, String charsetName, int tabStop) throws IOException, ExpressionParser.ParseException
Root
.
IOException
ExpressionParser.ParseException
public ExpressionParser.Root parseRoot(String sourceName, Reader reader, int tabStop) throws IOException, ExpressionParser.ParseException
Root
. reader
will not be closed.
IOException
ExpressionParser.ParseException
public ExpressionParser.Root parseRoot(String sourceName, CharSequence seq, int tabStop) throws ExpressionParser.ParseException
Root
.
ExpressionParser.ParseException
public ExpressionParser.Root parseRoot(ExpressionParser.LexicalAnalyzer analyzer) throws ExpressionParser.ParseException
Root
.
ExpressionParser.ParseException
public static void main(String[] args)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |