[antlr-interest] antlr-2.7.3 and CPP_parser_v_3.2 grammar
Spam Dumpster
spam_dumpster2 at cox.net
Sat Aug 8 15:09:00 PDT 2009
Greetings,
I a new to ANTLR and I am attempting to use David Wigg's C++ v3.2
grammar with ANTLR 2.7.3. However, I get errors when I
parse his example (i.e., "Quadratic.i") or another simple C++
class.
I've tried setting things up several times, but I think I'm still
overlooking something. I am wondering if anyone else has had a similar
problem and can point me in the right direction.
Regards,
Bob
-----------------------------------------------------------------------
- I'm using Visual C++ 6.0 with Windows XP SP3.
- This is the content of the simple C++ class file, temp.cpp.
class X {
public:
X() : x(0) { }
~X {}
int f() { return (++x); }
int x;
};
- These messages were printed to cerr:
cerr test.cpp:4:5: unexpected token: ~
cerr test.cpp:4:6: unexpected token: X
cerr test.cpp:4:8: expecting RCURLY, found '{'
cerr test.cpp:5:13: unexpected token: {
cerr test.cpp:5:30: expecting EOF, found '}'
*** Here is what I did to build the parser. ***
1. Extracted antlr-2.7.3.tar.gz into D:\Devel\antlr\antlr-2.7.3.
2. Initialized the CPP_parser Visual C++ project.
a) Created a Visual c++ console application project called
CPP_parser.
b) This creates these directories:
D:\Devel\antlr\CPP_parser
D:\Devel\antlr\CPP_parser\Debug
C) Project settings
o C++ Tab
- Precompiled headers
Not using precompiled headers
- Preprocessor
Additional include directories:
D:\Devel\antlr\antlr-2.7.3\lib\cpp
o Link Tab
- Object/library modules:
added lib\src.lib
(I haven't added the lib\src.lib file to the directory
yet.)
o Browse info tab
- Build browse info file
Checked
D) Extracted CPP_parser_v_3.2.zip into
D:\Devel\antlr\CPP_parser.
3. Creating the static ANTLR library.
a) Created a Visual c++ static library project called "src."
Pre-compiled header and MFC support were not checked.
b) Project setttings
o C++ Tab
- Precompiled headers
Not using precompiled headers
- Preprocessor
Additional include directories:
C:\Program Files\Microsoft Visual Studio\VC98\Include,
D:\Devel\antlr\antlr-2.7.3\lib\cpp
o Library Tab
- Output file name
Debug\src.lib
o Browse info tab
- Build browse info file
Checked
C) Copied these files into
D:\Devel\antlr\antlr-2.7.3\lib\cpp\antlr.
- D:\Devel\antlr\CPP_parser\LLkParser.hpp
- D:\Devel\antlr\CPP_parser\CharScanner.hpp
D) Changed the tabsize(?) initializer in the three
CharScanner constructors in
D:\Devel\antlr\antlr-2.7.3\lib\cpp\src\CharScanner.cpp
from tabsize(8) to tabsize(4).
E) Copied the following files into
D:\Devel\antlr\antlr-2.7.3\lib\cpp\src.
- D:\Devel\antlr\CPP_parser\LLkParser.cpp
- D:\Devel\antlr\CPP_parser\Parser.cpp
F. Changed the name of the file dll.cpp in
D:\Devel\antlr\antlr-2.7.3\lib\cpp\src\ to
dll.cpp.saved.
G. Added all of the *.cpp files in
D:\Devel\antlr\antlr-2.7.3\lib\cpp\src\
to the project.
H. Clicked on the Build src.lib menu item.
The library compiles with 3
"C4355: 'this' : used in base member initializer list"
warnings and compiles and builds with no errors.
J. Copied Debug\src.lib to
D:\Devel\antlr\CPP_parser\lib\src.lib.
See 2.C "Link Tab" above.
4. Building the parser.
A. Addedd D:\Devel\antlr\antlr-2.7.3\antlr.jar to the CLASSPATH
environment variable.
B. Entered the following commands in a console window:
> D:
> cd D:\Devel\antlr\CPP_parser
> java antlr.Tool CPP_parser.g
C. Added the following files to the CPP_parser Visual C++
project.
- CPPLexer.cpp
- CPPParser.cpp
- Dictionary.cpp
- Main.cpp
- MyCode.cpp
- Support.cpp
D. Clicked Build CPP_parser.exe
The program compiles with 87
"warning C4101: 'pe' : unreferenced local variable"
warnings, and compiles and links with no errors.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090808/d1180af3/attachment.html
More information about the antlr-interest
mailing list