Skip to content
Snippets Groups Projects
Commit c2bd9f08 authored by Aron Strandberg's avatar Aron Strandberg
Browse files

added EBNF

parent 36a86377
No related branches found
No related tags found
No related merge requests found
Pipeline #171 canceled
# Home Exam D7050E
- Fork this repo and put your answers (or links to answers) in THIS file.
- [Your repo](#your-repo)
- [Your syntax](#your-syntax)
- [Your semantics](#your-semantics)
- [Your type checker](#your-type-checker)
- [Your borrrow checker](#your-borrrow-checker)
- [Your LLVM backend](#your-llvm-backend)
- [Overal course goals and learning outcomes.](#overal-course-goals-and-learning-outcomes)
## Your repo
......@@ -16,9 +20,125 @@
- Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
Program
```ebnf
: FunctionDec+
;
```
FunctionDec
```ebnf
: "fn" Id "(" [ "," ], Params ")" "->" Type "{" Statement "}"
| "fn" Id "(" [ "," ], Params ")" "{" Statement "}"
;
```
Params
```ebnf
: "Id" ":" Type
;
```
Statement
```ebnf
: "let" Id ":" Type AssignOp Expr ";"
| "if" Log "{" Statement "}"
| "while" Log "{" Statement "}"
| "return" Expr ";"
| Expr ";"
;
```
LogOp
```ebnf
: "&&"
| "||"
| "!"
;
```
CondOp
```ebnf
: ">"
| "<"
| "=="
| "!="
;
```
AssignOp
```ebnf
: "="
| "+="
| "-="
| "/="
| "*="
;
```
SumOp
```ebnf
: "+"
| "-"
;
```
FactorOp
```ebnf
: "*"
| "/"
;
```
Type
```ebnf
: "i32"
| "bool"
;
```
Term
```ebnf
: Num
| Id
| Bool
| Function
| "(" Expr ")"
;
```
Num
```ebnf
: [ "-" ], Digit
;
```
Id
```ebnf
: Letter , { Letter | Digit }, - White_space
```
Bool
```ebnf
: "true"
| "false"
;
```
Function
```ebnf
: Id "(" [ "," ], Expr ")"
;
```
Letter
```ebnf
: "A" | "B" | "C" | "D" | "E" | "F" | "G"
| "H" | "I" | "J" | "K" | "L" | "M" | "N"
| "O" | "P" | "Q" | "R" | "S" | "T" | "U"
| "V" | "W" | "X" | "Y" | "Z" | "a" | "b"
| "c" | "d" | "e" | "f" | "g" | "h" | "i"
| "j" | "k" | "l" | "m" | "n" | "o" | "p"
| "q" | "r" | "s" | "t" | "u" | "v" | "w"
| "x" | "y" | "z"
;
```
Digit
```ebnf
: "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
;
```
White_space
```ebnf
: ? White_space characters ?
;
```
## Your semantics
- Give an as complete as possible Structural Operetional Semantics (SOS) for your language
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment