[antlr-interest] missing getTokenType(string) in ANTLR3C?

Jim Idle jimi at temporal-wave.com
Fri Jan 28 09:05:02 PST 2011


The token constants are in the .h file. If you are looking in a tree, you
get the tree node, then get its payload token and get the type from there.
You can include the .h file and write code to create a string map if you
want to use "dddd" but I think that you mean you want DDDD, which is the
#define in the generated .h file.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Bastian Asam
> Sent: Friday, January 28, 2011 1:04 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] missing getTokenType(string) in ANTLR3C?
>
> Hi Hiran,
> unfortunately there aren't any generated constants for my tokens or at
> least I can't find any. Since this also looks kind of odd to me I'm
> wondering if something's going wrong on my system.
> Can anyone confirm please, that for the C target no token constants are
> generated or that there is no getTokenType Method?
>
> And parser.test is only a Function: GrammarParser_test_return (*test)
> (struct GrammarParser_Ctx_struct * ctx) . I don't know how this could
> give the type of the token test.
>
> Thanks
> Bastian
>
>
>
> From:   "Hiran Chaudhuri" <Hiran.Chaudhuri at web.de>
> To:     "Bastian Asam" <bastian.asam at amadeus.com>
> Date:   27-01-11 16:29
> Subject:        Re: [antlr-interest] missing getTokenType(string) in
> ANTLR3C?
>
>
>
> Hi, Bastian.
>
> I've never used the C target, but in Java I would not go for
> getFirstChildWithType(BASE_TREE, UINT32) Function with (tree,"test")
>
> but instead
>
> getFirstChildWithType(BASE_TREE, UINT32) Function with (tree,
> parser.TEST)
>
> Are there no constants generated for your tokens?
>
> Hiran
>
>
> -----Ursprüngliche Nachricht-----
> Von: "Bastian Asam" <bastian.asam at amadeus.com>
> Gesendet: 27.01.2011 15:20:57
> An: antlr-interest at antlr.org
> Betreff: [antlr-interest] missing getTokenType(string) in ANTLR3C?
>
> >Hello everybody,
> >I spend all day to find a function for translating token names to
> their
> >integer type value.
> >
> >Basically what I want is to be able to call the
> >getFirstChildWithType(BASE_TREE, UINT32) Function with (tree,"test")
> >instead of (tree, 23). Otherwise I would always have to change my code
> >after altering the grammar a bit...
> >
> >I found the getTokenType(string) function in java, but not in C. Is it
> >missing in C? And what can I do to get it anyways?
> >
> >Any help would be greatly appreciated!
> >Thanks
> >Bastian
> >
> >
> >
> >IMPORTANT  -  CONFIDENTIALITY  NOTICE  - This e-mail is intended only
> >for
>
> >the use of the individual or entity shown above as addressees. It may
> >contain information which is privileged, confidential or otherwise
> >protected from disclosure under applicable laws.  If the reader of
> this
> >transmission is not the intended recipient, you are hereby notified
> >that any dissemination, printing, distribution, copying, disclosure or
> >the taking of any action in reliance on the contents of this
> >information is strictly prohibited.  If you have received this
> >transmission in error, please immediately notify us by reply e-mail or
> >using the address below and delete the message and any attachments
> from your system.
> >
> >Amadeus Data Processing GmbH
> >Geschäftsführer: Eberhard Haag
> >Sitz der Gesellschaft: Erding
> >HR München 48 199
> >Berghamer Strasse 6
> >85435 Erding
> >Germany
> >
> >List: http://www.antlr.org/mailman/listinfo/antlr-interest
> >Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> ___________________________________________________________
> Empfehlen Sie WEB.DE DSL Ihren Freunden und Bekannten und wir belohnen
> Sie mit bis zu 50,- Euro! https://freundschaftswerbung.web.de
>
>
>
>
>
> IMPORTANT  -  CONFIDENTIALITY  NOTICE  - This e-mail is intended only
> for the use of the individual or entity shown above as addressees. It
> may contain information which is privileged, confidential or otherwise
> protected from disclosure under applicable laws.  If the reader of this
> transmission is not the intended recipient, you are hereby notified
> that any dissemination, printing, distribution, copying, disclosure or
> the taking of any action in reliance on the contents of this
> information is strictly prohibited.  If you have received this
> transmission in error, please immediately notify us by reply e-mail or
> using the address below and delete the message and any attachments from
> your system.
>
> Amadeus Data Processing GmbH
> Geschäftsführer: Eberhard Haag
> Sitz der Gesellschaft: Erding
> HR München 48 199
> Berghamer Strasse 6
> 85435 Erding
> Germany
>
> 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