[antlr-interest] Error reporting with the C runtime: tokenNames

Ned Gill thomas.gill at csr.com
Wed May 20 02:58:47 PDT 2009


On Tue, 19 May 2009 16:28:45 +0100, Jim Idle  
<jimi at temporal-wave.com> wrote:

> It is the same as the other targets, in that you need to create a local
> function that returns/displays/adds to the message, the name you want to
> use for error display. It is just a switch statement on the token type
> basically, or you could create a local map and initialize it the first
> time it is required. It is just a bit of slog really.

Sounds like it. I think the information I need is in the <Name>.tokens  
file, though, so possibly I could generate some code from that.


>> I'm already maintaining my own version of C.stg for other reasons, so I
>> could make changes to that if necessary.
>>
> Let me know if there is something that you changed that really needs to
> be in the main template - I know of at least two things that I need to
> resolve (@after for instance), but obviously would prefer that you can
> use the main branch.

The changes are fairly trivial:

- fixed a few compiler warnings (for my grammar at least)
- added some types to cTypeInitMap (some standard, some specific to my  
project)
- #undef ADD (which is defined by a system header somwhere, annoyingly)
- a quick fix to get my grammar building under MinGW.

I've attached a diff against C.stg from 3.1.3.


> I don't know when you split, but there have been
> one or two tweaks to C.stg, so make sure you pick them up.

I'm keeping it up to date with your changes.


Thanks for your help,
Ned.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: C.stg.diff
Type: application/octet-stream
Size: 3143 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20090520/11078af1/attachment.obj 


More information about the antlr-interest mailing list