[antlr-interest] C codegen change request: Expose TokenNames array
Brent Yates
brent.yates at gmail.com
Sun Jun 22 14:09:04 PDT 2008
Gavin,
> ... which is exactly what getTokenNames does. Why redefine it?
>
getTokenNames is static and can't be called external to a parser instance.
> A more robust implementation would be...
>
Either method for calculating the size should work. The C.stg uses the
"<length(tokenNames)>+4" to set the size of the array, but your suggestion
is safer.
> Also, the array pointer is already accessible through
> yourParser->pParser->rec->state->tokenNames
>
I have used this, but find it very awkward. Since I was suggesting a
change, I thought I would clean things up a little ;) Also, this method
requires a parser instance. What I am looking for is the equivalent of a
static class method.
> ; it might be simpler to similarly expose the token count rather than make
> an actual method for it.) Alternatively, the TokenNames table could just be
> made null-terminated, so that the size of the table is discoverable given a
> pointer to it. (Though that's not quite as tidy.)
>
My idea was to not mess with getTokenNames, but to add two simple functions
which return the necessary information. These methods could be called
outside of any parser instance. Again, this is just for diagnostic and tool
use. They are not required to parse successfully.
Regards,
Brent Yates
[image: Close] Read more >> Options >>
[image: Visit Answers.com] <http://www.answers.com?initiator=FFANS>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080622/636fd969/attachment.html
More information about the antlr-interest
mailing list