Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \* Spew template for simple arithmetic expressions
- \* Digits
- %DIGIT
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- \* Numbers, which are just strings of digits.
- \* The numbers in parentheses add weight so they're chosen more often.
- \* E.g., the first line is p(1/4) and the second is p(3/4)
- %NUMBER
- \DIGIT
- (3)\DIGIT\NUMBER
- \* Operators
- %OP
- +
- -
- *
- /
- \* Expressions.
- %EXPR
- (10)\NUMBER \OP \NUMBER
- (\EXPR)
- (10)(\EXPR \OP \EXPR)
- \* This is where Spew starts, an EXPR followed by a newline
- %MAIN
- \EXPR\!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement