[antlr-interest] Code generation error?

Ric Klaren klaren at cs.utwente.nl
Tue Jul 27 06:41:16 PDT 2004


Hi,

On Tue, Jul 27, 2004 at 12:56:40PM -0000, jm_newton wrote:
> STRING : !QUOTE ('a'..'z')* !QUOTE
>        ;

First off I think you intend:

STRING : QUOTE! ('a'..'z')* QUOTE! ;

> which results in the following generated c++ code. Unfourtunately in
> the middle of that lot is the statement text.setLength(). setLength()
> is not a valid member function of std::basic_string so compilation
> fails...

Nevertheless you caught something that's been in the codegen since ages...
congrats :)

The fix is easy though replace the only occurence of
text.setLength(_saveIndex) in CppCodegenerator.java with a
text.erase(_saveIndex) and rebuild antlr.

> I'm not sure if I'm trying to do the impossible with my parser or
> found a real problem here. Environment:
> cantlr -> 2.7.4 from WWW site
> antlr-2.7.4

Not the impossible, if rebuilding of antlr is not an option then the (I
hope) corrected rule above does not trigger the bug.

Thanks for the report!

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
  "You can't expect to wield supreme executive power just because some
   watery tot throws a sword at you!"
  --- Monty Python and the Holy Grail



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list