fr.umlv.tatoo.cc.parser.lalr
Class LALRTableFactoryMethod

java.lang.Object
  extended by fr.umlv.tatoo.cc.parser.lalr.LALRTableFactoryMethod
All Implemented Interfaces:
TableFactoryMethod<LR0Item>

public class LALRTableFactoryMethod
extends Object
implements TableFactoryMethod<LR0Item>

Version:
$Revision$ $Date$
Author:
Julien

Constructor Summary
LALRTableFactoryMethod()
           
 
Method Summary
 Grammar buildGrammar(Collection<? extends ProductionDecl> productions, Set<? extends NonTerminalDecl> starts, TerminalDecl eof)
          builds the augmented grammar
 LR0Item createStartItem(ProductionDecl production, TerminalDecl eof)
          Create the kernel item for the start states
 NodeClosureComputer<LR0Item> getClosureComputer(Grammar grammar, GrammarSets grammarSets, TerminalDecl eof)
          Returns the closure computer for this method
 Set<TerminalDecl> getLookaheads(Grammar g, GrammarSets sets, LR0Item item, NodeDecl<LR0Item> node)
          returns the set of lookahead corresponding to a reduce action by item
 void initializeComputation(NodeFactory<LR0Item> factory, Grammar grammar, GrammarSets grammarSets, TerminalDecl eof)
          Initialize some computation (for LALR)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LALRTableFactoryMethod

public LALRTableFactoryMethod()
Method Detail

buildGrammar

public Grammar buildGrammar(Collection<? extends ProductionDecl> productions,
                            Set<? extends NonTerminalDecl> starts,
                            TerminalDecl eof)
Description copied from interface: TableFactoryMethod
builds the augmented grammar

Specified by:
buildGrammar in interface TableFactoryMethod<LR0Item>
Parameters:
productions - list of productions
starts - list of starts
eof - terminal eof
Returns:
the grammar

initializeComputation

public void initializeComputation(NodeFactory<LR0Item> factory,
                                  Grammar grammar,
                                  GrammarSets grammarSets,
                                  TerminalDecl eof)
Description copied from interface: TableFactoryMethod
Initialize some computation (for LALR)

Specified by:
initializeComputation in interface TableFactoryMethod<LR0Item>
Parameters:
factory - the factory used to build nodes
grammar - the grammar
grammarSets - grammarSets first and follow sets corresponding the grammar
eof - the end of file terminal

getClosureComputer

public NodeClosureComputer<LR0Item> getClosureComputer(Grammar grammar,
                                                       GrammarSets grammarSets,
                                                       TerminalDecl eof)
Description copied from interface: TableFactoryMethod
Returns the closure computer for this method

Specified by:
getClosureComputer in interface TableFactoryMethod<LR0Item>
Parameters:
grammar - the grammar
grammarSets - the grammar sets
eof - the end of file terminal
Returns:
the closure computer for this method

getLookaheads

public Set<TerminalDecl> getLookaheads(Grammar g,
                                       GrammarSets sets,
                                       LR0Item item,
                                       NodeDecl<LR0Item> node)
Description copied from interface: TableFactoryMethod
returns the set of lookahead corresponding to a reduce action by item

Specified by:
getLookaheads in interface TableFactoryMethod<LR0Item>
Parameters:
g - the grammar
sets - nullable, first and follow sets corresponding to g
item - the item to reduce by
node - the node
Returns:
the set of lookaheads

createStartItem

public LR0Item createStartItem(ProductionDecl production,
                               TerminalDecl eof)
Description copied from interface: TableFactoryMethod
Create the kernel item for the start states

Specified by:
createStartItem in interface TableFactoryMethod<LR0Item>
Parameters:
production - the starting production
eof - the end of file terminal
Returns:
the new item