Error reference › Parser diagnostics
unexpected token
errorWhat it means
Mozhi is parsed with a recursive-descent/Pratt parser. Each construct states which tokens may follow; anything else is unexpected. The message always contains `found <token>` so you can see exactly what the parser saw.
Trigger condition
The parser encounters a token that cannot continue the current construct — with the found token named in the message.
Minimal failing example
let x = (1 + 2
let y = 3Verified fix
let x = (1 + 2)
let y = 3Unbalanced delimiters also get a dedicated code (PARSE002) that names where the construct was opened.
What the interpreter prints
error[PARSE001]: unexpected token
--> app.mz:1:16
1 | let x = (1 + 2
| ^
|
reason: (the exact problem, with positions)
help: (a suggested fix appears here)
docs: https://crossberry-in.github.io/mozhi-doc/errors/PARSE001mozhi --json run app.mz to get the same information as
machine-readable JSON (schema mozhi.diagnostics.v1), or --verbose to
also show grouped related diagnostics. See the CLI reference.Suggested fix
Read the `found` part of the message; it names the offending token and position. Check the construct that starts on that line for a missing delimiter, comma or operator.
Related syntax
Statements and declarations
Related diagnostics
Reference links
Limitations
Identical duplicates are collapsed, and consequences of one root cause are grouped (shown with `--verbose`).