H (Hybrid) Language - v0.03, by Dr. Herong Yang
Evaluation Order of Multiple Operators
This section describes the precedence of operators.
When an expression has multiple operations with multiple operators, the order of evaluation of each operation is based on the following rules:
1. Operators of higher precedences are evaluated before operators of lower precedences.
2. Operators of on the left side are evaluated before operators on the right side.
Examples of expression evaluation orders:
1. "*" has a higher precedence than "+":
# "2 * 3" is evaluated first, because "*" has a higher precedence 1 + 2 * 3; # The above expression is an alias of: integer.add(1,integer.multiply(2,3));
2. "+" and "-" have the same precedence:
# "1 + 2" is evaluated first, because "+" is on the left side # and "+" and "-" have the same precedence 1 + 2 - 3; # The above expression is an alias of: integer.subtract(integer.add(1,2),3);
The above examples assume that we are using the commonly accepted precedence rules of arithmetic operations.
The exact list of operators and their precedences will be provided when we introduce individual data types.
Table of Contents