#Preliminary Perl6::Regex
#  This does not have any actions, but otherwise I think is correct.
#  Let me know if it's right or not.

use 6;

grammar Perl6::Regex {
  rule metachar { <[<{(\[\])}>:*+?\\|]>                    }
  
  rule ws       { [<[\h\v]>|\#\N*]*                        }
  
  rule atom     { <ws> (<!metachar> | \\ . | <group>) <ws> }
  
  rule modifier { <ws> (<[*+?]> \?? \:?) <ws>              }
  
  rule molecule {
   (  <atom> <modifier>
   |  <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