[email protected] wrote: > Dear all, > > we are using ANTLR3 (ver. 3.1.3) to generate a Java parser using C target. > The generated code is supposed to be compiled with Visual Studio 2008, and > later used in a VC++ project. > > The grammar file that we used is Java 1.5 grammar for ANTLR v3 written by > Terence Parr. We found it in the list of grammar files at > > http://www.antlr.org/grammar/list. > > We inserted the following language option into the above mentioned grammar > file: > > options > { > language = C; > ASTLabelType=pANTLR3_BASE_TREE; > } > > To integrate ANTLR3 into VS2008, we followed the instructions for using C > target on the Wiki page at > > http://www.antlr.org/wiki/display/ANTLR3/Using+the+ANTLR3+C+Target > > We successfully built the C runtime library (version 3.1.3) with > antlr3c_dll.lib generated. Then, we created a new VS project, and included > the references to the necessary header and library files in the project. > We also imported the custom build rules that we found within the > vsrulefiles subfolder inside the antlr3.1.3 release package. > > Next, we added the Java grammar file into the project. The > antlr3lexerandparser.rules rule automatically applied to generate the > source code of both parser and lexer. However, when we tried to compile > the generated C code, we got the compilation errors like the one below: > > javaparser.c(21743) : error C2231: '.getLine' : left operand points to > 'struct', use '->' > > We also tried to define "_cplusplus" and then got compilation errors like > this: > > sourceannotations.h(42) : error C2061: syntax error : identifier > 'vc_attributes' > > We suspect the reason of compile failures to be the incompatibility of the > C target with C++. However, we see in the list of ANTLR3 targets list that > the C target should be compatible with C++ as of ver. 3.1. > > We will greatly appreciate if you can give some hints where we might have > done things wrong, and advise us how to successfully compile the C code of > the parser in VC++. > I thought I replied to this? Please use the Java grammar in the downloaded examples for the C target and not the Java version of it. It is under the C directory in the downloaded examples. The Java version contains embedded Java code in the lexer, which clearly will not compile in C or C++ and needs to be changed to be C code. The example grammar in the C directory already does this.
Jim List: http://www.antlr.org/mailman/listinfo/antlr-interest Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "il-antlr-interest" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/il-antlr-interest?hl=en -~----------~----~----~----~------~----~------~--~---
