Maille program (text) → Parser (C, Flex, Bison): read
Parser (C, Flex, Bison) → Syntax tree (S-expression): writes
Syntax tree (S-expression) → Interpreter (OCaml, Hindley-Milner)
Interpreter (OCaml, Hindley-Milner) → Result (value and type): infers, evaluates
Browser (WebAssembly, js_of_ocaml) → Result (value and type): both, in the visitor's browser
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