Related articles |
---|
perl regular expression grammar alan@oursland.net (2001-07-17) |
Re: perl regular expression grammar merlyn@stonehenge.com (2001-07-18) |
Re: perl regular expression grammar ralph@inputplus.demon.co.uk (2001-07-18) |
Re: perl regular expression grammar johnmillaway@yahoo.com (John W. Millaway) (2001-07-18) |
Re: perl regular expression grammar mjd@plover.com (2001-07-18) |
Re: perl regular expression grammar abigail@foad.org (2001-07-18) |
Re: perl regular expression grammar alan@oursland.net (2001-07-23) |
Re: perl regular expression grammar usenet11522@itz.pp.sci.fi (Ilmari Karonen) (2001-07-23) |
Re: perl regular expression grammar mjd@plover.com (2001-08-02) |
From: | mjd@plover.com (Mark Jason Dominus) |
Newsgroups: | comp.lang.perl.misc,comp.compilers |
Date: | 18 Jul 2001 20:01:28 -0400 |
Organization: | Plover Systems Co. |
References: | 01-07-080 |
Keywords: | syntax |
Posted-Date: | 18 Jul 2001 20:01:28 EDT |
One comments: Your notation seems unnecessarily cumbersome. Why not
say
<set> ::= "[" "^"? <set-item>+ "]"
as an abbreviation for:
><set> ::= "[" <set-items> "]" | "[^" <set-items> "]"
><set-items> ::= <set-item> | <set-item> <set-items>
?? It seems like not much is gained your way.
You have a few omissions:
In article 01-07-080, Alan Oursland <alan@oursland.net> wrote:
><quant> ::= <group>"*" | <group>"+" | <group>"?" | <group>"{"<bound>"}" | <group>
This should be:
<quant>::= <group>"*" | <group>"+" | <group>"?" | <group>"{"<bound>"}"
| <group>"*?" | <group>"+?" | <group>"??" | <group>"{"<bound>"}?"
| <group>
><group> ::= "("<re>")" | <term>
I think this should look more like this:
<group> ::= "("<qmod><re>")" | <term>
<qmod> ::= "" | "?:" | "?=" | "?>" | "?!" | "?<=" | "?<!"
| <qexpr>
| "?(" <num-or-expr> ")" <re-or-two>
| "?"<modifs> | "?-"<modifs> | "?"<modifs>"-"<modifs>
<num-or-expr> ::= <num> | <qexpr>
<qexpr> ::= "?{" <expr> "}"
<re-or-two> ::= <concat> | <concat> "|" <concat>
<modifs> ::= <modif> | <modif><modifs>
<modif> ::= "s" | "m" | "i" | "x"
I'll leave it up to you to figure out how to represent <expr>. The
rule is that Perl looks for the matching close brace, and backslashed
close-braces don't count on the way.
><char> ::= <non-meta> | "\"<escaped>
><non-meta> ::= any non-meta char
><escaped> ::= <meta>|<control>|<special>|<assert>
This isn't right, because "\d" is legal. It means the same as 'd'.
><hexchar> ::= "x"<hex><hex> | "x{"<hex><hex><hex><hex>"}"
\x3 is also legal.
Hope this helps, although I'm not sure what you're trying to accomplish.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
Return to the
comp.compilers page.
Search the
comp.compilers archives again.