Can ANTLR generate token type definitions for literals containing numbers?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Michal_Rehacek
Posted On:   Thursday, May 3, 2001 01:28 PM

Upon generating a parser ANTLR writes an include file called ParserNameTokenTypes.hpp, containing an enumeration type with IDs and names for token types and literals. However, the lines that refer to literals containing numbers (like "int8") are commented out, like this: enum { LITERAL_long = 36, // "int8" = 37 }; Is there a way to tell ANTLR that it should add definitions to the enumeration type also for literals containing numbers? Like this: enum { LITERAL_long = 36, LITERAL_int8 = 37 };    More>>

Upon generating a parser ANTLR writes an include file called ParserNameTokenTypes.hpp, containing an enumeration type with IDs and names for token types and literals. However, the lines that refer to literals containing numbers (like "int8") are commented out, like this:



enum {

LITERAL_long = 36,

// "int8" = 37

};




Is there a way to tell ANTLR that it should add definitions to the enumeration type also for literals containing numbers? Like this:



enum {

LITERAL_long = 36,

LITERAL_int8 = 37

};

   <<Less

Re: Can ANTLR generate token type definitions for literals containing numbers?

Posted By:   Ric_Klaren  
Posted On:   Friday, May 4, 2001 01:56 AM

You are most probable doing something wrong.
Maybe you forgot to remake some .g file?
This can also stem from some disagreement
between parser and lexer about which token
is what.

If I specify in the token section something like:

tokens {
..
RETURN1="return";
. .
}

I get in the enum:


...
RETURN1 = 23,
...

I might be able to say more if you post
relevant bits of your grammars.

About | Sitemap | Contact