Object-oriented Parser System
v3.6

oops3
Class LL1

Object
  extended by Utils
      extended by Visitor
          extended by LL1
All Implemented Interfaces:
Symbols

public class LL1
extends Visitor

ParserFactory aspect: check LL(1). The visitor uses package access.

Each rule and each node needs to be checked for ambiguity: if a node accepts noInput its lookhead must not intersect its follow set.
Rule check right-hand side, traverse right-hand side.
Nonterminal
Terminal
nothing to do.
Sequence check node, traverse descendants.
Repeat if max is not equal to min check node unconditionally (if max equals min, they are both not zero and the lookahead cannot accept noInput; if min is 0, the lookahead accepts empty input and therefore must differ from follow; else there is a variable loop and again lookahead must differ from follow), traverse descendants.
Delimit if min is zero, check node (unconditionally) because there might be no loop; if max is not equal to min, check that the lookahead of the delimiter and the follow set of the node do not intersect to detect the end of the loop; also, if the delimiter accepts noInput check that the lookahead of the body and the follow set of the node do not intersect; traverse body and delimiter.
Xor check node, traverse descendants.
And
Or
check node unconditionally (there is a loop), traverse descendants.
AndList
OrList
check that the lookahead of the delimiter and the follow set of the node do not intersect to detect the end of the loop (there cannot be noInput); traverse descendants.

Version:
3.3.0

Field Summary
protected  Follow follow
          follow sets.
protected  Parser parser
          parser to be checked.
 
Fields inherited from class Utils
error
 
Fields inherited from interface Symbols
badInput, endOfFile, firstSymbol, noInput
 
Constructor Summary
LL1(Parser parser, Follow follow)
           
 
Method Summary
protected  void check(Parser.Node node)
          warning if lookahead and follow intersect.
protected  void check(Parser.Node node, BitSet set)
          warning if follow and other set intersect.
protected  void checkIf(Parser.Node node)
          warning if node accepts noInput and lookahead and follow intersect.
 boolean ll1()
          returns true if LL(1) check succeeds.
 Object visit(Parser.Delimit delimit)
          check if loop end is detected, traverse body and delimiter.
 Object visit(Parser.Group group)
          common code: visit descendants.
 Object visit(Parser.Nonterminal nonterminal)
          nothing to do.
 Object visit(Parser.Permute permute)
          check node unconditionally, traverse descendants.
 Object visit(Parser.PermutedList permutedList)
          check node with the delimiter, traverse descendants.
 Object visit(Parser.Repeat repeat)
          check node unconditionally, traverse decendants.
 Object visit(Parser.Rule rule)
          check and traverse rhs.
 Object visit(Parser.Sequence sequence)
          check node, traverse descendants.
 Object visit(Parser.Terminal terminal)
          nothing to do.
 Object visit(Parser.Xor xor)
          check node, traverse descendants.
 
Methods inherited from class Visitor
visit, visit, visit, visit, visit, visit, visit, visit
 
Methods inherited from class Utils
className, error, error, fromString, getError, message, testScanner, toChars, toString, toString, warning, warning
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

protected final Parser parser
parser to be checked.


follow

protected final Follow follow
follow sets.

Constructor Detail

LL1

public LL1(Parser parser,
           Follow follow)
Method Detail

ll1

public boolean ll1()
returns true if LL(1) check succeeds.


visit

public Object visit(Parser.Rule rule)
check and traverse rhs.

Overrides:
visit in class Visitor

visit

public Object visit(Parser.Terminal terminal)
nothing to do.

Overrides:
visit in class Visitor

visit

public Object visit(Parser.Nonterminal nonterminal)
nothing to do.

Overrides:
visit in class Visitor

visit

public Object visit(Parser.Group group)
common code: visit descendants.

Overrides:
visit in class Visitor

visit

public Object visit(Parser.Sequence sequence)
check node, traverse descendants.

Overrides:
visit in class Visitor

visit

public Object visit(Parser.Repeat repeat)
check node unconditionally, traverse decendants.

Overrides:
visit in class Visitor

visit

public Object visit(Parser.Delimit delimit)
check if loop end is detected, traverse body and delimiter.

Overrides:
visit in class Visitor

visit

public Object visit(Parser.Xor xor)
check node, traverse descendants.

Overrides:
visit in class Visitor

visit

public Object visit(Parser.Permute permute)
check node unconditionally, traverse descendants.

Overrides:
visit in class Visitor

visit

public Object visit(Parser.PermutedList permutedList)
check node with the delimiter, traverse descendants.

Overrides:
visit in class Visitor

checkIf

protected void checkIf(Parser.Node node)
warning if node accepts noInput and lookahead and follow intersect.


check

protected void check(Parser.Node node)
warning if lookahead and follow intersect.


check

protected void check(Parser.Node node,
                     BitSet set)
warning if follow and other set intersect.



(c) 2008 Axel T. Schreiner