fr.umlv.tatoo.runtime.parser
Class ParserTable<T,N,P,V>

java.lang.Object
  extended by fr.umlv.tatoo.runtime.parser.ParserTable<T,N,P,V>
Type Parameters:
T - type of terminal.
N - type of non-terminal.
P - type of production.
V - type of version.

public class ParserTable<T,N,P,V>
extends Object

Action table associated with a grammar. This table is created using the generated informations by Tatoo parser.

Version:
$Revision: 1316 $ $Date: 2007-11-03 00:47:26 +0100 (sam, 03 nov 2007) $
Author:
Julien Cervelle

Constructor Summary
ParserTable(Map<T,Action<T,P,V>[]> table, Action<T,P,V>[] branchArray, StateMetadata<T,N,V>[] stateMetadata, Map<N,Integer> startMap, V[] versions, int stateNb, T eof, T error)
          Creates a parser table.
 
Method Summary
 Action<T,P,V>[] getActions(T terminal)
          Returns the actions (shift/reduce/accept/error) associated with a particular terminal of the grammar.
 Action<T,P,V>[] getBranchArray()
           
 N getDefaultStart()
          Returns the default start non terminal.
 V getDefaultVersion()
          Returns the default version.
 T getEof()
          Returns the terminal indicating the end of file (eof).
 T getErrorTerminal()
          Returns the error terminal.
 StateMetadata<T,N,V> getMetadataForState(int state)
          Returns meta-data for error recovery associated with a particular state number.
 Map<N,Integer> getStartMap()
          Returns the table filled by Tatoo that associates the index of the initial state with a peculiar start non-terminal.
 int getStateNb()
          Returns the number of states in the table.
 Map<T,Action<T,P,V>[]> getTable()
          Returns the table filled by Tatoo that associates action (shift/reduce/accept/error) with each terminal of the grammar.
 List<V> getVersions()
          Returns an unmodifiable list containing all versions of the grammar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserTable

public ParserTable(Map<T,Action<T,P,V>[]> table,
                   Action<T,P,V>[] branchArray,
                   StateMetadata<T,N,V>[] stateMetadata,
                   Map<N,Integer> startMap,
                   V[] versions,
                   int stateNb,
                   T eof,
                   T error)
Creates a parser table.

Parameters:
table - a table that map action or versioned action to a terminal for a specific state index.
branchArray - an array that contains an action for a specific state index used by branching parser.
stateMetadata - the metadata associated to the state, see getMetadataForState(int).
startMap - a map that associates start non terminal to their state index in the table.
versions - all declared versions of the grammar.
stateNb - the number of states.
eof - the terminal eof.
error - the terminal error used by the default error recovery mecanism.
Method Detail

getActions

public Action<T,P,V>[] getActions(T terminal)
Returns the actions (shift/reduce/accept/error) associated with a particular terminal of the grammar.

Parameters:
terminal - the terminal.
Returns:
the action array.

getStateNb

public int getStateNb()
Returns the number of states in the table.

Returns:
the number of states.

getTable

public Map<T,Action<T,P,V>[]> getTable()
Returns the table filled by Tatoo that associates action (shift/reduce/accept/error) with each terminal of the grammar. WARNING, because array of parametrized type are not safe in Java, the returned value must be used with caution. In peculiar, this array doesn't support write access.

Returns:
the table

getBranchArray

public Action<T,P,V>[] getBranchArray()

getEof

public T getEof()
Returns the terminal indicating the end of file (eof).

Returns:
the eof terminal.

getErrorTerminal

public T getErrorTerminal()
Returns the error terminal.

Returns:
the error terminal.
See Also:
DefaultParserErrorRecoveryPolicy

getMetadataForState

public StateMetadata<T,N,V> getMetadataForState(int state)
Returns meta-data for error recovery associated with a particular state number.

Parameters:
state - the state number.
Returns:
meta-data associated with this state in the table.

getStartMap

public Map<N,Integer> getStartMap()
Returns the table filled by Tatoo that associates the index of the initial state with a peculiar start non-terminal.

Returns:
the index of the state.

getDefaultStart

public N getDefaultStart()
Returns the default start non terminal.

Returns:
the non terminal corresponding to the default initial state.

getVersions

public List<V> getVersions()
Returns an unmodifiable list containing all versions of the grammar.

Returns:
an unmodifiable list of all versions.

getDefaultVersion

public V getDefaultVersion()
Returns the default version.

Returns:
the default version.