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
Return to the
comp.compilers page.
Search the
comp.compilers archives again.