[antlr-interest] A grammar question

johnclarke72 johnclarke at hotmail.com
Tue Apr 16 11:47:45 PDT 2002


I am working on a parser for a simple language.  I am new to ANTLR 
and just have a couple of questions regarding grammar issues.

1 ) In my code I use ( 'a'..'z' | 'A'..'Z' ) to refer to all of the 
letters from a - z.  Is there any way to add something that will make 
it accept anything (eg all puntuation,etc) without having to define 
every item ?

2) In my grammar an item may have parameters or it may not have 
parameters.  The values for these parameters may have quotes or they 
may not.  A given item can potentially have more than 1 parameter.  
For example :

No parameters : <dodar>
Parameters (Quotes)    : <dodar Param1="value" Param2="Value"> 
Parameters (No Quotes) : <dodar Param1=value Param2=Value>

How can I describe this using Antlr ?

3) An item must have a start tag but the end tag is optional.  Eg 
either <dodar> or <dodar></dodar> is acceptable.  How can I describe 
this using Antlr ?

4) I presume that if I wanted to remove any characters from the 
parsed data I will have to write the Java code myself (eg to 
remove "'s and >'s).  Is this a correct assumption ?

I would be grateful for all advice offered regarding this.

John


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list