Forked from StoneCypher/gist:374acd81c3ca00393297
          
        
    
          Last active
          August 29, 2015 14:23 
        
      - 
      
- 
        Save forestbelton/8dd3414a81e2fca9ca53 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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 | |
| = (d:die _ { return d })* | |
| number | |
| = [0-9] | |
| nonzero | |
| = [1-9] | |
| diesize | |
| = 'd' int:integer { return int; } | |
| modifier | |
| = '+' int:integer { return int; } | |
| / '-' int:integer { return -1 * int; } | |
| die | |
| = cnt:integer? sz:diesize mod:modifier? { return { count: cnt || 1, size: sz, adjust: mod || 0 }; } | |
| integer | |
| = nz:nonzero num:number* { return parseInt(nz + num.join(''), 10); } | |
| // optional whitespace | |
| _ = [ \t\r\n]* | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment