diff --git a/HOME_EXAM.md b/HOME_EXAM.md index 399d18e3de45d8be40c2b722b99972d33b6524d0..b84a15b2985a9777eccffc35eb8e1e241f67c966 100644 --- a/HOME_EXAM.md +++ b/HOME_EXAM.md @@ -1,6 +1,10 @@ -# 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