xtc.parser
Class LeftRecurser

java.lang.Object
  extended by xtc.tree.Visitor
      extended by xtc.parser.LeftRecurser

public class LeftRecurser
extends Visitor

Visitor to detect left-recursion in a grammar.

This visitor requires that text-only productions have been marked as such.

Version:
$Revision: 1.49 $
Author:
Robert Grimm

Field Summary
protected  Analyzer analyzer
          The analyzer utility.
protected  Runtime runtime
          The runtime.
protected  boolean terminated
          The flag for whether we have seen a terminal.
 
Constructor Summary
LeftRecurser(Runtime runtime, Analyzer analyzer)
          Create a new left-recurser.
 
Method Summary
 java.util.Set<NonTerminal> recursive()
          Get the set of nonterminals corresponding to left-recursive productions.
 void visit(Binding b)
          Visit the specified binding.
 void visit(Element e)
          Visit the specified element.
 void visit(FullProduction p)
          Visit the specified production.
 void visit(Grammar g)
          Visit the specified grammar.
 void visit(Module m)
          Visit the specified self-contained module.
 void visit(NonTerminal nt)
          Visit the specified nonterminal.
 void visit(OrderedChoice c)
          Visit the specified ordered choice.
 void visit(ParserAction pa)
          Visit the specified parser action.
 void visit(Repetition r)
          Visit the specified repetition.
 void visit(Sequence s)
          Visit the specified sequence.
 void visit(StringMatch m)
          Visit the specified string match.
 void visit(Terminal t)
          Visit the specified terminal.
 void visit(UnaryOperator op)
          Visit the specified unary operator.
 void visit(VoidedElement v)
          Visit the specified voided element.
 
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

runtime

protected final Runtime runtime
The runtime.


analyzer

protected final Analyzer analyzer
The analyzer utility.


terminated

protected boolean terminated
The flag for whether we have seen a terminal.

Constructor Detail

LeftRecurser

public LeftRecurser(Runtime runtime,
                    Analyzer analyzer)
Create a new left-recurser.

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

recursive

public java.util.Set<NonTerminal> recursive()
Get the set of nonterminals corresponding to left-recursive productions. Note that this method must only be called after visiting the corresponding grammar with this visitor.

Returns:
The set of left-recursive nonterminals.

visit

public void visit(Grammar g)
Visit the specified grammar.


visit

public void visit(Module m)
Visit the specified self-contained module.


visit

public void visit(FullProduction p)
Visit the specified production.


visit

public void visit(OrderedChoice c)
Visit the specified ordered choice.


visit

public void visit(Repetition r)
Visit the specified repetition.


visit

public void visit(Sequence s)
Visit the specified sequence.


visit

public void visit(VoidedElement v)
Visit the specified voided element.


visit

public void visit(Binding b)
Visit the specified binding.


visit

public void visit(StringMatch m)
Visit the specified string match.


visit

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


visit

public void visit(Terminal t)
Visit the specified terminal.


visit

public void visit(UnaryOperator op)
Visit the specified unary operator. This method provides the default implementation for options and predicates.


visit

public void visit(ParserAction pa)
Visit the specified parser action. Parser actions are assumed to always consume some input.


visit

public void visit(Element e)
Visit the specified element. This method provides the default implementation for node markers, actions, parse tree nodes, null literals, and value elements.



Copyright © 2012. All Rights Reserved.