Closed hexaredecimal closed 6 months ago
I get an Error: Expected token
when running this function:
fn main() {
println(greet("World"))
}
fn greet(name: string) = "Hello " + name
Could you add some tests to the tests/
directory, and to the parser?
I created a parser test that I used to debug the error:
#[test]
fn test_parse_inline_function() {
let raw = "
fn main() = 1
";
let tokens = tokenize(raw).unwrap();
let tree = parse(tokens, Some(raw.to_string()), "".into());
assert!(tree.is_ok())
}
I didn't have enough time to investigate this further though. Trying again later.
Okay, it seems like the error is an issue with how the parse_expression
function peeks tokens. I added a test stub to investigate this later.
I think this is ready to merge. Thanks @hexaredecimal for your work, I love this feature!
I have followed your advice and implemented inline functions from the parser. I also added a function/method for creating hints. I had some time on my hands so I also decide to start working on the run command for qbe. I'm thinking of refactoring the code to a function to reduce the code size of the match expression.