From 65f979a780447ba669e1235ff2902b93da1faec1 Mon Sep 17 00:00:00 2001 From: Aron <arostr-5@student.ltu.se> Date: Sun, 3 Nov 2019 14:43:44 +0100 Subject: [PATCH] started with SOS, bit tricky with symbols.. --- HOME_EXAM.md | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/HOME_EXAM.md b/HOME_EXAM.md index cacd88b..c4fbae4 100644 --- a/HOME_EXAM.md +++ b/HOME_EXAM.md @@ -142,14 +142,14 @@ White_space Showcase ```rust -fn test_i32(b: i32) -> i32 { +fn test_i32(b: i32, c: i32) -> i32 { let a : i32 = 10 + 2 * 3; a = -1 - (1 - 1); return a + b; } fn test_bool(b: bool) -> bool { if b && true || false { - let a : i32 = test_i32(1); + let a : i32 = test_i32(1, 999); while (a < 5) { a = a + 1; } @@ -185,6 +185,35 @@ For furture development - Compare your solution to the requirements (as stated in the README.md). What are your contributions to the implementation. +Structural Operational Semantics (SOS) +Symbolx: +- σ, state +- σ', derived state +- ⇓, evaluates +- c, command +- x, variable +- e, expression +- b, boolean expression + +Command sequence + +$\frac{<c1,σ> ⇓ σ' <c2,σ'> ⇓ σ''}{<c1;c2,σ> ⇓ σ''}$ + +Arithmetic + +$\frac{<e1,σ> ⇓ n1 <e2, σ> ⇓ n2}{<e1 + e2, σ> ⇓ n1 plus n2}$ + +If true + +$\frac{<b, σ> ⇓ true <c1, σ> ⇓ σ'}{<if b then c1> ⇓ σ}$ + +If false + +$\frac{<b, σ> ⇓ false <c1, σ> ⇓ σ'}{<if b then c1> ⇓ σ}$ + + + + ## Your type checker - Give an as complete as possible set of Type Checking Rules for your language (those rules look very much like the SOS rules, but over types not values). -- GitLab