fri.patterns.interpreter.parsergenerator
Interface ParserTables

All Known Implementing Classes:
AbstractParserTables

public interface ParserTables

Responsibilities of (bottom-up) parser tables, that must provide:

Author:
(c) 2000, Fritz Ritzberger

Field Summary
static java.lang.Integer ACCEPT
          Special symbol occuring in a parser table, 0, means: syntax was correct when coming to that cell.
static java.lang.Integer ERROR
          Special symbol occuring in a parser table, -1, means: error when coming to that cell.
static java.lang.Integer SHIFT
          Special symbol occuring in a parser table, -2, means: read next token.
 
Method Summary
 void dump(java.io.PrintStream out)
          Dumps rules, GOTO-table, PARSE-ACTION-table, FIRST and FOLLOW sets, ...
 java.util.Map getExpected(java.lang.Integer state)
          The keySet of returned Map contains all expected terminals for the current state.
 java.lang.Integer getGotoState(java.lang.Integer currentState, java.lang.String symbol)
          Returns the next state from the GOTO-table, for a given state and a received terminal or nonterminal.
 java.lang.Integer getParseAction(java.lang.Integer currentState, java.lang.String terminal)
          Returns the action from the PARSE-ACTION-table, for a given state and received terminal.
 Syntax getSyntax()
          Returns the input syntax.
 java.util.List getTerminals()
          Returns the List of treminals, without EPSILON.
 

Field Detail

ACCEPT

public static final java.lang.Integer ACCEPT
Special symbol occuring in a parser table, 0, means: syntax was correct when coming to that cell.


ERROR

public static final java.lang.Integer ERROR
Special symbol occuring in a parser table, -1, means: error when coming to that cell.


SHIFT

public static final java.lang.Integer SHIFT
Special symbol occuring in a parser table, -2, means: read next token.

Method Detail

getGotoState

public java.lang.Integer getGotoState(java.lang.Integer currentState,
                                      java.lang.String symbol)
Returns the next state from the GOTO-table, for a given state and a received terminal or nonterminal.

Parameters:
currentState - the current parser state
symbol - recently received terminal or nonterminal
Returns:
new parser state

getParseAction

public java.lang.Integer getParseAction(java.lang.Integer currentState,
                                        java.lang.String terminal)
Returns the action from the PARSE-ACTION-table, for a given state and received terminal. fuer einen gegebenen Zustand und ein Terminal.

Parameters:
currentState - the current parser state
terminal - recently received terminal
Returns:
new action to proceed, SHIFT, ACCEPT, ERROR, or anything above zero, meaning REDUCE.

getTerminals

public java.util.List getTerminals()
Returns the List of treminals, without EPSILON.


getSyntax

public Syntax getSyntax()
Returns the input syntax.


dump

public void dump(java.io.PrintStream out)
Dumps rules, GOTO-table, PARSE-ACTION-table, FIRST and FOLLOW sets, ...


getExpected

public java.util.Map getExpected(java.lang.Integer state)
The keySet of returned Map contains all expected terminals for the current state. These can be used as Lexer hints.