Class TopLevelClass

java.lang.Object
  extended byTopLevelClass

public class TopLevelClass
extends java.lang.Object

A syntax representation, generated by ¬<><∪∪ (notavaCC) 1.0.0beta. 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.

Since:
notavaCC 1.0

Nested Class Summary
static interface TopLevelClass.Default
          A namespace for the default implementations.
static class TopLevelClass.LexicalAnalyzer
          Generator of a sequence of TopLevelClass.Tokens.
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(java.lang.String sourceName, java.lang.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(java.lang.String[] args)
          Parses the given files and prints the syntax tree (a sample program).
protected  TopLevelClass.Node modifyWholeTree(TopLevelClass.Node root)
          This method is called when an whole abstract syntax tree is built.
 TopLevelClass.Type parseType(java.io.File file)
          Deprecated. replaced by TopLevelClass#parseType(file, null)
 TopLevelClass.Type parseType(java.io.File file, java.lang.String charsetName)
          Parses a Type in the given file.
 TopLevelClass.Type parseType(java.lang.String sourceName, java.lang.CharSequence text, int tabStop)
          Parses a Type in the given text.
 TopLevelClass.Type parseType(java.lang.String sourceName, java.io.File file, java.lang.String charsetName, int tabStop)
          Parses a Type in the given file.
 TopLevelClass.Type parseType(java.lang.String sourceName, java.io.Reader reader, int tabStop)
          Parses a Type in the given character stream.
 TopLevelClass.Type parseType(TopLevelClass.LexicalAnalyzer analyzer)
          Parses the sequence of tokens.
protected  java.lang.CharSequence toCharSequence(java.io.File file, java.lang.String charsetName)
          Gets the java.lang.CharSequence that represents the text in the given file.
protected  java.lang.CharSequence toCharSequence(java.io.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

EOF_TOKEN

public static final int EOF_TOKEN
Describes the EOF.

Since:
notavaCC 1.0
See Also:
TopLevelClass.Token.getSymbolID(),

TOKEN_TERMINAL

public static final int TOKEN_TERMINAL
Describes the terminal symbol TERMINAL. A TokenDefinition generates this field, and The word TERMINAL is given by IDENITIFIER.

Since:
notavaCC 1.0
See Also:
TopLevelClass.Token.getSymbolID(),
Constructor Detail

TopLevelClass

public TopLevelClass()
Constructs a parser. ConstructorScope makes the constructor the default scope.

Since:
notavaCC 1.0
Method Detail

createNode

protected TopLevelClass.Node createNode(int symbolID,
                                        TopLevelClass.NodeInitializationParameters parameters)
                                 throws TopLevelClass.ParseException
Creates a node of an abstract syntax tree.

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.

symbolIDtype to create
TopLevelClass.Type.ID TopLevelClass.Type

The default implementation by the TopLevelClass 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.
Throws:
TopLevelClass.ParseException - if the text to parse doesn't satisfy some requirements.
Since:
notavaCC 1.0

createNode

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

Parameters:
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.
Returns:
a created node.
Since:
notavaCC 1.0

modifyWholeTree

protected TopLevelClass.Node modifyWholeTree(TopLevelClass.Node root)
                                      throws TopLevelClass.ParseException
This method is called when an whole abstract syntax tree is built. The tree this method returns is regarded as the result of parsing.

Parameters:
root - the root of the tree generated by createNode(int, TopLevelClass.NodeInitializationParameters).
Returns:
the result of parsing.
Throws:
TopLevelClass.ParseException
Since:
notavaCC 1.0

toCharSequence

protected final java.lang.CharSequence toCharSequence(java.io.File file,
                                                      java.lang.String charsetName)
                                               throws java.io.IOException
Gets the java.lang.CharSequence that represents the text in the given file.

Parameters:
file - a file.
charsetName - the charset name of the file, or null for the default charset.
Returns:
the java.lang.CharSequence that represents the text in the file.
Throws:
java.io.IOException - if some error is occured for the access to the file.
Since:
notavaCC 1.0

toCharSequence

protected final java.lang.CharSequence toCharSequence(java.io.Reader reader)
                                               throws java.io.IOException
Gets the 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.

Parameters:
reader - a character stream. This method will not close it.
Returns:
the java.lang.CharSequence that represents the text from the reader.
Throws:
java.io.IOException - if some error is occured for the access to the reader.
Since:
notavaCC 1.0

createLexicalAnalyzer

protected TopLevelClass.LexicalAnalyzer createLexicalAnalyzer(java.lang.String sourceName,
                                                              java.lang.CharSequence text,
                                                              int tabStop)
                                                       throws TopLevelClass.ParseException
Creates a lexical analyzer.

This is a factory method to create a lexical analyzer. The user can override the method in order to customize the lexical analysis.

Parameters:
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().
Returns:
the lexical analyzer that analyze the text.
Throws:
TopLevelClass.ParseException - if the text to parse doesn't satisfy some requirements.
Since:
notavaCC 1.0

parseType

public TopLevelClass.Type parseType(java.io.File file)
                             throws java.io.IOException,
                                    TopLevelClass.ParseException
Deprecated. replaced by TopLevelClass#parseType(file, null)

Parses a 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).

Parameters:
file - the file including the text to parse.
Returns:
the abstract syntax tree.
Throws:
java.io.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.
Since:
notavaCC 1.0

parseType

public TopLevelClass.Type parseType(java.io.File file,
                                    java.lang.String charsetName)
                             throws java.io.IOException,
                                    TopLevelClass.ParseException
Parses a 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.getPath(), file, charsetName, 8).

Parameters:
file - the file including the text to parse.
charsetName - the charset name of the file, or null for the default charset.
Returns:
the abstract syntax tree.
Throws:
java.io.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.
Since:
notavaCC 1.0

parseType

public TopLevelClass.Type parseType(java.lang.String sourceName,
                                    java.io.File file,
                                    java.lang.String charsetName,
                                    int tabStop)
                             throws java.io.IOException,
                                    TopLevelClass.ParseException
Parses a 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.

Parameters:
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().
Returns:
the abstract syntax tree.
Throws:
java.io.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.
Since:
notavaCC 1.0

parseType

public TopLevelClass.Type parseType(java.lang.String sourceName,
                                    java.io.Reader reader,
                                    int tabStop)
                             throws java.io.IOException,
                                    TopLevelClass.ParseException
Parses a 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.

Parameters:
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().
Returns:
the abstract syntax tree.
Throws:
java.io.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.
Since:
notavaCC 1.0

parseType

public TopLevelClass.Type parseType(java.lang.String sourceName,
                                    java.lang.CharSequence text,
                                    int tabStop)
                             throws TopLevelClass.ParseException
Parses a 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.

Parameters:
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().
Returns:
the abstract syntax tree.
Throws:
TopLevelClass.ParseException - if the text doesn't satisfy some requirements.
Since:
notavaCC 1.0

parseType

public TopLevelClass.Type parseType(TopLevelClass.LexicalAnalyzer analyzer)
                             throws TopLevelClass.ParseException
Parses the sequence of tokens.

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.

Parameters:
analyzer - the lexical analyzer that gives the sequence of tokens to parse.
Returns:
the abstract syntax tree.
Throws:
TopLevelClass.ParseException - if the sequence of tokens doesn't satisfy some requirements.
Since:
notavaCC 1.0

main

public static void main(java.lang.String[] args)
Parses the given files and prints the syntax tree (a sample program).

This method is generated if there is only one $parsable nonterminal symbol. The specification of this method may be changed in the feature.

Parameters:
args - the names of the files to parse.
Since:
notavaCC 1.0