At 11:31 AM 06-06-2002 -0700, Brent Dax wrote:
>#Preliminary Perl6::Regex
>#  This does not have any actions, but otherwise I think is correct.
>#  Let me know if it's right or not.

I'm not a regex guru, but...


>use 6;
>
>grammar Perl6::Regex {
>   rule metachar { <[<{(\[\])}>:*+?\\|]>                    }
>
>   rule ws       { [<[\h\v]>|\#\N*]*                        }
>
>   rule atom     { <ws> (<!metachar> | \\ . | <group>) <ws> }

I had gotten the impression that a literal string separated by whitespace 
was an atom, so

rule foofoobar { foo <1,2> bar }

would match 'foobar' or 'foofoobar'.  If so, I think <!metachar> needs to 
be replaced by <!metachar>+

>     rule modifier { <ws> (<[*+?]> \?? \:?) <ws>              }
>
>   rule molecule {
>    (  <atom> <modifier>

<atom> ends with <ws>, <modifier> begins with <ws>.  Does that mean that 
there must be two <ws> between an atom and a modifier?  (Possibly not, 
since <ws> can match null, so 'a*' would match <ws> with four nulls).  Just 
clarifying for myself.

>    |  <ws> \:<1,4> <ws>
>    |  <compound> <ws> \| <ws> <compound>
>    )
>   }
>
>   rule compound { [(<molecule>)]*                          }
>
>   rule group    {<ws>
>    (  \( <compound> \)
>    |  \[ <compound> \]
>    |  \{ <Perl6::Code> \}
>    |  \< !? [ \w+ | \d+ , \d+ ] <compound> \>
>    )
>    <ws>
>   }
>}
>
>--Brent Dax <[EMAIL PROTECTED]>
>@roles=map {"Parrot $_"} qw(embedding regexen Configure)
>
>Early in the series, Patrick Stewart came up to us and asked how warp
>drive worked.  We explained some of the hypothetical principles . . .
>"Nonsense," Patrick declared.  "All you have to do is say, 'Engage.'"
>     --Star Trek: The Next Generation Technical Manual

Reply via email to