Skip to content

Latest commit

 

History

History
52 lines (43 loc) · 5.93 KB

operators.md

File metadata and controls

52 lines (43 loc) · 5.93 KB

Documentation

Operators

Arithmetic Logic Bitwise Unary prefix
+ Addition == Equal & And ++ Increment then use
- Subtraction != Not equal | Or -- Decrement then use
* Multiplication < Less ^ Xor ~ Bitwise not
/ Division <= Less or equal << Left shift not Logic not
% Modulus > Greater >> Right shift
>= Greater or equal
&& And
|| Or

Operator precedence

BIPLAN uses a layered recursive descent parser that naturally enforces standard mathematical hierarchy that perfectly mirrors standard C precedence:

  1. Factor: Parentheses, numbers, constants, variables, function calls and system functions
  2. Term: *, /, %
  3. Expression: +, -, &, |, ^, <<, >>
  4. Relation: ==, !=, <, >, <=, >=, &&, ||

For this reason this expression 2 + 3 * 4 evaluates to 14; multiplication has a higher precedence than addition.

Operator syntax

In BIPLAN the following program is incorrect:

if 1 == 1 || 0 == 0 print "OK" end

The correct form is:

if (1 == 1) || (0 == 0) print "OK" end

Parenthesis are required for the interpreter to detect a nested relation and compute it before the primary relation.