Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pseudocode Interpreter

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.

Use the project

Clone the repo

git clone https://github.com/Nash115/pseudocode_interpreter.git
cd pseudocode_interpreter

Build the project

cargo build --release

The 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.pseudocode

Execute instruction by instruction (REPL) : (type exit to quit)

./target/release/pseudocode_interpreter 

Code examples

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)

Work In Progress

  • Comments
  • Strings
  • Lists
  • Conditions
  • Loops
  • Better errors (including lines...)
  • Better environment (Avoid Scope Accumulation : Memory Leak)

Documentation

Keywords

  • 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 (and endFn,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

Built-in constants and functions

  • 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.

Variable types

  • Number : a float encoded in 64 bits (f64 Rust 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
  }
}

Logical operations

Operators :

  • not, non : Get the opposite of a boolean
  • and, et : Evaluates to true (vrai) if the left AND the right values are (or evaluates to) true
  • or, ou : Evaluates to true (vrai) if the left OR the right value is (or evaluate to) true

Example :

not false and (false or true)

Evaluates to true

Releases

Packages

Contributors

Languages