Previous: , Up: Arithmetic expressions   [Contents][Index]


Formal grammar for arithmetic expressions

Formal grammar for arithmetic expressions

For completeness, the following productions formalize the process by which coNCePTuaL parses arithmetic expressions:

<expr> ::= <cond_expr>
<cond_expr> ::= <add_expr> IF <rel_expr> OTHERWISE <add_expr>
<add_expr> ::= <mult_expr>
| <add_expr> ‘+ <mult_expr>
| <add_expr> ‘- <mult_expr>
| <add_expr> ‘| <mult_expr>
| <add_expr> XOR <mult_expr>
<mult_expr> ::= <unary_expr>
| <mult_expr> ‘* <unary_expr>
| <mult_expr> ‘/ <unary_expr>
| <mult_expr> MOD <unary_expr>
| <mult_expr> ‘>> <unary_expr>
| <mult_expr> ‘<< <unary_expr>
| <mult_expr> ‘& <unary_expr>
<power_expr> ::= <primary_expr> [‘** <unary_expr>]
<unary_expr> ::= <power_expr>
| <unary_operator> <unary_expr>
<unary_operator> ::= +’ | ‘-’ | NOT
<primary_expr> ::= ( <expr> ‘)
| <ident>
| <integer>
| <func_name> ‘( <enumerated_exprs> ‘)
| REAL( <expr> ‘)
<enumerated_exprs> ::= <expr> [‘, <expr>]*
Scott Pakin, pakin@lanl.gov