| java.lang.Object fri.patterns.interpreter.parsergenerator.parsertables.AbstractParserTables
All known Subclasses: fri.patterns.interpreter.parsergenerator.syntax.builder.SyntaxBuilderParserTables, fri.patterns.interpreter.parsergenerator.parsertables.SLRParserTables,
AbstractParserTables | abstract public class AbstractParserTables implements ParserTables,Serializable(Code) | | Base class for all parser tables. Default implementations.
Source generation method: toSourceFile(). Needed by CompiledTables,
used for buffering compiled table classes at runtime.
Dump methods to print human readable table contents. Dumping does not work on
buffered table objects (needs scratch build by constructor).
author: (c) 2000, 2001, 2002 Fritz Ritzberger |
Field Summary | |
public static transient int | CELLWIDTH Helper for the cell width of printed tables. | protected List | gotoTable The GOTO-table with all possible follow states. | protected transient List | nonterminals Non-terminals, with START-symbol. | protected List | parseTable The PARSE-ACTION table with SHIFT and REDUCE entries. | protected transient List | symbols Non-terminals and terminals, without EPSILON, with START-symbol: column header of GOTO-table. | protected Syntax | syntax The raw syntax to apply on parsing. | protected transient List | terminals Terminals, with EPSILON: column header of PARSE-ACTION table. | protected List | terminalsWithoutEpsilon Terminals, without EPSILON: tokens for the Lexer. |
Method Summary | |
public static AbstractParserTables | construct(Class parserType, Syntax syntax) Factory to build precompiled parser tables, or construct them from scratch. | public void | dump(PrintStream out) Implements ParserTables: prints rules, FIRST/FOLLOW sets, syntax nodes (states), GOTO-table, PARSE-ACTION-table. | protected void | dumpGoto(PrintStream out) | protected void | dumpParseAction(PrintStream out) | protected String | dumpRule(Rule rule, int i) | public void | dumpSyntax(PrintStream out) | protected void | dumpTable(String title, List head, List table, PrintStream out) | public void | dumpTables(PrintStream out) | public Map | getExpected(Integer state) Implements ParserTables: Returns a Map of the expected tokens for current state, contained in keySet iterator. | public Integer | getGotoState(Integer currentState, String symbol) Implements ParserTables: returns the next state from GOTO-table. | public Integer | getParseAction(Integer currentState, String terminal) Implements ParserTables: returns the next action from PARSE-ACTION-table. | public Syntax | getSyntax() Implements ParserTables: returns Syntax. | public List | getTerminals() Implements ParserTables: returns String List of terminals, without EPSILON. | public void | report(PrintStream out) Reports count of rules, ternminals and nonterminals. | public String | toSourceFile(String parserClassName) Generates a compilable source file "parserClassName.java".
If the class name contains package path, the file will be generated
within the corresponding directory, else within working directory.
Parameters: parserClassName - name of class to generate:"Java" will generate "Java.java" in current directory,"my.pkg.PT" will generate "my/pkg/PT.java" in current directory. |
CELLWIDTH | public static transient int CELLWIDTH(Code) | | Helper for the cell width of printed tables. Can be set manually if automatic result does not fit.
|
gotoTable | protected List gotoTable(Code) | | The GOTO-table with all possible follow states. As much lines as states and columns as terminals and nonterminals are present.
|
nonterminals | protected transient List nonterminals(Code) | | Non-terminals, with START-symbol.
|
parseTable | protected List parseTable(Code) | | The PARSE-ACTION table with SHIFT and REDUCE entries. As much lines as states and as much columns as terminals are present.
|
symbols | protected transient List symbols(Code) | | Non-terminals and terminals, without EPSILON, with START-symbol: column header of GOTO-table.
|
syntax | protected Syntax syntax(Code) | | The raw syntax to apply on parsing.
|
terminals | protected transient List terminals(Code) | | Terminals, with EPSILON: column header of PARSE-ACTION table.
|
terminalsWithoutEpsilon | protected List terminalsWithoutEpsilon(Code) | | Terminals, without EPSILON: tokens for the Lexer.
|
AbstractParserTables | protected AbstractParserTables()(Code) | | Serializable constructor.
|
construct | public static AbstractParserTables construct(Class parserType, Syntax syntax) throws Exception(Code) | | Factory to build precompiled parser tables, or construct them from scratch.
Used by CompiledTables and SerializedTables.
Parameters: parserType - LALRParserTables, SLRParserTables, LRParserTables class. Parameters: syntax - can be null for precompiled tables, else the syntax to build. |
dump | public void dump(PrintStream out)(Code) | | Implements ParserTables: prints rules, FIRST/FOLLOW sets, syntax nodes (states), GOTO-table, PARSE-ACTION-table.
|
getExpected | public Map getExpected(Integer state)(Code) | | Implements ParserTables: Returns a Map of the expected tokens for current state, contained in keySet iterator.
|
getGotoState | public Integer getGotoState(Integer currentState, String symbol)(Code) | | Implements ParserTables: returns the next state from GOTO-table.
Parameters: currentState - curent state Parameters: symbol - current terminal or nonterminal new state |
getParseAction | public Integer getParseAction(Integer currentState, String terminal)(Code) | | Implements ParserTables: returns the next action from PARSE-ACTION-table.
Parameters: currentState - curent state Parameters: symbol - current terminal new action |
getSyntax | public Syntax getSyntax()(Code) | | Implements ParserTables: returns Syntax.
|
getTerminals | public List getTerminals()(Code) | | Implements ParserTables: returns String List of terminals, without EPSILON.
|
report | public void report(PrintStream out)(Code) | | Reports count of rules, ternminals and nonterminals.
|
toSourceFile | public String toSourceFile(String parserClassName) throws IOException(Code) | | Generates a compilable source file "parserClassName.java".
If the class name contains package path, the file will be generated
within the corresponding directory, else within working directory.
Parameters: parserClassName - name of class to generate:"Java" will generate "Java.java" in current directory,"my.pkg.PT" will generate "my/pkg/PT.java" in current directory. fileName if File could be written, else null. |
|
|