Browse Source

Implement returning variables

github-actions
Garrit Franke 2 years ago
parent
commit
010b6207ec
  1. 3
      examples/hello_world.fx
  2. 4
      src/parser/mod.rs

3
examples/hello_world.fx

@ -2,8 +2,7 @@
fn main() {
let x = 2;
let y;
return 1;
return x;
}
fn fib() {}

4
src/parser/mod.rs

@ -169,6 +169,10 @@ impl Parser {
let state = Expression::Int(token.raw.parse::<u32>().map_err(|e| e.to_string())?);
Ok(state)
}
TokenKind::Identifier(val) => {
let state = Expression::Variable(val);
Ok(state)
}
other => Err(format!("Expected Expression, found {:?}", other)),
}
}

Loading…
Cancel
Save