USING: command-line fry io kernel macros math math.parser namespaces peg.ebnf prettyprint sequences strings ; IN: b EBNF: parse-calc sign = "-" => [[ >string ]] whole = ([0-9])* => [[ >string ]] digit = "." ([0-9])* => [[ [ >string ] map concat ]] number = sign? whole digit? => [[ [ f eq? not ] filter concat string>number ]] add = "+" => [[ [ + ] ]] sub = "-" => [[ [ - ] ]] mul = "*" => [[ [ * ] ]] div = "/" => [[ [ / ] ]] ops = add|sub|mul|div expr = number ops number => [[ [ first ] [ third ] [ second ] tri '[ _ _ @ ] ]] ;EBNF MACRO: calc ( string -- ) parse-calc ; : b-main ( -- ) command-line get [ first parse-calc call( -- x ) number>string print ] unless-empty ; MAIN: b-main