[antlr-interest] LL-Regular / WAS: BLOG

Oliver Zeigermann oliver at zeigermann.de
Tue Oct 28 22:47:48 PST 2003


Sure, you can left factor. But the resulting grammar would be something 
from less obvious to ugly.

Oliver

Terence Parr wrote:

> Heh, you're right!  It would still be possible to left factor those 
> rules, however, making it slightly faster than LL-regular.
> 
> Ter
> 
> On Tuesday, October 28, 2003, at 03:26 PM, Oliver Zeigermann wrote:
> 
> 
>>Talking to myself :)
>>
>>An example for a grammar that would work with LL-regular is one for
>>XML start tags and empty elements
>>
>>startTag : LT NAME (NAME = VALUE)* GT ;
>>
>>emptyElement : LT NAME (NAME = VALUE)* SLASH GT ;
>>
>>endTag : LT SLASH NAME GT ;
>>
>>xmlElement
>>     : startTag
>>     	( xmlElement
>>     	| TEXT
>>        )*
>>       endTag
>>      | emptyElement
>>    ;
>>
>>Becaues of the attributes, this will not work with any fixed
>>lookahead, but would require syntactic predicates in ANTLR 2.x
>>
>>In ANTLR 3.x a regular scan ahead would do!
>>
>>That's good!
>>
>>Oliver
>>
>>--- In antlr-interest at yahoogroups.com, "Oliver Zeigermann"
>><oliver at z...> wrote:
>>
>>>I have just read part of the BLOG and find the idea to scan ahead with
>>>an FA a very interesting idea. I noticed, I myself as a human, do
>>>exactly the same when disambiguiting something in a formal language:
>>>scanning ahead until you find the character you are looking for to
>>>decide between the options. So, if this method does not work on a
>>>grammar, the language or the grammar should be fairly unreadable for
>>>humans as well.
>>
>>
>>
>>
>>
>>Your use of Yahoo! Groups is subject to 
>>http://docs.yahoo.com/info/terms/
>>
>>
>>
> 
> --
> Professor Comp. Sci., University of San Francisco
> Creator, ANTLR Parser Generator, http://www.antlr.org
> Co-founder, http://www.jguru.com
> Co-founder, http://www.knowspam.net enjoy email again!
> Co-founder, http://www.peerscope.com pure link sharing
> 
> 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 
> 




 

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




More information about the antlr-interest mailing list