Algorithmic language interpreter (in French only for now)
``bash`
npm install -g algo-lang
Basic usage:
`bash`
algo-lang path/to/file.algo
Pretty print your file in console:
`bash`
algo-lang --pretty-print path/to/file.algo
`algo
algorithme test
variables
entier i, j
algorithme procedure swap
parametres globaux
entier i, j
variables
entier tmp
debut
tmp ← i
i ← j
j ← tmp
fin algorithme procedure swap
debut
i ← 2
j ← 4
swap(i, j)
afficher(chaine(i) + chaine(j)) / prints 42 /
fin algorithme test
`
#### Note
selon expressions differ slightly from the previous documentation. There is a cas keyword added in the mix to allow LALR parsing :
`algo`
selon expression faire
cas val1, val2: expr1
expr2
autrement expr3
expr4
fin selon
#### Operator aliases
Some operators have aliases to ease development:
* <- is equivalent to ←^
* is equivalent to ↑
#### nul
There is a special nul keyword to assign the null pointer to any pointer variable and check if a pointer is null.
#### Available types
Only those base types are available:
* booleen (defined just like booleen = (faux, vrai))caractere
* (can be cast with system routines to: chaine, entier)chaine
* (can be cast with system routines to: entier, reel)entier
* (can be cast with system routines to: caractere, chaine, reel)reel
* (can be cast with system routines to: chaine, entier)
#### System routines
There are some system routines you can use:
* afficher(chaine): prints the string on stdout (no endline is added automatically)allouer(pointer)
* : allocate memory for the pointed valuecaractere(value)
* : try to cast value in caracterechaine(value)
* : try to cast value in chaineentier(value)
* : try to cast entier in chaineliberer(pointer)
* : free memory pointed by the provided pointer, do nothing if pointer is nul, resets pointer to nullongueur(chaine)
* : returns the length of the string
#### Operator []
The operator also allows you to access characters (caractere) in a string (chaine) like in:
``
afficher("toto"[1])
Important note: In this language, index are from 1 to n and not from 0 to n − 1`!