Skip to content
Snippets Groups Projects
Commit 15838008 authored by David Söderberg's avatar David Söderberg
Browse files

Update HOME_EXAM.md

parent afb7df2e
No related branches found
No related tags found
No related merge requests found
......@@ -360,7 +360,7 @@ let a = 1;
### Assign expression
```math
\frac{<e, σ> → v, σ'}{<\text{id} = e, σ> → σ'[\text{id} = e]}
\frac{<e, σ> → v, σ'}{<\text{id} = e, σ> → σ'[\text{id} = v]}
```
``` rust
a = 0;
......@@ -371,7 +371,7 @@ a = 0;
\frac{<b, σ> → true <c_1, σ> → σ'}{<\text{if } b \text{ then }c_1 \text{ else } c_2,σ> → σ'}
```
```math
\frac{<b, σ> → false <c_2, σ> → σ'}{<\text{if } b \text{ then }c_1 \text{ else } c_2,σ> → σ''}
\frac{<b, σ> → false <c_2, σ> → σ''}{<\text{if } b \text{ then }c_1 \text{ else } c_2,σ> → σ''}
```
``` rust
......@@ -426,9 +426,77 @@ while a < 10 {
## 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).
> - Demonstrate each "type rule" by an example. You may use one or several "programs" to showcase where rules successfully apply.
##### Symbols:
- σ, type state
- σ', changed type state
- →, evaluates
- c, command
- v, variable
- e, expression
- t, type
##### Expression can be either a
- b, boolean
- n, number
- f, function
#### Types
- i32
- bool
- ()
- &t
- *t
- ()
-Unknown
### Integer type operands
```math
\frac{<e_1,σ> → \text{i32} <e_2, σ> → \text{i32}}{<e_1 - e2, σ> → \text{i32}}
```
Above is a minus operation of two integers, these will evaluate to i32. Following operands can also be used:
- +, Addition
- *, Multiplication
- /, Division
### Boolean type operands
```math
\frac{<e_1,σ> → \text{bool} <e_2, σ> → \text{bool}}{<e_1 != e2, σ> → \text{bool}}
```
Above is a not equals operation of two expessions resulting in a bool, following boolean expressions can be described in the same way:
- "==", Equal
- "&&", And
- "||", Or
These operands can also be used with the type i32 as follows:
- ">", Greater than
- ">=", Greater than or equals
- "<", Less than
- "<=", Less than or equals
- "==", Equal
- "!=", Not equal
```math
\frac{<e_1,σ> → \text{i32} <e_2, σ> → \text{i32}}{<e_1 <= e2, σ> → \text{bool}}
```
### Reference and Dereference
```math
\frac{<e,σ> → \&t}{<*e,σ> → t}
```
```math
\frac{<e,σ> → \&text{mut } t}{<*e,σ> → \text{mut} t}
```
```math
\frac{<*e,σ> → t}{<e,σ> → \&t}
```
> - 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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment