Re: Regular expression grammar?

Zalman Stern <zalman@netcom18.netcom.com>
24 Sep 1999 22:53:59 -0400

          From comp.compilers

Related articles
Regular expression grammar? bediger@teal.csn.net (Bruce Ediger) (1999-09-16)
Re: Regular expression grammar? jjan@cs.rug.nl (J.H.Jongejan) (1999-09-20)
Re: Regular expression grammar? terryg@uswest.net (1999-09-20)
Re: Regular expression grammar? lex@cc.gatech.edu (1999-09-20)
Re: Regular expression grammar? cbarron3@ix.netcom.com (1999-09-20)
Re: Regular expression grammar? zalman@netcom18.netcom.com (Zalman Stern) (1999-09-24)
Re: Regular expression grammar? zalman@netcom18.netcom.com (Zalman Stern) (1999-09-24)
Re: Regular expression grammar? zalman@netcom18.netcom.com (Zalman Stern) (1999-09-24)
Re: Regular expression grammar? cbarron3@ix.netcom.com (1999-09-27)
| List of all articles for this month |
From: Zalman Stern <zalman@netcom18.netcom.com>
Newsgroups: comp.compilers
Date: 24 Sep 1999 22:53:59 -0400
Organization: Netcom
References: 99-09-051 99-09-070
Keywords: lex, parse

lex@cc.gatech.edu wrote:
: %token SYMBOL OR STAR LPAREN RPAREN
: %%
: regexp : r1 ;


: r1 : r2 | r1 OR r2 ;
: r2 : r3 | r2 r3 ;
: r3 : primary | r3 STAR ;


: primary : parenthesized | SYMBOL ;




: parenthesized : LPAREN regexp RPAREN ;
: %%


This grammar allows "a**" which the grammar I sent does not. I believe
allowing "a**" is correct and not allowing it is incorrect given the
definition of regular expressions. But I cannot see a sequence of STAR
operators ever being different than a single one and am tempted to disallow
it as its probably a typo. (A smattering of UNIX tools I just tried do
allow "a**".)


Thanks to lex (the poster) for showing a more formal approach to solving
the problem. (Which even manages to avoid a bug!)


-Z-


Post a followup to this message

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