Skip to content

Instantly share code, notes, and snippets.

Created June 29, 2013 07:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5890252 to your computer and use it in GitHub Desktop.
Save anonymous/5890252 to your computer and use it in GitHub Desktop.
use v6;
my $l1 = "1: 2 3 4";
#my $l2 = "11: 2 3 4"; # Works
grammar Data {
rule TOP { ^ <date> ':' <datasequence> $ }
rule date { \d?\d } # problem with '?'
rule datasequence { (\s?<dane>)+ }
rule dane { \d+ }
}
say Data.parse( $l1 ); # Fail
say "OK" if $l1 ~~ /\d?\d:/; # OK
#say Data.parse( $l2 ); # Works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment