{int}({binop}{int})?where int stands for an integer and binop denotes +, - or *. Observe that each of the above arithmetic expressions contains at most one arithmetic operation. Here's a session with such a calculator
? -3 -> -3 ? -3 + 4 -> 1 ? 2 + 3 -> 5 ? 2 + 3 + 4 + 5 -> 5 ? 2 / 3 Invalid expression: / ? 1234567890 * 987654321 -> -671530190Optionally your calculator can consider arithmetic expressions of the form
({val} :=)? {val}({binop}{val})?where val is either an integer or an identifier. In that case your calculator will manage a symbol table for these identifiers.