Three examples that will be rejected by the compiler:
```rust
fna(x:bool,y:bool){
x||y
}
```
No return type.
```rust
fna(x:bool)->bool{
x
};
fnmain()->(){
a();
}
```
No argument given in functioncall.
```rust
fna(x:i32,y:i32)->bool{
ifx>y{
true
}
elsex<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.