The grammar of expressions
The Backus-Naur Form (BNF) notation is used to specify the grammar for programming languages. The semantics of BNF can be learned from books, and plenty of material is available. The grammar of the expression evaluator we use is as follows:
<Expr> ::= <Term> | Term { + | - } <Expr> <Term> ::= <Factor> | <Factor> {*|/} <Term> <Factor>::= <number> | ( <expr> ) | {+|-} <factor> | SIN(<expr>) | COS(<expr>) | $t
This BNF can be converted to source code very easily.