Skip to content

Instantly share code, notes, and snippets.

@pmichaud
Created October 29, 2009 20:28
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 pmichaud/221783 to your computer and use it in GitHub Desktop.
Save pmichaud/221783 to your computer and use it in GitHub Desktop.
$ cat x
grammar ABC {
token TOP { $<num>=[\d+] <?{ +$<num> <= 255 }> }
}
for 1, 1000, 255, 256, 17 {
print($_);
say( ABC.parse($_) ?? ' matches' !! " doesn't match" );
}
$ ./nqp x
1 matches
1000 doesn't match
255 matches
256 doesn't match
17 matches
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment