From 48896c56c39344fa429260d3969eccc93ef8035c Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Wed, 7 Sep 2022 07:33:13 +0100 Subject: Some docs on operators --- language.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/language.md b/language.md index ec0a425..4044ad1 100644 --- a/language.md +++ b/language.md @@ -354,7 +354,25 @@ TODO: a zero ended array of u8 with special initializers ## Operators -TODO +Micro2 uses the same operators and almost the same operator precedence as C, from more to less priority: + +``` +! - ~ +/ * % +& +- + +<< >> | ^ +> >= < <= +|| && +!= == += +``` + +Arithmetic operators only apply to integers. + +Comparison operators only apply to integers, with the exception of `==` and `!=` that also apply to other types (if both operands are of the same type). + +Logic operators apply to booleans and they are lazy operators (e.g. in `a && b`, `b` won't be evaluated if `a` is false). ## Flow control -- cgit v1.2.3