diff options
author | Flavian Kaufmann <flavian@flaviankaufmann.ch> | 2025-05-21 07:50:31 +0200 |
---|---|---|
committer | Flavian Kaufmann <flavian@flaviankaufmann.ch> | 2025-05-21 07:50:31 +0200 |
commit | eab00131b086b379c9e983fa8165405f48738b6d (patch) | |
tree | 76dad6350b50de2d017f67c8980a1b987252bf24 | |
parent | 396685999cca865b9ea110d8cb461373a962ebe9 (diff) | |
download | imp-eab00131b086b379c9e983fa8165405f48738b6d.tar.gz imp-eab00131b086b379c9e983fa8165405f48738b6d.zip |
doc fix
-rw-r--r-- | README.md | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -2,6 +2,7 @@ A small interpreter of the IMP programming language. + ## Build - `make all` to build interpreter. @@ -9,31 +10,41 @@ A small interpreter of the IMP programming language. - `make example` to interpret "example/example.imp". - `make clean` to remove build folder. + ## Dependencies - [flex](https://github.com/westes/flex) - [bison](https://www.gnu.org/software/bison) - [readline](https://tiswww.case.edu/php/chet/readline/rltop.html) + ## IMP [Syntax](/res/syntax.ebnf) + **Statement `<stm>`** + Variable assignment: + - `<var> := <aexp>` any variable not assigned, has the value 0. Local variable: + - `var <var> := <aexp> in <stm> end` Control flow: + - `if <bexp> then <stm> else <stm> end` - `while <bexp> do <stm> end` - `(<stm>; <stm>)` sequential composition, the first statement runs before the second - `skip`, nop + **Expression** + Arithmetic Expression `<aexp>`: + - `<num>` - `<var>` - `(<aexp> + <aexp>)` @@ -41,6 +52,7 @@ Arithmetic Expression `<aexp>`: - `(<aexp> + <aexp>)` Boolean Expression `<bexp>`: + - `not <bexp>` - `(<bexp> or <bexp>)` - `(<bexp> and <bexp>)` @@ -51,8 +63,12 @@ Boolean Expression `<bexp>`: - `<aexp> > <aexp>` - `<aexp> >= <aexp>` + **Variable `<var>`** + - `[a-zA-Z][A-Za-z0-9]*` + **Numeral `<num>`** + - `[0-9]+` |