A question about LL(1) or LL(2) syntax when constructing cd file


Subject: A question about LL(1) or LL(2) syntax when constructing cd file
From: Pengcheng Wu (wupc@ccs.neu.edu)
Date: Tue Nov 19 2002 - 14:33:27 EST


I will answer your fist question. I think you can figure out the answer to
the other questions.

The reason you got the warning is that both DefaultCG and CGSlice start
with CGName, so the parser generator(javacc) can not distinguish them with
LL(1) syntax (see the textbook). You have two ways to solve this problem:

   (1) change your syntax so that the syntax can be solvable in LL(1).
   (2) modify your syntax to indicate javacc you want to use LL(K).

       Here is an example of LL(2).

       Node : lookahead (@ 2 @) AppNode | LetNode | lookahead (@ 2 @)
AssignNode | lookahead (@ 2 @) AddNode| Term | ProcNode .

--Pengcheng

On Mon, 18 Nov 2002, A student wrote:

> I guess I can just tell you my problems over email. Here they are:
>
> Reading from file gen/Parser.jj . . .
> Warning: Choice conflict involving two expansions at
> line 115, column 5 and line 115, column 23 respectively.
> A common prefix is: <IDENTIFIER>
> Consider using a lookahead of 2 for earlier expansion.
> Parser generated with 0 errors and 1 warnings.
>
> Here is the part of the .cd file they are referring to:
>
> CreateCG = "ClassGraph" CGForm.
> CGForm: DefaultCG | CGSlice.
> DefaultCG = CGName.
> CGSlice = CGName "=" "new" "ClassGraph" "(" <dcgname> CGName "," SForm
> ")".
> CGName = <i> Ident.
>
>
> Here are the other problems:
>
> Running the compiler...
> ./gen/Main.java:16:24: no method named get_s defined in Main
> System.out.println(m.get_s());
> ^
> ./javafiles/CreateClassGraph.java:12:40: no method named getNew defined in
> ClassGraphListenerFactory
> ClassGraphListener newCgListener = ClassGraphListenerFactory.getNew();
> ^
> ./javafiles/CreateClassGraph.java:13:5: no method named ClassGraphEvent
> defined in ClassGraphListener
> newCgListener.ClassGraphEvent(args, cg);
> ^
> 3 errors
> Aborting, compiler exited with error value 255.
>
>
> I have no idea what the first error means, but I just thought I'd add it
> in in case you've seen it before.
>
> For the last two errors, I have added the following to my .cd file:
>
> Main = .
>
> ClassGraphListener = .
> ClassGraphListenerFactory = .
>
> I also have those last two classes as two distinct behavior files.
>
> I obviously don't expect you to have answers to these problems, but I
> thought I'd just see if you could help from afar. Thanks.



This archive was generated by hypermail 2b28 : Tue Nov 19 2002 - 14:33:28 EST