From 5a90102b20d18966b69496d85361d14c085479db Mon Sep 17 00:00:00 2001 From: Flavian Kaufmann Date: Wed, 21 May 2025 07:45:30 +0200 Subject: syntax doc --- README.md | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'README.md') diff --git a/README.md b/README.md index dc39ac2..a86f2df 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,46 @@ A small interpreter of the IMP programming language. - [flex](https://github.com/westes/flex) - [bison](https://www.gnu.org/software/bison) -- [readline](https://tiswww.case.edu/php/chet/readline/rltop.html) \ No newline at end of file +- [readline](https://tiswww.case.edu/php/chet/readline/rltop.html) + +## IMP + +[Syntax](/res/syntax.ebnf) + +**Statement ** +Variable assignment: +- ` := ` any variable not assigned, has the value 0. + +Local variable: +- `var := in end` + +Control flow: +- `if then else end` +- `while do end` +- `(; )` sequential composition, the first statement runs before the second +- `skip`, nop + +**Expression** +Arithmetic Expression : +- `` +- `` +- `( + ) +- `( - ) +- `( + ) + +Boolean Expression : +- `not +- `( or ) +- `( and ) +- ` = ` +- ` # ` not equals +- ` < ` +- ` <= ` +- ` > ` +- ` >= ` + +**Variable ** +- `[a-zA-Z][A-Za-z0-9]*` + +**Numeral ** +- `[0-9]+` -- cgit v1.2.3