[antlr-interest] Value passed to String based rule parameter has spaces inserted after commas.

Sam Ellis sam.ellis at arm.com
Sat Jul 21 12:11:09 PDT 2007


On 21/7/07 13:55, "Benjamin Niemann" <pink at odahoda.de> wrote:
> There not much ANTLR can do without knowing how strings, types,
> comments, ... look like in the target language - that it would need a
> complete grammar of each target language, which would make things way more
> difficult to implement.

It makes sense, though I guess I'd assumed it might be doing some minimal
braces/quotes matching or allow characters to be escaped.


> So finally: to work around this limitation, use something like that:
> 
> bowl
>     : { f = "apple,orange"; }
>       fruit[f]
>     ;

I have a lot of such rule parameters... As I'm splitting the string up into
an array inside the rule action anyway the easiest for me was to split on
comma+space instead of just comma. Really, of course, I should look at
passing in an array and avoid the run-time hit of splitting these strings at
all, but that's an enhancement for another day... Thanks for the
suggestions.


-- 
Sam Ellis, RVDK Team Leader,
DevSys Product Engineering Group,          Tel: +44 (0) 1223 400516
ARM Ltd., 110 Fulbourn Road,               Fax: +44 (0) 1223 400887
Cambridge, CB1 9NJ                         mailto:Sam.Ellis at arm.com



-- 
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.




More information about the antlr-interest mailing list