[antlr-interest] ANTLR Examples - StdCParser for C++

David Wigg wiggjd at sbu.ac.uk
Fri Oct 5 14:22:11 PDT 2001


We are trying to convert the example StdCParser.g to produce C++ code
instead of Java code.

CToken.java is one of a number of java support modules specially written
for the StdCParser.g (for Java) which we need to convert to C++.

At the moment we cannot compile our new CToken.cpp because we are left
with one compiler error on the return statement from the toString()
method which states that it cannot add two pointers together [return
"CToken:" + "(" + etc.]. This would appear to be due to the compiler not
being able to access the definition of a suitable "operator+"(?).

However, we are baffled by the fact that, though our new CToken.cpp has
been written exactly following the model of both CommonToken.cpp and
Token.cpp in the "standard" cpp libraries in which both their toString()
methods concatenate strings in the return statement and compile
successfully but our CToken.cpp does not.

I have preprocessed both our new CToken.cpp and its superclass, the
supplied CommonToken.cpp, and I cannot find any definition of an
operator+ which is in the CommonToken.cpp .i file but not in the
CToken.cpp .i file (Which might account for one working but not the
other).

We are grateful for a reply from Gary Schaps to our earlier call for
help when we knew less about what was going on, but now we know that
both Token.cpp and CommonToken.cpp compile successfully in the same
project we do not see why our CToken.cpp (and with a corresponding
CToken.hpp file) written on the same lines and in the same directories
shouldn't compile as well.

We are also grateful for a reply from Ric Klaren to our latest appeal.
(Yes, I would like to release this version to the community Ric.)
Unfortunately, we are already using antlr/String.cpp which successfully
concatenates a string and an integer to create a new string. What
doesnt work in CToken.cpp is a concatenation of two strings.

If anyone would like to see our code for CToken.cpp and CToken.hpp I
will of course be pleased to send them a copy, but we have checked it
line by line against CommonToken.cpp and CommonToken.hpp and cannot see
any significant difference.

I hope the symptoms will be sufficient to trigger someones memory to
supply a solution.

Many thanks.

David
South Bank University
London, England

 

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



More information about the antlr-interest mailing list