From 4d89b50242b507742f536d9fd06cc72767bf37ca Mon Sep 17 00:00:00 2001
From: David Eriksson <cryslacks@live.se>
Date: Thu, 22 Oct 2020 09:44:13 +0000
Subject: [PATCH] Update HOME_EXAM.md

---
 HOME_EXAM.md | 249 +++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 231 insertions(+), 18 deletions(-)

diff --git a/HOME_EXAM.md b/HOME_EXAM.md
index 7634c1e..44fb264 100644
--- a/HOME_EXAM.md
+++ b/HOME_EXAM.md
@@ -4,19 +4,240 @@
 
 ## Your repo
 
-- Link to your repo here:
+- Link to your repo here: **_Insert github link here_**
 
 ## Your syntax
 
-- Give an as complete as possible EBNF grammar for your language.
-
-- Give an example that showcases all rules of your EBNF. The program should "do" something as used in the next exercise.
-
-- For your implementation, show that your compiler successfully accepts the input program.
-
-- Give a set of examples that are syntactically illegal, and rejected by your compiler.
-
-- Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
+> - Give an as complete as possible EBNF grammar for your language.
+
+Program
+```ebnf
+    : Func Program
+    | Func
+    ;
+```
+Func
+```ebnf
+    : "fn" Id Params "->" Type Block
+    | "fn" Id Params Block
+    ;
+```
+Params
+```ebnf
+    : "()"
+    | "(" [ "," ], Param ")"
+    ;
+```
+Param
+```ebnf
+    : "mut" Id ":" Type
+    | Id ":" Type
+    ;
+```
+Block
+```ebnf
+    : "{" StmtSeq* Stmt "}"
+    | "{" StmtSeq* "}"
+    ;
+```
+StmtSeq
+```ebnf
+    : ";"
+    | Stmt ";"
+    | StmtBlock
+    ;
+```
+Stmt
+```ebnf
+    : "let" Id ":" Type "=" Expr
+    | "let" Id ":" Type
+    | "let" Id "=" Expr
+    | "let" Id
+    | "let" "mut" Id ":" Type "=" Expr
+    | "let" "mut" Id ":" Type
+    | "let" "mut" Id "=" Expr
+    | "let" "mut" Id
+    | Expr "=" Expr
+    | Expr1
+    ;
+```
+StmtBlock
+```ebnf
+    : "while" Expr Block
+    | "if" Expr Block "else" Block
+    | "if" Expr Block
+    | Block
+    ;
+```
+Expr
+```ebnf
+    : ExprBlock
+    | Expr1
+    ;
+```
+ExprBlock
+```ebnf
+    : "if" Expr Block "else" Block
+    | Block
+    ;
+```
+Expr1
+```ebnf
+    : Expr1 LoCode Expr2
+    | Expr1 ArCode Expr2
+    | Expr2
+    ;
+```
+Expr2
+```ebnf
+    : Expr2 FactorCode Lit
+    | Lit
+    ;
+```
+Lit
+```ebnf
+    : Id Exprs
+    | ArCode Lit
+    | "!" Lit
+    | Bool
+    | Num
+    | Id
+    | "&" Lit
+    | "&mut" Lit
+    | "*" Lit
+    | "(" Expr ")"
+    ;
+```
+Exprs
+```ebnf
+    : "()"
+    | "(" [ "," ], Expr1 ")"
+```
+LoCode
+```ebnf
+    : "&&"
+    | "||"
+    | "=="
+    | "!="
+    | ">"
+    | "<"
+    | ">="
+    | "<="
+    ;
+```
+ArCode
+```ebnf
+    : "+"
+    | "-"
+    ;
+```
+FactorCode
+```ebnf
+    : "*"
+    | "/"
+    ;
+```
+Type
+```ebnf
+    : "i32"
+    | "bool"
+    | "()"
+    | "&" Type
+    | "&mut" Type
+    ;
+```
+Num
+```ebnf
+    : "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" 
+    ;
+```
+
+Id
+```ebnf
+    : (LetterLow | LetterHigh | "_")+ (LetterLow | LetterHigh | Num | "_")*
+    ;
+```
+Bool
+```ebnf
+    : "true"
+    | "false"
+    ;
+```
+LetterHigh
+```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"
+    ;
+```
+LetterLow
+```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" 
+    ;
+```
+
+Accepted code
+```Rust
+fn main() {
+    let mut a = 3;
+    let b = &mut a;
+    *b = 1;
+
+    while a <= 3 {
+        *b = add(*b, 1);
+    }
+
+    let c = a / 3;
+}
+
+fn add(a:i32, b:i32) -> i32 {
+    a+b
+}
+```
+
+> - Give an example that showcases all rules of your EBNF. The program should "do" something as used in the next exercise.
+> - For your implementation, show that your compiler successfully accepts the input program.
+
+**Accepted code**
+```Rust
+fn main() {
+    let mut a = 3;
+    let b = &mut a;
+    *b = 1;
+
+    while a <= 3 {
+        *b = add(*b, 1);
+    }
+
+    let c = a / 3;
+}
+
+fn add(a:i32, b:i32) -> i32 {
+    a+b
+}
+```
+
+> - Give a set of examples that are syntactically illegal, and rejected by your compiler.
+
+**Rejected Code**
+```Rust
+
+```
+
+
+> - Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
+
+I have fullfilled all of the of the requirements for a minimal subset of Rust such as:
+* Functions
+* Statements
+* Expressions
+* Primitive types and literals
+* Returns
+* References and Dereferences
 
 ## Your semantics
 
@@ -46,14 +267,6 @@
 
 - Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
 
-## Your LLVM/Crane-Lift backend (optional)
-
-- Let your backend produce LLVM-IR/Crane Lift IR for an example program (covering the translations implemented).
-
-- Describe the translation process, and connect back to the generated IR.
-
-- Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
-
 ## Overall course goals and learning outcomes.
 
 Comment on the alignment of the concrete course goals (taken from the course description) to the theory presented, work You have done and knowledge You have gained. (I have put some comments in [...]).
-- 
GitLab