Skip to content

Latest commit

 

History

History
209 lines (172 loc) · 8.51 KB

03-Expressions.md

File metadata and controls

209 lines (172 loc) · 8.51 KB

Index



Expressions

Aritmetics

They return numeric values (Powers or Skills) after being evaluated.

Operators:

+ : Addition.

- : Subtraction.

* : Multiply.

/ : Skill division. Takes 2 Powers and returns a Skill.

// : Integer division. Takes 2 Powers and returns a Power that corresponds to the division's quotient.

% : Modulus. toma dos enteros y regresa un entero que corresponde al resto de la división.

- : Minus. Takes a Power or Skill and multiply it by -1.

# : Length. Takes an array or list and returns the number of elements it contains.


Boolean

They return boolean values (Win or Lose) after being evaluated.

Operators between booleans:

|| : Disjunction.

&& : Conjunction.

! : Negation.

Operators between any scalar type:

== : Equality. For pointers it compares the pointed elements.

!= : Inequality. For pointers it compares the pointed elements.

> : Greater than. For characters the normal lexical order is followed.

>= : Greater or equal than. For characters the normal lexical order is followed

< : Less than. For characters the normal lexical order is followed

<= : Less or equal than. For characters the normal lexical order is followed

Ternary conditional operator:

Boolean expression quest Win case function loot Lose case function

Evaluates and returns the result of the Win case function or Lose case function, depending if the boolean expression evaluates Win or Lose.


Characters

They return a character after being evaluated.

Monadic prefix operators:

buff: Uppercase. Converts the given alphabetic character to its uppercase representation.

debuff: Lowercase. Converts the given alphabetic character to its lowercase representation.


Arrays and Lists

They return an array or list after being evaluated.

Operators:

|)(| : Array indexing. Index range [0..#array - 1].

|><| : List indexing. Index range [0..#list - 1].

:: : List concatenation. Takes 2 lists and appends the second to the first.

: : List insertion (annex) Prepend a head element to a list.


Records

Access operator: spawn

It takes a record or union and an id, and if it matches a field, returns the value in it.

To know more go to Records and Unions data types section.


Pointers

Dereference operator: puff

Given a variable of the pointer type, it returns the value that was pointed by the given variable.

In the case that the variable is not dereferenced, its address is the one being used.

To know more go to Pointers data type section.



Expressions evaluation

Operators precedence

Precedence in descending order:

Operator Firts level Second level Third level Fourth level
Aritmetic Minus, Length Integer Division, Modulus Multiply, Division Addition, Subtraction
Boolean Negation Conjunction, Disjunction Ternary Comparators
Character Uppercase Lowecase
Arrays Indexing
Lists Indexing, Annex Concatenation
Record Access
Pointer Dereference

Operators associativity

Operator Izquierda Derecha No asocia
Aritmetic Multiply, Division, Integer Division, Modulus Addition, Subtraction, Minus, Length
Boolean Conjunción, Disyunción, Ternary Negation Comparators
Character Uppercase, Lowercase
Arrays Indexing
Lists Indexing, Annex, Concatenation
Record Access
Pointer Dereference

Evaluation order

Expressions are evaluated from left to right.

Next page ->



Table of content