diff options
Diffstat (limited to 'README.md')
-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]+` |