diff --git a/HOME_EXAM.md b/HOME_EXAM.md index aa52fcad9f40cc1ec3d26c8cf519e0eea524c4a1..d0fbb5b6dcb2d137a76618abc349324427390d76 100644 --- a/HOME_EXAM.md +++ b/HOME_EXAM.md @@ -230,11 +230,11 @@ Bool fn test1(x: i32, y: i32) -> i32 { if x < y { if x > 0 { - - x + (2 * y); + - x + (2 * y) }; x + y } else { - - x - (2 * y); + - x - (2 * y) } }; fn test2(x: bool) -> bool { @@ -253,19 +253,54 @@ Bool } ``` +#### Illeagal examples +Three examples that will be rejected by the compiler: +```rust + fn a(x: bool, y: bool) { + x || y + } +``` +No return type. + +```rust + fn a(x: bool) -> bool { + x + }; + fn main() -> () { + a(); + } +``` +No argument given in functioncall. + +```rust + fn a(x: i32, y: i32) -> bool { + if x > y { + true + } + else x < y { + false + } + } +``` +Expressions not allowed in else statment. + #### Coverage +The following bullet points are covered by the parser + - Two different function definitions (with arguments and return type or without arguments and return type) - Let and mutable let - Assignments - Functioncalls - If with or without else - While -- Expressions +- Expressions (parenthesized expressions, prefix, several operands, precedence) - Types: bool, i32 and unit All statements have explicit types. #### Future implementation +In the future could the following things be implemented to allow the parser to accept more programs + - Function definition with arguments but no return type or no arguments but return type - Else if - Other loops than while @@ -274,6 +309,7 @@ All statements have explicit types. - Functions not needed to be decleared in specific order - Global assignments - Shadowing +- Pretty printing Currently it is needed to seperate statements with ";" (except for the last one) for the parser to interpret it as a vector. This would be nice to rewrite in the future.