[antlr-interest] a new paper on ANTLR style grammars

Terence Parr parrt at cs.usfca.edu
Thu Nov 20 12:06:27 PST 2003


On Thursday, November 20, 2003, at 10:05 AM, Arnar Birgisson wrote:

> Hello there..
>
> Am I correct in the assumption that the "|" operator in ANTLR is not
> ordered, i.e. it has the same meaning as in BNF? If so, wouldn't the 
> "/"
> operator as defined in the paper be useful? I don't have much
> perspective on this as I am yet a beginner, but wouldn't it at least
> save us from inserting "options {greedy=true}:" and syntactic 
> predicates
> here and there?

Given a nondeterminism like that derived from the if-then-else 
ambiguity, ANTLR chooses the first alternative that matches; order is 
implied.  For syntactic predicates, if a predicate fails, it tries the 
next alt that could match it; again an implied order.

The difference is that either a nondeterminism or syntactic predicate 
are required to get this functionality.  The PEG stuff from Bryan Ford 
(the paper) is explicitly ordered from the start.  I've not dug enough 
to know much more.

Terence

>
> Arnar
>
>> -----Original Message-----
>> From: Terence Parr [mailto:parrt at cs.usfca.edu]
>> Sent: 18. nóvember 2003 19:31
>> To: antlr-interest at yahoogroups.com
>> Subject: [antlr-interest] a new paper on ANTLR style grammars
>>
>>
>> Folks,
>>
>> Here is an upcoming paper to a conference that formally defines
>> grammars that operate like antlr: where alternatives have an implied
>> order.  Nicely formalizes the strategy of predicated parsing etc...
>>
> http://www.brynosaurus.com//pub/lang/peg.pdf
>
> Just as we have the syntactic predicate that says what the lookahead
> context must be, he has a "not predicate" that says what the lookahead
> cannot be.  This is very useful for such things as saying "match this
> rule, but only if not following in context by this next thing."  Really
> powerful.  moreover, he has a parser that demonstrates linear
> backtracking parsing by use of dynamic programming.  I will be studying
> his technique very closely before code gen for ANTLR. :)
>
> Ter
> --
> 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/
>
>
>
--
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/ 




More information about the antlr-interest mailing list