Skip to content

Instantly share code, notes, and snippets.

Created August 9, 2009 12:42
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/164758 to your computer and use it in GitHub Desktop.
Save anonymous/164758 to your computer and use it in GitHub Desktop.
use v6;
grammar DiceParser {
regex TOP { ^ <numdice> 'd' <numsides> <modifier>? $ };
rule modifier { <plusminus> <digit>+ };
regex numdice { <digit>+ };
regex numsides { <digit>+ };
regex plusminus { \+ | \- };
};
my Match $match = DiceParser.parse('2d6+2');
say $match<modifier><plusminus>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment