From 0bac8ed6415b363a8af67ac1dec8530bafad244a Mon Sep 17 00:00:00 2001 From: Aron <arostr-5@student.ltu.se> Date: Sun, 3 Nov 2019 12:09:12 +0100 Subject: [PATCH] parser complete --- HOME_EXAM.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/HOME_EXAM.md b/HOME_EXAM.md index b84a15b..cacd88b 100644 --- a/HOME_EXAM.md +++ b/HOME_EXAM.md @@ -139,6 +139,44 @@ White_space : ? White_space characters ? ; ``` + +Showcase +```rust +fn test_i32(b: 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); + while (a < 5) { + a = a + 1; + } + return a; + } +} + +fn main() { + test_bool(true); +} +``` +Above descirbed EBNF and showcase defines a minimal subset of Rust, including +- Function declaration, with excplicit return type either void (NONE) or primitive type +- Primitive types are i32 and boolean +- let, assignment, if, while and return statements with explicit types +- Operands are divided into logical, conditionl and arithmetic operands with precedence +- Parantesized precedence and FactorOp has precedence over SumOp +- Assignment operands are seperated from above mentioned operands +- Location information for Error is not implemented +- Error recovery is not implemented + +For furture development +- Rethink how assignment operands are handled in grammar +- Add if else statement +- Add support for String in Term +- Error handling, location information and recovery + ## Your semantics - Give an as complete as possible Structural Operetional Semantics (SOS) for your language -- GitLab