|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--fri.patterns.interpreter.parsergenerator.parsertables.AbstractParserTables
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).
Field Summary | |
static int |
CELLWIDTH
Helper for the cell width of printed tables. |
protected java.util.List |
gotoTable
The GOTO-table with all possible follow states. |
protected java.util.List |
nonterminals
Non-terminals, with START-symbol. |
protected java.util.List |
parseTable
The PARSE-ACTION table with SHIFT and REDUCE entries. |
protected java.util.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 java.util.List |
terminals
Terminals, with EPSILON: column header of PARSE-ACTION table. |
protected java.util.List |
terminalsWithoutEpsilon
Terminals, without EPSILON: tokens for the Lexer. |
Fields inherited from interface fri.patterns.interpreter.parsergenerator.ParserTables |
ACCEPT, ERROR, SHIFT |
Constructor Summary | |
protected |
AbstractParserTables()
Serializable constructor. |
Method Summary | |
static AbstractParserTables |
construct(java.lang.Class parserType,
Syntax syntax)
Factory to build precompiled parser tables, or construct them from scratch. |
void |
dump(java.io.PrintStream out)
Implements ParserTables: prints rules, FIRST/FOLLOW sets, syntax nodes (states), GOTO-table, PARSE-ACTION-table. |
protected void |
dumpGoto(java.io.PrintStream out)
|
protected void |
dumpParseAction(java.io.PrintStream out)
|
protected java.lang.String |
dumpRule(Rule rule,
int i)
|
void |
dumpSyntax(java.io.PrintStream out)
|
protected void |
dumpTable(java.lang.String title,
java.util.List head,
java.util.List table,
java.io.PrintStream out)
|
void |
dumpTables(java.io.PrintStream out)
|
java.util.Map |
getExpected(java.lang.Integer state)
Implements ParserTables: Returns a Map of the expected tokens for current state, contained in keySet iterator. |
java.lang.Integer |
getGotoState(java.lang.Integer currentState,
java.lang.String symbol)
Implements ParserTables: returns the next state from GOTO-table. |
java.lang.Integer |
getParseAction(java.lang.Integer currentState,
java.lang.String terminal)
Implements ParserTables: returns the next action from PARSE-ACTION-table. |
Syntax |
getSyntax()
Implements ParserTables: returns Syntax. |
java.util.List |
getTerminals()
Implements ParserTables: returns String List of terminals, without EPSILON. |
void |
report(java.io.PrintStream out)
Reports count of rules, ternminals and nonterminals. |
java.lang.String |
toSourceFile(java.lang.String parserClassName)
Generates a compilable source file "parserClassName.java". |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Syntax syntax
protected java.util.List gotoTable
protected java.util.List parseTable
protected transient java.util.List symbols
protected transient java.util.List terminals
protected java.util.List terminalsWithoutEpsilon
protected transient java.util.List nonterminals
public static transient int CELLWIDTH
Constructor Detail |
protected AbstractParserTables()
Method Detail |
public java.lang.Integer getGotoState(java.lang.Integer currentState, java.lang.String symbol)
getGotoState
in interface ParserTables
currentState
- curent statesymbol
- current terminal or nonterminal
public java.lang.Integer getParseAction(java.lang.Integer currentState, java.lang.String terminal)
getParseAction
in interface ParserTables
currentState
- curent stateterminal
- recently received terminal
public java.util.List getTerminals()
getTerminals
in interface ParserTables
public Syntax getSyntax()
getSyntax
in interface ParserTables
public java.util.Map getExpected(java.lang.Integer state)
getExpected
in interface ParserTables
public static AbstractParserTables construct(java.lang.Class parserType, Syntax syntax) throws java.lang.Exception
parserType
- LALRParserTables, SLRParserTables, LRParserTables class.syntax
- can be null for precompiled tables, else the syntax to build.
java.lang.Exception
public void dump(java.io.PrintStream out)
dump
in interface ParserTables
public void dumpTables(java.io.PrintStream out)
public void dumpSyntax(java.io.PrintStream out)
protected java.lang.String dumpRule(Rule rule, int i)
protected void dumpGoto(java.io.PrintStream out)
protected void dumpParseAction(java.io.PrintStream out)
protected void dumpTable(java.lang.String title, java.util.List head, java.util.List table, java.io.PrintStream out)
public void report(java.io.PrintStream out)
public java.lang.String toSourceFile(java.lang.String parserClassName) throws java.io.IOException
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.
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |