dk.brics.servletvalidator
Class SetCalculatorVisitor

java.lang.Object
  extended by dk.brics.servletvalidator.grammar.AbstractGrammarEntityVisitor
      extended by dk.brics.servletvalidator.SetCalculatorVisitor
All Implemented Interfaces:
GrammarEntityVisitor

public class SetCalculatorVisitor
extends AbstractGrammarEntityVisitor

Calculates the first and the follow set of all alphabet symbols in the grammar. Assumes that there is not ε productions in the grammar. Use EpsilonRemovalVisitor to remove those before calculating first and follow sets. It is also simplified in the sense that the end of file symbol is not added to the followsets. This is simply because we will not need it for this analysis.

Author:
schwarz

Field Summary
 Grammar grammar
           
 
Fields inherited from class dk.brics.servletvalidator.grammar.AbstractGrammarEntityVisitor
marked
 
Constructor Summary
SetCalculatorVisitor()
           
 
Method Summary
 void apply(Grammar g)
           
 LinkedSet<AlphabetSymbol> getFirstSet(AlphabetSymbol n)
           
 Map<AlphabetSymbol,LinkedSet<AlphabetSymbol>> getFirstSets()
           
 LinkedSet<AlphabetSymbol> getFollowSet(AlphabetSymbol n)
           
 Map<AlphabetSymbol,LinkedSet<AlphabetSymbol>> getFollowSets()
           
 Set<Production> getUsesSet(NonTerminal n)
           
 Map<NonTerminal,Set<Production>> getUsesSets()
           
 void out(Production production)
           
 void out(Terminal terminal)
           
 void reApply()
           
 
Methods inherited from class dk.brics.servletvalidator.grammar.AbstractGrammarEntityVisitor
apply, apply, apply, getPath, in, in, in, isMarked, mark, out, print, shouldPrettyPrint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

grammar

public Grammar grammar
Constructor Detail

SetCalculatorVisitor

public SetCalculatorVisitor()
Method Detail

apply

public void apply(Grammar g)
Specified by:
apply in interface GrammarEntityVisitor
Overrides:
apply in class AbstractGrammarEntityVisitor

getFirstSet

public LinkedSet<AlphabetSymbol> getFirstSet(AlphabetSymbol n)

getFirstSets

public Map<AlphabetSymbol,LinkedSet<AlphabetSymbol>> getFirstSets()

getFollowSet

public LinkedSet<AlphabetSymbol> getFollowSet(AlphabetSymbol n)

getFollowSets

public Map<AlphabetSymbol,LinkedSet<AlphabetSymbol>> getFollowSets()

getUsesSet

public Set<Production> getUsesSet(NonTerminal n)

getUsesSets

public Map<NonTerminal,Set<Production>> getUsesSets()

out

public void out(Production production)
Specified by:
out in interface GrammarEntityVisitor
Overrides:
out in class AbstractGrammarEntityVisitor

out

public void out(Terminal terminal)
Specified by:
out in interface GrammarEntityVisitor
Overrides:
out in class AbstractGrammarEntityVisitor

reApply

public void reApply()


Copyright © 2008 Mathias Schwarz.