Subject: LL(2)
From: John Sung (john_j_sung@yahoo.com)
Date: Thu Feb 28 2002 - 21:39:53 EST
Hi Gang,
This problem illustrates the look ahead property of
the Traversal Specification Language.
Basically, when you have these two statements:
declare traveral t1: "from here to there";
declare traversal t2(cg): "from here to there";
the parser can not determine whether the current
statement we're working on is the first case or the
latter case by just looking at 1 token. It needs to
look ahead 2 tokens, i.e. see the t2 and either ":" or
"(" to determine how it should parse the current
statement.
In this case, you need to add in special lookahead
keywords in the right places. For an example, revisit
homework #5.
And similar case happens with class graph declarations
as well.
John
> Thank you. We're having a little problem with our
> class dictionary. We're
> getting the following error, the program.cd file is
> attached:
> Reading from file gen/Parser.jj . . .
> Warning: Choice conflict involving two expansions at
> line 110, column 5 and line 110, column 31
> respectively.
> A common prefix is: <IDENTIFIER>
> Consider using a lookahead of 2 for earlier
> expansion.
> Warning: Choice conflict involving two expansions at
> line 122, column 5 and line 122, column 23
> respectively.
> A common prefix is: <IDENTIFIER>
> Consider using a lookahead of 2 for earlier
> expansion.
> Parser generated with 0 errors and 2 warnings.
> Running the compiler...
> gen/Parser.java:128:7: unreachable statement
> it = _ComplexClassGraph();
> ^
> gen/Parser.java:129:7: unreachable statement
> break;
> ^
> gen/Parser.java:149:7: unreachable statement
> it = _ComplexTRV();
> ^
> gen/Parser.java:150:7: unreachable statement
> break;
> ^
> 4 errors
> Aborting, compiler exited with error value 255.
>
>
__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com
This archive was generated by hypermail 2b28 : Thu Feb 28 2002 - 21:39:55 EST