[antlr-interest] Help with error in C code generation (3.1)
Jim Idle
jimi at temporal-wave.com
Thu Aug 21 20:08:50 PDT 2008
On Thu, 2008-08-21 at 17:30 -0600, Patrick McCormick wrote:
> Hi,
>
Yes - someone else spotted that two - I have checked in a fix so you can
pick it up from the next snapshot build as ANTLR 3.1.1.
Here is a hack script that I use to build on Linux:
#! /bin/bash
# Local custom tool that builds ANTLR 3.x and rejars it etc.
#
# Your local copy of ANTLR src
#
pushd ~/antlrsrc/code/antlr/main/src/org/antlr/tool
# Compile the grammar files
#
java antlr.Tool antlr.g
java antlr.Tool antlr.print.g
java antlr.Tool assign.types.g
java antlr.Tool define.g
java antlr.Tool buildnfa.g
cp ANTLRTokenTypes.txt ../codegen
cd ../codegen
java antlr.Tool codegen.g
cd ~/antlrsrc/code/antlr/main/runtime/Java/src
# Build all the java shit <that's this email canned by stupid filters>
#
javac -cp "$CLASSPATH" -d . org/antlr/runtime/*.java
org/antlr/runtime/*/*.java
# Build the runtime only jar, again, we don't worry about the extra
stuff for now
#
rm /var/tw/jars/ANTLRRuntime.jar
jar cf /var/tw/jars/ANTLRRuntime.jar org/antlr/runtime
cd ~/antlrsrc/code/antlr/main/src
javac -cp "$CLASSPATH" -d . org/antlr/Tool.java org/antlr/*/*.java
# Build the tool jar, not worrying about all the extra stuff that does
not go in the jar
# as this is just for my own testing.
#
rm /var/tw/jars/ANTLRTool.jar
jar cf /var/tw/jars/ANTLRTool.jar \
org/antlr/Tool.class \
org/antlr/analysis \
org/antlr/codegen \
org/antlr/misc \
org/antlr/tool
# Go back to whereever we were
popd
Jim
> I've run into some issues with generating C code under the 3.1 release
> (that is being compiled as part of a C++
> project). The errors I'm seeing are in the generated C code that is
> being compiled as C++ source:
>
> antlr/SParser.cpp:14982: error: invalid conversion from ‘void*’ to
> ‘ANTLR3_BASE_TREE_struct*’
>
> This corresponds to this line in the generated parser:
>
> string_literal17_tree = ADAPTOR->create(ADAPTOR, string_literal17);
>
> In looking over the code generation templates it appears that there is
> really only on possibility as to where
> this is being generated from. Here are the possible spots (the first
> one clearly missing a cast like the others):
>
> ASTParser.stg:<label>_tree = ADAPTOR->create(ADAPTOR, <label>);
> ASTParser.stg:<label>_tree = (<ASTLabelType>)(ADAPTOR-
> >create(ADAPTOR, <label>));
> ASTParser.stg:<label>_tree = (<ASTLabelType>)(ADAPTOR-
> >create(ADAPTOR, <label>));
>
> I'm assuming adding the cast would fix this but I haven't been able to
> rebuild ANTLR successfully
> from the source distribution to test it out. I'm running under MacOS
> X 10.5.4 with XCode 3.1 installed.
> I'm a newbie to both Java and ANTLR so any help would be
> appreciated. In particular, I'd like to know how
> I go about rebuilding the source distribution -- I'm using ant but get
> hundreds of errors during the build.
>
> Thanks for any help you can provide,
>
> --Patrick
>
>
>
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080821/e7bae2ba/attachment.html
More information about the antlr-interest
mailing list