Hi,

I keep running into questions like this, and don't know how to answer them. 
Could anyone look at this simple example and tell me how I would accomplish my 
goal? I think I've got a central concept mixed up in my head.

What I'm trying to do is under the "array" rule below, where I'm trying to 
create a rewrite rule which collects elements which are within a grouping 
construct. This seems to come up a lot for me, and I don't get how to do it.

While we're at it, what is the easiest way to strip the " " characters from the 
strings?

Thanks for any help! Here's the grammar excerpt:

tokens { ARRAY; }

@header { using System; }

public prog:   ( stat {Console.WriteLine(
                $stat.tree==null?"null":$stat.tree.ToStringTree());} )+ ;

stat:   assign | block | ';'! ;
block:  ID^ ID '{'! (assign)+ '}'! ;
assign: ID '='^ (atom | array) ';'! ;
atom:   FLOAT | ID | STRING ;
array:  '[' ((FLOAT)+ | (STRING)+) ']' -> ^(ARRAY _FLOATS_OR_STRINGS_ ) ;

fragment LETTER : '$'| 'A'..'Z' | 'a'..'z' | '_' ;
fragment DIGITS : ('0'..'9')+;
fragment EXP : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;
STRING : '"' ( ~('"') )* '"' ;
ID  :   LETTER (LETTER|DIGITS)*;
FLOAT :  (DIGITS? '.' DIGITS EXP?) | (DIGITS EXP?) ;
WS  :   (' '|'\t'|'\n'|'\r')+ {Skip();} ;


- Andy

________________________________

CONFIDENTIALITY NOTICE: This e-mail transmission, and any documents, files or 
previous e-mail messages attached to it, may contain information that is 
confidential and/or legally privileged. If you are not the intended recipient, 
or a person responsible for delivering it to the intended recipient, please DO 
NOT disclose the contents to another person, store or copy the information in 
any medium, or use any of the information contained in or attached to this 
transmission for any purpose. If you have received this transmission in error, 
please immediately notify the sender by reply email or at 
priv...@plantronics.com, and destroy the original transmission and its 
attachments without reading or saving in any manner.

For further information about Plantronics - the Company, its products, brands, 
partners, please visit our website www.plantronics.com.

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to il-antlr-inter...@googlegroups.com.
To unsubscribe from this group, send email to 
il-antlr-interest+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to