Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compiler Tools JavaCC > (JavaCC/JTB/C++...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 434 of 559
Post > Topic >>

(JavaCC/JTB/C++ Grammar) Expansion within "(...)?" can be matched by empty string.

by alan.larkin@[EMAIL PROTECTED] Nov 25, 2006 at 05:33 AM

I am trying to get the (singular ... theres only one, and its nearly 10
years old!) C++ grammar to work with JTB and JavaCC. It p***** through
JavaCC fine, but when you run it through JTB first, the resulting
grammar produces lots of errors, as many others on the NG have attested
to.

In particular it generates a lot of lines like

sc=n3=function_declarator(isTypedef)

which JavaCC chokes on. I have attempted to rectify these by changing
them to

{
    n3=function_declarator(isTypedef);
    sc=n3;
}

Doing so gets rid of the errors anyway ... However I am now stuck on a
new problem. I get 21 of these:

Error: Line 374, Column 7: Expansion within "(...)?" can be matched by
empty string.

The offending section is

....
   |
      LOOKAHEAD("enum" ( <ID> )? "{")
      { n5 = new NodeSequence(4); }
      n6=enum_specifier()
      { n5.addNode(n6); }
*** (
         n8=init_declarator_list(false)
         { n7.addNode(n8); }
      )?
      { n5.addNode(n7); }
      n10=";" { n9 = JTBToolkit.makeNodeToken(n10); }
      { n5.addNode(n9); }
      { n0 = new NodeChoice(n5, 1); }
   |
....

(*** is line 374). The corrresponding section in the original grammar
is

....
   |
    LOOKAHEAD("enum" (<ID>)? "{")
       enum_specifier() (init_declarator_list(false))?  ";"
   |
....

Can anyone tell me what I need to do to rectify this please?

Thanks,
Alan.
 




 3 Posts in Topic:
(JavaCC/JTB/C++ Grammar) Expansion within "(...)?" can be matche
alan.larkin@[EMAIL PROTEC  2006-11-25 05:33:29 
Re: (JavaCC/JTB/C++ Grammar) Expansion within "(...)?" can be ma
alan.larkin@[EMAIL PROTEC  2006-11-25 06:31:21 
Re: (JavaCC/JTB/C++ Grammar) Expansion within "(...)?" can be ma
alan.larkin@[EMAIL PROTEC  2006-11-26 16:22:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 8:29:46 CST 2008.