Re: Alternative Syntax for Regular Expressions?

Ralph Boland <rboland@unb.ca>
13 Oct 2001 23:07:56 -0400

          From comp.compilers

Related articles
Alternative Syntax for Regular Expressions? forrest@ce.berkeley.edu (Jon Forrest) (2001-10-10)
Re: Alternative Syntax for Regular Expressions? eeide@cs.utah.edu (Eric Eide) (2001-10-12)
Re: Alternative Syntax for Regular Expressions? joachim_d@gmx.de (Joachim Durchholz) (2001-10-12)
Re: Alternative Syntax for Regular Expressions? jenglish@flightlab.com (2001-10-12)
Re: Alternative Syntax for Regular Expressions? vannoord@let.rug.nl (2001-10-12)
Re: Alternative Syntax for Regular Expressions? dmitry@elros.cbb-automation.de (2001-10-12)
Re: Alternative Syntax for Regular Expressions? alexc@world.std.com (2001-10-13)
Re: Alternative Syntax for Regular Expressions? rboland@unb.ca (Ralph Boland) (2001-10-13)
Re: Alternative Syntax for Regular Expressions? spinoza1111@yahoo.com (2001-10-14)
Re: Alternative Syntax for Regular Expressions? eanders@cs.berkeley.edu (2001-10-16)
Re: Alternative Syntax for Regular Expressions? ralph@inputplus.demon.co.uk (2001-10-16)
Re: Alternative Syntax for Regular Expressions? spinoza1111@yahoo.com (2001-10-20)
Re: Alternative Syntax for Regular Expressions? spinoza1111@yahoo.com (2001-10-20)
Re: Alternative Syntax for Regular Expressions? spinoza1111@yahoo.com (2001-10-20)
| List of all articles for this month |

From: Ralph Boland <rboland@unb.ca>
Newsgroups: comp.compilers
Date: 13 Oct 2001 23:07:56 -0400
Organization: University of New Brunswick
References: 01-10-029
Keywords: lex
Posted-Date: 13 Oct 2001 23:07:56 EDT

Jon Forrest wrote:


> I've been looking at some pretty hairy regular expressions (in Perl)
> recently that are virtually unreadable. The thought crossed my mind
> that maybe there are some alternatives to classic regular expression
> syntax out there. Note that I'm only talking about the syntax - it's
> hard to beat the semantics of regular expressions.
>
> Does anybody know of anything?


I've invented a few operators of my own.


a ^ b ==> a (b a)*
                                                great for extended CFGs
                                                Also, easy to construct a F.S.M. from.
                                                (IDList -> ID ^ ',' ';' )


a ^| b ==> a (a | b)*
                                                useful for writing scanners.
                                                  ( identifier --> CHAR ^| INT )


a% ==> (anything except a) immediately followed by a.
                                                    great operator for things like sed/grep/perl
                                                      I would think.


a @ b ==> (a | b | ab)
                                                      This is useful for reasons too difficult
to explain here.




I also like using {a} instead of a* and [a] instead of a?


So has anybody else invented or know of useful
non-standard regular expression operators?????




I also like the adea of extending regular expressions to include the $
operator where the $ operator stands for the extended regular
expression.


The result is a one production extended CFG.


e.g.


    ((abc)*$(def)) | ghi


    specifies the same language as
the one production grammar:


      Start ==> ((abc)* Start (def)) | ghi




(So you can beat the semantics of regular expressions :) )


Ralph Boland


Post a followup to this message

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