Created
June 22, 2015 19:58
-
-
Save StoneCypher/374acd81c3ca00393297 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start | |
= w:(die _)* { return w.map(function(X) { return X[0] }); } | |
number | |
= [0-9] | |
nonzero | |
= [1-9] | |
symbol | |
= [\+-] | |
count | |
= integer | |
diesize | |
= 'd' int:integer { return int; } | |
modifier | |
= '+' int:integer { return int; } | |
/ '-' int:integer { return -1 * int; } | |
die | |
= cnt:count sz:diesize mod:modifier { return { count: cnt, size: sz, adjust: mod }; } | |
/ cnt:count sz:diesize { return { count: cnt, size: sz, adjust: 0 }; } | |
/ sz:diesize mod:modifier { return { count: 1, size: sz, adjust: mod }; } | |
/ sz:diesize { return { count: 1, size: sz, adjust: 0 }; } | |
integer | |
= nz:nonzero num:number* { return parseInt(nz + num.join(''), 10); } | |
// optional whitespace | |
_ = [ \t\r\n]* | |
// mandatory whitespace | |
__ = [ \t\r\n]+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment