[antlr-interest] understanding CPP_PARSER.g

Keith Pincombe pincombe at gmail.com
Sun Mar 20 06:11:48 PST 2005


Hi,

If anyone has used CPP_PARSER.g i would love to ask you some questions
as i am really struggling to use it, my main problem is working out
how to access the information that the parser has discovered, more
specifically what type of variable has been discovered.

I think this is covered in the grammar below but the more i look at it
the more i don't think its in the right place, the more i look into
this the more confused i am getting if someone could help i would be
very grateful.

simple_type_specifier returns [CPPParser::TypeSpecifier ts]
{char *s;
ts = tsInvalid;}
: ( {qualifiedItemIsOneOf(qiType|qiCtor)}? 
s = qualified_type {ts=tsTYPEID;} 
| 
( "char" {ts |= tsCHAR;}
| "wchar_t" {ts |= tsWCHAR_T;}  
| "bool" {ts |= tsBOOL;}
| "short" {ts |= tsSHORT;}
| "int" {ts |= tsINT;}
| ("_int64"|"__int64") {ts |= tsLONG;}
| "__w64" {ts |= tsLONG;}
| "long" {ts |= tsLONG;}
| "signed" {ts |= tsSIGNED;}
| "unsigned" {ts |= tsUNSIGNED;}
| "float" {ts |= tsFLOAT;}
| "double" {ts |= tsDOUBLE;}
| "void" {ts |= tsVOID;}
| ("_declspec"|"__declspec") LPAREN ID RPAREN 
)+
|
// Fix towards allowing us to parse *.cpp files directly
(qualified_type qualified_id)=> s = qualified_type {ts=tsTYPEID;}
{printf("simple_type_specifier third option entered\n");}
)
;


More information about the antlr-interest mailing list