Skip to content
Snippets Groups Projects
Commit 0bac8ed6 authored by Aron Strandberg's avatar Aron Strandberg
Browse files

parser complete

parent c2bd9f08
No related branches found
No related tags found
No related merge requests found
Pipeline #172 failed
...@@ -139,6 +139,44 @@ White_space ...@@ -139,6 +139,44 @@ White_space
: ? White_space characters ? : ? 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 ## Your semantics
- Give an as complete as possible Structural Operetional Semantics (SOS) for your language - Give an as complete as possible Structural Operetional Semantics (SOS) for your language
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment