Have you ever wanted to execute pseudocode? This project, built in Rust, allows you to execute pseudocode (English) and French pseudo-code. However, it requires strict syntax and you should respect some rules explained in the Documentation.
Clone the repo
git clone https://github.com/Nash115/pseudocode_interpreter.git
cd pseudocode_interpreterBuild the project
cargo build --releaseThe binary is located in ./target/release/pseudocode_interpreter
or (./target/release/pseudocode_interpreter.exe on Windows)
Execute a file containing the code :
./target/release/pseudocode_interpreter my_code.pseudocodeExecute instruction by instruction (REPL) :
(type exit to quit)
./target/release/pseudocode_interpreter Pseudocode (English) :
function add(a,b)
return a + b
endFunction
let result = add(1,2)
print(result)
The same code in pseudo-code (French) :
fonction ajouter(a,b)
retourner a + b
finFonction
variable resultat = ajouter(1,2)
affiche(resultat)
- Comments
- Strings
- Lists
- Conditions
- Loops
- Better errors (including lines...)
- Better environment (Avoid Scope Accumulation : Memory Leak)
var,let,variable: Declares (explicitly) a variable. A variable does not require an explicit declaration : it is automatically declared on the first assignment if not declared previously.
let a = 2
b = 3
const,constante: Declares a constant : a variable that cannot be edited
const pi = 3.14
fn,function,fonction,procedure(andendFn,finFn,endFunction,finFonction,endProcedure,finProcedure): Used to define a function
fn add(a,b)
a + b
endFn
return,retourner,renvoyer: Return a value from a function
fn add(a,b)
return a + b
endFn
PI: CONST with an f64 value of πprint(...),affiche(...): FUNCTION that prints every parameter, separated by spaces.time(),temps(): FUNCTION that returns the time since the EPOCH.
- Number : a float encoded in 64 bits (
f64Rust type)
a = 42
b = 3.14
- Booleans :
true/false(vrai/faux)
b1 = true
b1 = vrai
b2 = false
b2 = faux
- Object (JSON-like)
user = {
age: 42,
subscribed: true,
social : {
followers: 100,
friends: 10
}
}
Operators :
not,non: Get the opposite of a booleanand,et: Evaluates totrue(vrai) if the left AND the right values are (or evaluates to)trueor,ou: Evaluates totrue(vrai) if the left OR the right value is (or evaluate to)true
Example :
not false and (false or true)
Evaluates to true