[antlr-interest] C runtime, VS2005 barfs at generated Initializers for double!!

Sam Harwell sharwell at pixelminegames.com
Wed Nov 12 20:07:38 PST 2008


You need to alter the template file C.stg and rebuild the ANTLR tool. In
the cTypeInitMap at the top, change 0.0D to 0.0.

 

Sam

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Vamsi Juvvi
Sent: Wednesday, November 12, 2008 9:57 PM
To: antlr-interest at antlr.org
Subject: [antlr-interest] C runtime,VS2005 barfs at generated
Initializers for double!!

 

Hi list/the-not-so-idle-idle:

   While preparing a small antlr presentation for my colleagues I
managed to generate code that VS 2005 simply refuses to compile.

   in my tree parser for a simple calculator example. I have

atom returns [double val]
    : (
            a=DECIMAL_LITERAL        
        | a=HEX_LITERAL
        | a=OCTAL_LITERAL
       )
       { val = parseInt($a.text);}
       
    | a=FLOATING_POINT_LITERAL 
      {val = parseDouble($a.text);}
    ;

The generated code for the atom method does this to initialize val

double val = 0.0D;

It does not compile unless I remove the D suffix on the 0.0. 0.0D is not
a legal double literal for Visual studio C/C++. Is there any way I can
turn this automatic initialization off ? Or is this a bug that'll need
to be fixed in the C templates ? I can workaround this using a struct to
wrap my double but that would be perverse.

thanks much for reading.

-vamsi

-- 
Between impulse and reaction lies man's greatest strength: The freedom
to create a choice, to create his universe, to choose - Victor Frankl
(adapted)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20081112/7e94eaae/attachment.html 


More information about the antlr-interest mailing list