- Give an example that showcases all rules of your EBNF. The program should "do" something as used in the next exercise.
> - 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.
Showcase of EBNF:
### Accpeted code
```rust
fnexample(x:i32,y:bool)->i32{
letmutz:i32=1+x;
ify{
z=z+-2
}
z
fnfunc(x:i32,y:i32)->i32{
x+y
}
fntest()->bool{
letmuta=3;
letb=&muta;
*b=1;
*b=0;
whilea<=3{
*b=example(*b,false);
whilea<10{
*b=func(*b,1);
}
letc=a/3;
...
...
@@ -207,26 +203,57 @@ Showcase of EBNF:
}
```
- 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.
Run the input program
### Bad code
- Give a set of examples that are syntactically illegal, and rejected by your compiler.
Different kinds of misstypes
``` rust
ffunc(x:i32,y:i32)->i32{
x-y
}
```
``` rust
illegalstuff;
ltea=1;
```
- Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
Mixed positions
``` rust
letxmut=false;
```
##### Future implementation
Not yet implemented
``` rust
fnfunc(){
fnfunc2(){
fnfunc3(){
//...
}
}
}
```
> - Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
##### Our syntax support the most basic subset of rust, including
- Primitive types such as i32 and boolean
- Functions with the primitive return types
- let, if, if else, while, assign, return
- Precedence of operands by dividing them into arithmetic, conditional and logical operands.
- Possbility for ArCode (addition and subtraction) to have precedence over FactorCode(multiplication and division) by parenthesized precedence
##### Future implementation
- Better error handling with location information
- More types
- Nestled functions
- Global variables
- Pretty printing
## Your semantics
```
- Give a (simplified) Structural Operational Semantics (SOS) for your language. You don't need to detail rules that are similar (follow the same pattern). Regarding variable environment (store) you may omit details as long as the presentation is easy to follow.
- Explain (in text) what an interpretation of your example should produce, do that by dry running your given example step by step. Relate back to the SOS rules. You may skip repetitions to avoid cluttering.
```
> - Give a (simplified) Structural Operational Semantics (SOS) for your language. You don't need to detail rules that are similar (follow the same pattern). Regarding variable environment (store) you may omit details as long as the presentation is easy to follow.
> - Explain (in text) what an interpretation of your example should produce, do that by dry running your given example step by step. Relate back to the SOS rules. You may skip repetitions
##### Symbols:
- σ, state
...
...
@@ -371,20 +398,40 @@ while a < 10 {
a=a+1;
}
```
```
- For your implementation, give a program (or set of test programs) that cover all the semantics of your language that you have successfully implemented. (Maybe a subset of the input language accepted by the grammar.)
- Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
> - For your implementation, give a program (or set of test programs) that cover all the semantics of your language that you have successfully implemented. (Maybe a subset of the input language accepted by the grammar.)
```rust
fnfunc(x:i32,y:i32)->i32{
x+y
}
fntest()->bool{
letmuta=3;
letb=&muta;
*b=0;
whilea<10{
*b=func(*b,1);
}
letc=a/3;
}
fnmain(){
test();
}
```
## Your type checker
- Give a simplified set of Type Checking Rules for your language (those rules look very much like the SOS rules, but over types not values). Also here you don't need to detail rules that are similar (follow the same pattern).
> - Give a simplified set of Type Checking Rules for your language (those rules look very much like the SOS rules, but over types not values). Also here you don't need to detail rules that are similar (follow the same pattern).
- Demonstrate each "type rule" by an example. You may use one or several "programs" to showcase where rules successfully apply.
> - Demonstrate each "type rule" by an example. You may use one or several "programs" to showcase where rules successfully apply.
- For your implementation, give a set of programs demonstrating that ill-typed programs are rejected, connect back to the Type Checking Rules to argue why these are illegal and thus should be rejected.
> - For your implementation, give a set of programs demonstrating that ill-typed programs are rejected, connect back to the Type Checking Rules to argue why these are illegal and thus should be rejected.
- Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.
> - Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation.