A simple RPN language
$ go install github.com/j0hax/smack
Example: the input is the equivalent of (1 + 2) * 6
, resultung in 18
.
1 2 + 6 *
18
The smack interpreter works with standard input and output streams, meaining you can perform computations with pipes:
$ echo '1 2 + 6 *' | smack > out.txt
$ smack < out.txt
18
Very much a WIP. Some tokens for mathematical functions have been implemented, such as log
. Check the source for the lexer.
Does not exist (yet). Don't try to pop more than the stack can handle, or else you won't be doing many calculations today.
I just wanted something that rhymes with stack.