|
Object-oriented Parser System v3.6 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectUtils
Visitor
LL1
public class LL1
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. | |
NonterminalTerminal
| 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. |
AndOr
| check node unconditionally (there is a loop), traverse descendants. | |
![]() | AndListOrList
| 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.
|
| 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 |
|---|
protected final Parser parser
protected final Follow follow
| Constructor Detail |
|---|
public LL1(Parser parser,
Follow follow)
| Method Detail |
|---|
public boolean ll1()
public Object visit(Parser.Rule rule)
visit in class Visitorpublic Object visit(Parser.Terminal terminal)
visit in class Visitorpublic Object visit(Parser.Nonterminal nonterminal)
visit in class Visitorpublic Object visit(Parser.Group group)
visit in class Visitorpublic Object visit(Parser.Sequence sequence)
visit in class Visitorpublic Object visit(Parser.Repeat repeat)
visit in class Visitorpublic Object visit(Parser.Delimit delimit)
visit in class Visitorpublic Object visit(Parser.Xor xor)
visit in class Visitorpublic Object visit(Parser.Permute permute)
visit in class Visitorpublic Object visit(Parser.PermutedList permutedList)
visit in class Visitorprotected void checkIf(Parser.Node node)
noInput and
lookahead and follow intersect.
protected void check(Parser.Node node)
protected void check(Parser.Node node,
BitSet set)
|
(c) 2008 Axel T. Schreiner |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||