← All projects

Systems

Toy language

Parsed with Flex/Bison, evaluated in OCaml, syntax tree displayed.

Done Sprint S11-S12 · 8 points
In short, no jargon for non-developersRead the summaryClose
What it is
A small programming language invented for the purpose, “Maille”, which can describe 3D objects, and the tool that runs its programs in the page.
What it is for
To understand from the inside how the languages we program in work.
What it shows
Advanced computer science notions, taught at university, put into practice from end to end.

Taught in L2 (formal languages)

Source code

How the pieces fit together

Diagram: Maille program → Parser (read) ; Parser → Syntax tree (writes) ; Syntax tree → Interpreter ; Interpreter → Result (infers, evaluates) ; Browser → Result (both, in the visitor's browser). read writes infers, evaluates both, in the visitor's browser Maille program text Parser C, Flex, Bison Syntax tree S-expression Interpreter OCaml, Hindley-Milner Result value and type Browser WebAssembly, js_of_ocaml

Try Maille in your browser

The program is parsed by the C parser (Flex and Bison) compiled to WebAssembly, then typed and evaluated by the OCaml interpreter compiled to JavaScript: nothing leaves your browser.

Examples:

Ctrl+Enter (⌘+Enter on Mac) to run. Meshes: torus, sphere, cylinder (resolution 3 to 256), union; invariants: vertices, edges, faces, euler, boundary_loops, components, genus.

Syntax tree

Built by the C parser. Each node shows its line and column; click it to put the cursor there in the program.

Tech stack

  • Flex
  • Bison
  • OCaml
  • C

Who does what

Flex
Maille's lexer: words, numbers, strings, positions in UTF-8 characters, named lexical errors.
Bison
The grammar, with no conflict at all, which builds the located syntax tree.
OCaml
The interpreter: Hindley-Milner type inference and evaluation; compiled to JavaScript by js_of_ocaml for the project page.
C
The reentrant parser around Flex and Bison, compiled to WebAssembly by Emscripten for the project page.

Definition of Done

  • Code reviewed, diff by diff
  • Unit and integration tests green
  • Green CI on Linux, Windows and macOS when compiled
  • README, REVIEW.md and DECISIONS.md up to date
  • Texts in French and English
  • Demo deployed and tested on mobile