aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md44
1 files changed, 43 insertions, 1 deletions
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 <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>)
+- `(<aexp> - <aexp>)
+- `(<aexp> + <aexp>)
+
+Boolean Expression <bexp>:
+- `not <bexp>
+- `(<bexp> or <bexp>)
+- `(<bexp> and <bexp>)
+- `<aexp> = <aexp>`
+- `<aexp> # <aexp>` not equals
+- `<aexp> < <aexp>`
+- `<aexp> <= <aexp>`
+- `<aexp> > <aexp>`
+- `<aexp> >= <aexp>`
+
+**Variable <var>**
+- `[a-zA-Z][A-Za-z0-9]*`
+
+**Numeral <num>**
+- `[0-9]+`