antimony-lang/antimony

`parse_expression` function peeks invalid tokens

garritfra opened this issue · 0 comments

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 #95 (comment)