Guest User

Spew Template for Simple Expressions

a guest
Apr 23rd, 2013
308
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. \* Spew template for simple arithmetic expressions
  2.  
  3. \* Digits
  4. %DIGIT
  5. 0
  6. 1
  7. 2
  8. 3
  9. 4
  10. 5
  11. 6
  12. 7
  13. 8
  14. 9
  15.  
  16. \* Numbers, which are just strings of digits.
  17. \* The numbers in parentheses add weight so they're chosen more often.
  18. \* E.g., the first line is p(1/4) and the second is p(3/4)
  19. %NUMBER
  20. \DIGIT
  21. (3)\DIGIT\NUMBER
  22.  
  23. \* Operators
  24. %OP
  25. +
  26. -
  27. *
  28. /
  29.  
  30. \* Expressions.
  31. %EXPR
  32. (10)\NUMBER \OP \NUMBER
  33. (\EXPR)
  34. (10)(\EXPR \OP \EXPR)
  35.  
  36. \* This is where Spew starts, an EXPR followed by a newline
  37. %MAIN
  38. \EXPR\!
RAW Paste Data