Hi, yes, close to that:
name returns [String name]
: ID { $name = $ID.text; }
| STRING { $name = getString( $STRING.text ); }
;
So, a rule name can be either an ID or a STRING. ID is what you got already:
ID
: ('a'..'z'|'A'..'Z'|'_'|'$'|'\u00c0'..'\u00ff')('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'\u00c0'..'\u00ff')*
;
A String is a valid Java string... so pretty much anything enclosed in either " or '.
STRING
: ('"' ( EscapeSequence | ~('\\'|'"') )* '"')
| ('\'' ( EscapeSequence | ~('\\'|'\'') )* '\'')
;
In other words, if you want to allow the user to write rule names and don't want to bother in validating it, just enclose the rule name in " and be done with it. The only thing that may be good is to limit the length of the string... you may want to use a hard limit around 60 characters I guess.
[]s
Edson
[]s
Edson
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3529-6000
Mobile: +55 11 9287-5646
JBoss, a division of Red Hat @ www.jboss.com