Closed jdelgadofrts closed 1 month ago
Oh :laughing: It's because the input isn't a valid decl
. Notice decl
requires a let
followed by either another decl
or expr
. The following parses just fine:
let five = 5; five
Yep, as @Zij-IT. let
isn't like an ordinary variable declaration in an imperative language, it's more akin to the waylet
works in a functional language like ML: let x = y; z
is itself a compound expression, but let x = y;
is not an expression on its own.
That said, the error given is a little confusing. I think 1.0 would do better here though.
Going to close this since the tutorial isn't actually broken.
When using the tutorial code, at the Parsing Let, it seems like the parser gets stuck after the
let
input of the file.It still processes raw arithmetic expressions fine such as
5+5
but anything starting withlet
will kill the parser with the following error:Parse error: found "f" but expected one of "-", "*", "/", end of input, "+"
The sample file i'm using:
It basically tries to compile
f
from five into an expression such as above.This is what the tutorial
main.rs
looks at this step:I'm not entirely sure how to fix it. But if you provide a fix, i'll be happy to update both the tutorial as well as the example code.