About

This project is a simple math interpeter. It supports expressions involving additon ("+"), subtraction ("-"), multiplication ("*"), division ("/"), brackets ("(" and ")"), and both floating point and integer arithmetic. The grammar for the interpreter, in EBNF, is:

unary = ("-", unary) | int | float | ("(", expression, ")");
factor = (factor, ("*" | "/"), unary) | unary;
expression = (expression, ("+" | "-"), factor) | factor;

Or graphically,

Visual description of EBNF above

Generated with Vincent Jacques' DrawGrammar

The interpeter is implemented in around 600 lines of C, and then compiled to WASM with Emscripten to run on the web. The source code can be found at https://github.com/liam-ilan/math-interpreter.