fr.umlv.tatoo.cc.parser.lr
Class LRTableFactoryMethod

java.lang.Object
  extended by fr.umlv.tatoo.cc.parser.lr.LRTableFactoryMethod
All Implemented Interfaces:
TableFactoryMethod<LR1Item>

public class LRTableFactoryMethod
extends Object
implements TableFactoryMethod<LR1Item>


Constructor Summary
LRTableFactoryMethod()
           
 
Method Summary
 Grammar buildGrammar(Collection<? extends ProductionDecl> productions, Set<? extends NonTerminalDecl> starts, TerminalDecl eof)
          builds the augmented grammar
 LR1Item createStartItem(ProductionDecl production, TerminalDecl eof)
          Create the kernel item for the start states
 NodeClosureComputer<LR1Item> getClosureComputer(Grammar grammar, GrammarSets grammarSets, TerminalDecl eof)
          Returns the closure computer for this method
 Set<TerminalDecl> getLookaheads(Grammar g, GrammarSets sets, LR1Item item, NodeDecl<LR1Item> node)
          returns the set of lookahead corresponding to a reduce action by item
 void initializeComputation(NodeFactory<LR1Item> 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

LRTableFactoryMethod

public LRTableFactoryMethod()
Method Detail

getClosureComputer

public NodeClosureComputer<LR1Item> 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<LR1Item>
Parameters:
grammar - the grammar
grammarSets - the grammar sets
eof - the end of file terminal
Returns:
the closure computer for this method

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<LR1Item>
Parameters:
productions - list of productions
starts - list of starts
eof - terminal eof
Returns:
the grammar

getLookaheads

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

Specified by:
getLookaheads in interface TableFactoryMethod<LR1Item>
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 LR1Item createStartItem(ProductionDecl production,
                               TerminalDecl eof)
Description copied from interface: TableFactoryMethod
Create the kernel item for the start states

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

initializeComputation

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

Specified by:
initializeComputation in interface TableFactoryMethod<LR1Item>
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