oops.parser
Class Rule

java.lang.Object
  |
  +--oops.parser.Node
        |
        +--oops.parser.Rule

public class Rule
extends Node

represents grammar rule: id : alt .

See Also:
Serialized Form

Field Summary
static boolean debug
          determines default factory class: false: GoalAdapter, true: GoalDebug.
protected  boolean firstGoalWarning
           
protected  boolean followChanged
          set if follow has changed.
protected  GoalMaker gm
           
protected  boolean inProgress
          used to detect left recursion and to flag if follow needs to be recomputed.
protected  boolean marked
           
protected  java.lang.String nt
          nonterminal name.
protected  Node rhs
          right hand side subtree.
 
Fields inherited from class oops.parser.Node
follow, lookahead
 
Constructor Summary
Rule(Id nt, Node rhs)
           
 
Method Summary
 boolean checkDeadLoop()
           
 void checkLL1(Parser parser)
          checks LL(1) for rule and rhs.
 int degree()
           
 boolean followChanged()
          resets before recomputing follow.
 java.lang.String getNt()
           
 void parse(Scanner scanner, Goal goal, Parser parser, oops.parser.Activation caller)
          performs recognition.
 java.lang.Object parse(Scanner scanner, Parser parser, oops.parser.Activation caller)
           
protected  Goal rhsParse(Scanner scanner, Parser parser, oops.parser.Activation caller)
           
 void setFollow(Parser parser)
          traverses rhs; should reach all rules from start rule.
 Set setFollow(Parser parser, Set succ)
          sets or adds to (new) follow set and reports changes to parser.
 void setFollow(Set s)
          initialize follow with an empty set.
 void setGoalMaker(GoalMaker gm)
           
 Set setLookahead(Parser parser)
          gets lookahead from rhs, sets inProgress.
 java.lang.Object sub(int n)
           
 java.lang.String toString()
           
 java.lang.String toString(Parser parser)
           
 
Methods inherited from class oops.parser.Node
add, getLookahead, node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

marked

protected boolean marked

debug

public static boolean debug
determines default factory class: false: GoalAdapter, true: GoalDebug.

nt

protected java.lang.String nt
nonterminal name.

rhs

protected Node rhs
right hand side subtree.

inProgress

protected transient boolean inProgress
used to detect left recursion and to flag if follow needs to be recomputed.

followChanged

protected transient boolean followChanged
set if follow has changed.

firstGoalWarning

protected boolean firstGoalWarning

gm

protected GoalMaker gm
Constructor Detail

Rule

public Rule(Id nt,
            Node rhs)
Method Detail

setLookahead

public Set setLookahead(Parser parser)
gets lookahead from rhs, sets inProgress.
Overrides:
setLookahead in class Node
Tags copied from class: Node
Returns:
lookahead.

followChanged

public boolean followChanged()
resets before recomputing follow.

setFollow

public void setFollow(Set s)
initialize follow with an empty set. used only once, only for the start rule.

setFollow

public void setFollow(Parser parser)
traverses rhs; should reach all rules from start rule.

setFollow

public Set setFollow(Parser parser,
                     Set succ)
sets or adds to (new) follow set and reports changes to parser.
Overrides:
setFollow in class Node
Parameters:
parser - for report.
succ - to set/add to follow.
Returns:
lookahead.

checkLL1

public void checkLL1(Parser parser)
checks LL(1) for rule and rhs.
Overrides:
checkLL1 in class Node

checkDeadLoop

public boolean checkDeadLoop()
Overrides:
checkDeadLoop in class Node

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(Parser parser)

getNt

public java.lang.String getNt()

degree

public int degree()
Overrides:
degree in class Node

sub

public java.lang.Object sub(int n)
Overrides:
sub in class Node

rhsParse

protected Goal rhsParse(Scanner scanner,
                        Parser parser,
                        oops.parser.Activation caller)
                 throws java.io.IOException,
                        oops.parser.Activation

parse

public void parse(Scanner scanner,
                  Goal goal,
                  Parser parser,
                  oops.parser.Activation caller)
           throws java.io.IOException,
                  oops.parser.Activation
Description copied from class: Node
performs recognition.
Overrides:
parse in class Node
Tags copied from class: Node
Parameters:
scanner - delivers input tokens.
goal - represents current nonterminal and is informed about shifts/reduces.
caller - Activation frame.

parse

public java.lang.Object parse(Scanner scanner,
                              Parser parser,
                              oops.parser.Activation caller)
                       throws java.io.IOException,
                              oops.parser.Activation

setGoalMaker

public void setGoalMaker(GoalMaker gm)