antimony-lang / antimony

The Antimony programming language
https://antimony-lang.github.io/antimony/
Apache License 2.0
138 stars 6 forks source link

`parse_expression` function peeks invalid tokens #98

Open garritfra opened 6 months ago

garritfra commented 6 months ago

I get an Error: Expected token when running this function:

fn main() {
    println(greet("World"))
}

fn greet(name: string) = "Hello " + name

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())
}

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.

Originally posted by @garritfra in https://github.com/antimony-lang/antimony/issues/95#issuecomment-2039664468