Advertisement
raedr7n

Dice notation EBNF grammar

Jun 13th, 2022 (edited)
2,332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BNF 0.48 KB | None | 0 0
  1. rpg = rpg "+" rpg1
  2.     | rpg "-" rpg1
  3.     | rpg1
  4.     ;
  5.  
  6. rpg1 = rpg1 "*" rpg2
  7.      | rpg1 "/" rpg2
  8.      | rpg2
  9.      ;
  10.  
  11. rpg2 = rpg2 "^" alldice
  12.      | alldice
  13.      ;
  14.  
  15. alldice = [loop] "d" loop
  16.         | gdice
  17.         ;
  18.  
  19. gdice = [loop] "d" loop "g" [loop]
  20.       | ldice
  21.       ;
  22.  
  23. ldice = [loop] "d" loop "l" [loop]
  24.       | loop
  25.       ;
  26.  
  27. loop = num
  28.      | "(" rpg ")"
  29.      ;
  30.  
  31. num = digit [num] ;
  32.  
  33. digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement