# Tokay Calc
version : 0.4
_ : Char< \t>+ # redefine whitespace to just tab and space
Factor : @{
Float _ # built-in 64-bit signed float token
Int _ # built-in bigint token
'(' _ Expr Expect<')'> _
}
Term : @{
Term '*' _ Factor $1 * $4
Term '/' _ Factor $1 / $4
Factor
}
Expr : @{
Expr '+' _ Term $1 + $4
Expr '-' _ Term $1 - $4
Term
}
begin print("Tokay Calc " + version) # print at startup
Expr _ print("= " + $1) # execute each expression
'exit' exit # exit command
# any other input, e.g. newline, is ignored