[antlr-interest] languages without reserved words

Michael Brade brade at informatik.uni-muenchen.de
Wed Mar 8 07:02:26 PST 2006


On Wednesday 08 March 2006 13:47, Martin Probst wrote:
> conclusion we already had - keyword free grammars are messy, and the
> distinction between parser and lexer doesn't really hold for them.
I see, and now that makes a lot more sense to me, I didn't understand it 
before.

> > The big problem with this is that guessing won't pick it up and will thus
> > fail. In the above grammar I need the guessing in the second line (left
> > empty) to see if there is at least an LP coming up.
>
> I think the only way to keep guessing working with such a language in
> ANTLR 2 is to have a stateful lexer.
yeah, and I'm not gonna implement that :-/

> You could also write:
>
> data_term: { LA(1).getText().equals("declare") }? NCNAME "ns-prefix" ...
> 	| NCNAME
I'm not sure. That would mean the second NCNAME alternative would never be 
executed because the first throws an exception. At least the rules that only 
have one alternative won't work since there is no backtracking. I thought 
about those things already but apart from modifying the generated code I 
haven't been able to find another solution.

Cheers,
-- 
Michael Brade;                 KDE Developer, Student of Computer Science
  |-mail: echo brade !#|tr -d "c oh"|s\e\d 's/e/\@/2;s/$/.org/;s/bra/k/2'
  °--web: http://www.kde.org/people/michaelb.html

KDE 4: Beyond Your Expectations
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20060308/5d741091/attachment.bin


More information about the antlr-interest mailing list