Evaluating R-value Expressions

Last modified by John Stroy on 2018/10/19 11:40

Abstract

In this specification, we attempt to describe the process of HSP's implementation of r-values.

Specification

Construct an expression tree for the r-value expression.

expression := operand
operand := literal | function(operandList) | operand infixOperator operand | prefixOperator operand | operand postfixOperand | (operand)
operandList := empty | operand | (operand ,)+ operand
literal := numeric | string

For each operator or function, add child nodes as parsed from left-to-right to the tree from left-to-right.

Evaluate expressions by walking the tree, depth first, evaluating the left-most unevaluated child first.

On encountering one or more invalid operands for an operator, an error will be thrown after evaluating both operands.

Grouping does not influence the order of operand evaluation (e.g. most nested term is not necessarily evaluated first), but grouping does influence the order of operator evaluation (e.g. restructures the tree to select which expression is a child of the other expression).