xtc.parser
Class RootFinder

java.lang.Object
  extended by xtc.tree.Visitor
      extended by xtc.parser.GrammarVisitor
          extended by xtc.parser.RootFinder

public class RootFinder
extends GrammarVisitor

Visitor to identify a grammar's real root. A real root is a top-level nonterminal, whose production directly or indirectly depends on all other top-level nonterminals. If a grammar has such a root, this visitor annotates the grammar with the root property.

Note that this visitor assumes that the entire grammar is contained in a single module.

Version:
$Revision: 1.12 $
Author:
Robert Grimm

Field Summary
protected  java.util.Set<NonTerminal> topLevel
          The set of qualified top-level nonterminals.
 
Fields inherited from class xtc.parser.GrammarVisitor
analyzer, isBound, isLastElement, isPredicate, isRepeatedOnce, isTopLevel, isVoided, needsSequence, runtime, transformInPlace
 
Constructor Summary
RootFinder(Runtime runtime, Analyzer analyzer)
          Create a new root finder.
 
Method Summary
 java.lang.Object visit(Module m)
          Visit the specified grammar.
 Element visit(NonTerminal nt)
          Visit the specified nonterminal.
 
Methods inherited from class xtc.parser.GrammarVisitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class xtc.tree.Visitor
dispatch, equals, hashCode, iterate, map, mapInPlace, unableToVisit, visit
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

topLevel

protected java.util.Set<NonTerminal> topLevel
The set of qualified top-level nonterminals.

Constructor Detail

RootFinder

public RootFinder(Runtime runtime,
                  Analyzer analyzer)
Create a new root finder.

Parameters:
runtime - The runtime.
analyzer - The analyzer utility.
Method Detail

visit

public java.lang.Object visit(Module m)
Visit the specified grammar.

Overrides:
visit in class GrammarVisitor

visit

public Element visit(NonTerminal nt)
Visit the specified nonterminal.



Copyright © 2012. All Rights Reserved.