[antlr-interest] Please provide fix for the errors in STDC Grammar
Gary R. Van Sickle
g.r.vansickle at att.net
Thu Jan 8 06:43:31 PST 2009
There are several problems with that grammar, but that's not your real
problem:
> Hi All
>
> I get the below 3 errors
>
> How do I fix the above 3 errors?
>
> This is really very very important and urgent.. Please help
> me in this regard.
>
...and also, just a general comment: Regardless of how important and urgent
your problem is, unless you're paying real $$$ for somebody to care, they
simply aren't going to. In fact it's probably counterproductive; I know for
me personally, the more "important and urgent" a non-paying customer claims
their problem is, the less inclined I am to help. Just an FYI. And if you
bought the book, well, I guess you are a paying customer, so nevermind ;-),
but even then, seriously, such statements don't buy you anything.
> Please provide fix for the same.
>
> 1:
>
> typedef unsigned short int USHORT;
> typedef USHORT STATUS;
> STATUS status;
>
> When ever it tries to the read the token it gives the below
>
> [ unexpected token: status ]
>
Last I tried it, this did work. It's possible you're running into the issue
that the grammar only has one identifier namespace while C actually has four
separate namespaces, but feeding just that 3-line snippet into the grammar
should/did work.
>
>
> 2: extern word __extension__({ __uint16_t __swap16gen_x =
> (word w); (__uint16_t)((__swap16gen_x & 0xff) << 8 |
> (__swap16gen_x & 0xff00) >> 8); });
>
>
>
> I get the below error
>
> unexpected token: {
>
That's loaded with GCCisms (__extension__ for one). You'll have to augment
the lexer and parser grammars to handle these non-ANSI/C89/C0x constructs.
I ran into this one myself, and temporarily got around it by simply
"absorbing" anything that looked like "__extension__ ( <whatever> )".
>
> 3:
>
> Token *pToken = __builtin_va_arg(ap, Token*);
>
Same thing here, __builtin_va_arg() is a GCC built-in that you'll have to
explicitly handle somehow.
> How do I fix the above 3 errors?
>
> This is really very very important and urgent.. Please help
> me in this regard.
Again, see above.
--
Gary R. Van Sickle
More information about the antlr-interest
mailing list