[antlr-interest] Could you advise me ?
Lloyd Dupont
lloyd at galador.net
Sat Apr 20 23:36:02 PDT 2002
> 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 ?
. (one dot, not '.' which is a dot character)
but never use (.)* it will consume all your file...
instead use ~('\r\|'\n\), which mean anything but '\r' or '\n' character
> No parameters : <dodar>
> Parameters (Quotes) : <dodar Param1="value" Param2="Value">
> Parameters (No Quotes) : <dodar Param1=value Param2=Value>
did you try sometjing like (I am not a guru, just assuming)
TAG: '<' TAGNAME PARAM* '>';
TAGNAME: "dodar"
| "coucou"
| "foo"
| "bar"
| "toto"
;
PARAM: IDENT '=' VALUE;
... to be continued ...
> How can I describe this using Antlr ?
like above...
> 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 ?
any optional rule is stated with ?, (did you look the doc or, at last, the
examples ?)
for instance:
TAG: '<' TAGNAME PARAM* '>'; TAGBODY ("</" TAGNAME ">")?;
or even better:
TAG: '<' t1:TAGNAME PARAM* '>'; TAGBODY
("</" t2:TAGNAME { t1.getText().equals(t2.getText()); }? ">")?;
> I would be grateful for any advice you can offer.
thanks, you're wellcome.
> Thanks in advance
you too good :-)
> John Clarke
Lloyd Dupont
painfully learning ANTLR fellow user
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list