|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
|
+--TopLevelClass
A syntax representation, generated by ¬<><∪∪ (notavaCC) 0.75. Licensed under GPL usually.
The fully qualified name of the class is given by ParserDeclaration. The class has the default scope if it is described as $protected
. Otherwise, the class is public.
If the value of the --target option is less than 1.4, CharSequence
and AssertionError
are replaced by StringBuffer
and RuntimeException
.
parseType(java.io.File)
parses a text and generates an abstruct syntax tree.
A node of the tree is an instance of sub-types of TopLevelClass.Node
.
This class and any nested classes in this class are not synchronized.
Nested Class Summary | |
static interface |
TopLevelClass.Default
A namespace for the default implementations. |
static class |
TopLevelClass.LexicalAnalyzer
Generator of a sequence of TopLevelClass.Token s. |
static interface |
TopLevelClass.Node
A node of the abstract syntax tree that is the result of parsing. |
protected static class |
TopLevelClass.NodeInitializationParameters
Contains private fields that is used in order to create a node. |
static class |
TopLevelClass.ParseException
Describes a error of a text. |
static interface |
TopLevelClass.Token
A token, which is a fragment of a parsed text. |
static interface |
TopLevelClass.Type
An abstract-syntax-tree node Type .
|
static class |
TopLevelClass.Visitor
A visitor. |
Field Summary | |
static int |
EOF_TOKEN
Describes the EOF. |
static int |
TOKEN_TERMINAL
Describes the terminal symbol TERMINAL .
|
Constructor Summary | |
TopLevelClass()
Constructs a parser. |
Method Summary | |
protected TopLevelClass.LexicalAnalyzer |
createLexicalAnalyzer(String sourceName,
CharSequence text,
int tabStop)
Creates a lexical analyzer. |
protected TopLevelClass.Node |
createNode(int symbolID,
TopLevelClass.NodeInitializationParameters parameters)
Creates a node of an abstract syntax tree. |
protected TopLevelClass.Default.Node |
createNode(int symbolID,
TopLevelClass.NodeInitializationParameters parameters,
boolean compact)
Creates a node of an abstract syntax tree. |
static void |
main(String[] args)
Parses the given files and prints the syntax tree (a sample program). |
TopLevelClass.Type |
parseType(File file)
Parses a Type in the given file.
|
TopLevelClass.Type |
parseType(String sourceName,
CharSequence text,
int tabStop)
Parses a Type in the given text.
|
TopLevelClass.Type |
parseType(String sourceName,
File file,
String charsetName,
int tabStop)
Parses a Type in the given file.
|
TopLevelClass.Type |
parseType(String sourceName,
Reader reader,
int tabStop)
Parses a Type in the given character stream.
|
TopLevelClass.Type |
parseType(TopLevelClass.LexicalAnalyzer analyzer)
Parses the sequence of tokens. |
protected CharSequence |
toCharSequence(File file,
String charsetName)
Gets the java.lang.CharSequence that represents the text in the given file.
|
protected CharSequence |
toCharSequence(Reader reader)
Gets the java.lang.CharSequence that represents the text from the given character stream.
|
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
TopLevelClass.Token.getSymbolID()
,
public static final int TOKEN_TERMINAL
TERMINAL
.
A TokenDefinition generates this field, and The word TERMINAL
is given by IDENITIFIER.
TopLevelClass.Token.getSymbolID()
,
Constructor Detail |
public TopLevelClass()
Method Detail |
protected TopLevelClass.Node createNode(int symbolID, TopLevelClass.NodeInitializationParameters parameters) throws TopLevelClass.ParseException
This is a factory method to create a node from the information given by the arguments. The user can override the method in order to customize the node creation.
The type of the node to create is described by symbolID
as follows.
symbolID | type to create |
---|---|
TopLevelClass.Type.ID |
TopLevelClass.Type |
List/Node.ID |
List/Node |
The implementation by the TopLevelClass
is equivalent to createNode(symbolID, parameters, false)
.
symbolID
- the kind of the node to create.parameters
- the parameters to initialize the node.
TopLevelClass.ParseException
- if the text to parse doesn't satisfy some requirements.protected final TopLevelClass.Default.Node createNode(int symbolID, TopLevelClass.NodeInitializationParameters parameters, boolean compact)
TopLevelClass.Default
.
symbolID
- the kind of the node to create. See createNode(int, TopLevelClass.NodeInitializationParameters)
.parameters
- the parameters to initialize the node.compact
- if true
, the method creates a compact node, which have only labeled children.
protected final CharSequence toCharSequence(File file, String charsetName) throws IOException
java.lang.CharSequence
that represents the text in the given file.
file
- a file.charsetName
- the charset name of the file, or null
for the default charset.
java.lang.CharSequence
that represents the text in the file
.
IOException
- if some error is occured for the access to the file
.protected final CharSequence toCharSequence(Reader reader) throws IOException
java.lang.CharSequence
that represents the text from the given character stream.
This method reads characters from the stream until the end of the stream has been reached, and returns the java.lang.CharSequence
that represents the characters.
reader
- a character stream. This method will not close
it.
java.lang.CharSequence
that represents the text from the reader
.
IOException
- if some error is occured for the access to the reader
.protected TopLevelClass.LexicalAnalyzer createLexicalAnalyzer(String sourceName, CharSequence text, int tabStop) throws TopLevelClass.ParseException
This is a factory method to create a lexical analyzer. The user can override the method in order to customize the lexical analysis.
sourceName
- the name of the source, used only to set the result of TopLevelClass.Token.getSourceName()
.text
- the text to analyze.tabStop
- the number that the tab character advances the cursor to the next column that is a multiple of. tabStop
is used only to set the result of TopLevelClass.Token.getColumn()
.
text
.
TopLevelClass.ParseException
- if the text to parse doesn't satisfy some requirements.public TopLevelClass.Type parseType(File file) throws IOException, TopLevelClass.ParseException
Type
in the given file.
This method parses a text in the given file according to the grammar whose start symbol is Type
.
A $parsable
nonterminal symbol Type
generates this method. If Type
is $parsable-protected
, this method is protected
.
This is equivalent to parseType(file.getName(), file, null, 8)
.
file
- the file including the text to parse.
IOException
- if some error is occured for the access to the file.
TopLevelClass.ParseException
- if the text in the file doesn't satisfy some requirements.public TopLevelClass.Type parseType(String sourceName, File file, String charsetName, int tabStop) throws IOException, TopLevelClass.ParseException
Type
in the given file.
This method parses a text in the given file according to the grammar whose start symbol is Type
.
A $parsable
nonterminal symbol Type
generates this method. If Type
is $parsable-protected
, this method is protected
.
sourceName
- the name of the source, used only to set the result of TopLevelClass.Token.getSourceName()
.file
- the file including the text to parse.charsetName
- the charset name of the file, or null
for the default charset.tabStop
- the number that the tab character advances the cursor to the next column that is a multiple of. tabStop
is used only to set the result of TopLevelClass.Token.getColumn()
.
IOException
- if some error is occured for the access to the file.
TopLevelClass.ParseException
- if the text in the file doesn't satisfy some requirements.public TopLevelClass.Type parseType(String sourceName, Reader reader, int tabStop) throws IOException, TopLevelClass.ParseException
Type
in the given character stream.
This method reads characters from the stream until the end of the stream has been reached,
and parses the text according to the grammar whose start symbol is Type
.
A $parsable
nonterminal symbol Type
generates this method. If Type
is $parsable-protected
, this method is protected
.
sourceName
- the name of the source, used only to set the result of TopLevelClass.Token.getSourceName()
.reader
- a character stream. This method will not close
it.tabStop
- the number that the tab character advances the cursor to the next column that is a multiple of. tabStop
is used only to set the result of TopLevelClass.Token.getColumn()
.
IOException
- if some error is occured for the access to the file.
TopLevelClass.ParseException
- if the text in the file doesn't satisfy some requirements.public TopLevelClass.Type parseType(String sourceName, CharSequence text, int tabStop) throws TopLevelClass.ParseException
Type
in the given text.
This method parses the text
according to the grammar whose start symbol is Type
.
A $parsable
nonterminal symbol Type
generates this method. If Type
is $parsable-protected
, this method is protected
.
sourceName
- the name of the source, used only to set the result of TopLevelClass.Token.getSourceName()
.text
- the text to parse.tabStop
- the number that the tab character advances the cursor to the next column that is a multiple of. tabStop
is used only to set the result of TopLevelClass.Token.getColumn()
.
TopLevelClass.ParseException
- if the text doesn't satisfy some requirements.public TopLevelClass.Type parseType(TopLevelClass.LexicalAnalyzer analyzer) throws TopLevelClass.ParseException
This method parses the sequence of the tokens given by the lexical analyzer according to the grammar whose start symbol is Type
.
A $parsable
nonterminal symbol Type
generates this method. If Type
is $parsable-protected
, this method is protected
.
analyzer
- the lexical analyzer that gives the sequence of tokens to parse.
TopLevelClass.ParseException
- if the sequence of tokens doesn't satisfy some requirements.public static void main(String[] args)
This method is generated if there is only one $parsable
nonterminal symbol. The specification of this method may be changed in the feature.
args
- the names of the files to parse.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |