[antlr-interest] C Target Question: compiling under C++
Jim Idle
jimi at temporal-wave.com
Wed Nov 5 16:33:34 PST 2008
On Wed, 2008-11-05 at 12:25 -0500, Colin Fraizer wrote:
> I apologize for the newbie question, but I’m somewhat new to ANTLR.
>
This should just work, but perhaps there is a missing cast that you are
the first to discover. Are you using ANTLR 3.1.1? If you are then let me
have a piece of ANTLR grammar that shows this problem, and I will fix
it :-)
Jim
>
>
> I want to build a parser for a domain-specific language. I would like
> to use C++ for my implementation and understood that the C target
> would generate code that compiles under C++, but I’m running into
> trouble. (Perhaps I’ve just misunderstood. If so, I’m sorry.)
>
>
>
> When I select these options:
>
> {
>
> language=C;
>
> output=AST;
>
> backtrack=true;
>
> ASTLabelType=pANTLR3_BASE_TREE;
>
> }
>
>
>
> ANLTR generates a parser which contains lines like this:
>
> root_1 =
> (pANTLR3_BASE_TREE)(ADAPTOR->becomeRootToken(ADAPTOR,
> stream_oper->nextToken(stream_oper), root_1));
>
>
>
> but my C++ compiler complains that the return type of
> stream_oper->nextToken is “void *”, which cannot be converted to
> ‘pANTLR3_COMMON_TOKEN’ without a cast.
>
>
>
> Any suggestions on how to avoid this? (Or is the answer: just use C?)
>
>
>
> Thanks in advance,
>
> Colin Fraizer
>
> Indianapolis, IN
>
> antlr at cfraizer.com // (yeah, I use a separate mailbox for this mailing
> list. I’m not claiming to be “Mr. Antlr” or anything. 8-)
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list