[antlr-interest] C runtime and aggregation in the parser

Nathan Eloe powerofazure at gmail.com
Tue Jul 13 12:09:26 PDT 2010


Hello again,
I'm writing about a very specific problem I'm having with the C runtime.
One of the restrictions of the grammar I'm writing is that strings may
contain some specific characters (such as # or %), but other rules have
these as operators, and as such I can't just make a token to catch all
strings.  The only way around this I've found has been aggregating
allowable strings in the parser.
Example:
ns_str_agg
  : nsp=ns_str_part nsap=ns_str_aggp -> STRING[$nsp.text+$nsap.text]
  | ns_str_part
  | rw=res_word_str nsap=ns_str_aggp -> STRING[$rw.text+$nsap.text];

This worked just fine when I was using the java runtime (so I could use
the debugger and gunit to test my grammar).  When moving to the C
runtime, I get the following error (and lots of them):

bashastParser.c: In function 'ns_str_agg':
bashastParser.c:42343: error: invalid operands to binary + (have
'uint8_t *' and 'pANTLR3_STRING')

I've attached the grammar to this email (I am attempting to recreate the
Bash grammar).  Is there some way around this or some way to correctly
do this kind of aggretation with the C runtime?

Thanks,
Nathan

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: bashast.g
Url: http://www.antlr.org/pipermail/antlr-interest/attachments/20100713/18b38ad7/attachment.pl 


More information about the antlr-interest mailing list