Re: Bison Parser negate production rules

George Neuner <gneuner2@comcast.net>
29 Mar 2007 23:07:32 -0400

          From comp.compilers

Related articles
Bison Parser negate production rules royzlife@gmail.com (2007-03-23)
Re: Bison Parser negate production rules gneuner2@comcast.net (George Neuner) (2007-03-26)
Re: Bison Parser negate production rules cfc@shell01.TheWorld.com (Chris F Clark) (2007-03-26)
Re: Bison Parser negate production rules mco333@sympatico.ca (mco333) (2007-03-27)
Re: Bison Parser negate production rules gneuner2@comcast.net (George Neuner) (2007-03-27)
Re: Bison Parser negate production rules cfc@shell01.TheWorld.com (Chris F Clark) (2007-03-29)
Re: Bison Parser negate production rules Meyer-Eltz@t-online.de (Detlef Meyer-Eltz) (2007-03-29)
Re: Bison Parser negate production rules gneuner2@comcast.net (George Neuner) (2007-03-29)
Re: Bison Parser negate production rules cfc@shell01.TheWorld.com (Chris F Clark) (2007-04-02)
| List of all articles for this month |
From: George Neuner <gneuner2@comcast.net>
Newsgroups: comp.compilers
Date: 29 Mar 2007 23:07:32 -0400
Organization: Compilers Central
References: 07-03-084 07-03-090 07-03-094 07-03-097 07-03-100
Keywords: parse, LALR
Posted-Date: 29 Mar 2007 23:07:32 EDT

On 29 Mar 2007 00:57:34 -0400, Chris F Clark
<cfc@shell01.TheWorld.com> wrote:


>>>In fact, Yacc++ can be thought of as taking Yacc/Bison and adding in
>>>regular expressions and predicates (then cleaning up the syntax a
>>>little). In it we have a not predicate that allows exactly what you
>>>are asking for. You will find similar functionality in PCCTS/ANTLR
>>>although the underlying technology is LL not LR for them, so you
>>>cannot use left recursion (or precedence rules).


I was already aware of ANTLR's predicates and complement operator, but
it was not clear from the latest manual I had that the complement
operator could be used on token sets in the parser as well as in
regular expressions.


My fault really ... for a long time the software and manual were
separate and I tended to get a new manual only when new features were
announced.


The manual for the current 2.7.7 version does in fact say clearly that
complement sets can be used in parsers and, AFAICT, it works as
advertised. It also seems to work in 2.7.4 (the latest I had) but an
older 2.5.8 version (circa 1998?) choked badly on the example I tried
so I'm guessing that support for set complement is relatively recent.


>
>http://en.wikipedia.org/wiki/Syntactic_predicate
>


ANTLR and it's predicates are mentioned in the page, but the
complement example shows a generic PEG rather than something that
works in ANTLR.




I still think set complement is a blunt instrument. I can't recall
ever really missing it and I can't easily think of a good use for it.
I can't imagine ever wanting to specify a parser rule in the negative
as in the ANTLR example


expr: T1 (~(T1|T2|T3))* (T1|T2|T3);


because it's so very unlikely that I would ever want to accept every
other valid language token in the hole.


But I guess it's handy to know it's there if the need ever does arise.


Thanks,
George


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.