ITADN

lang: Parser identifies incorrect location when I assume 'else if' is a thing

#929Openjordansissel 创建于 2026-05-24
J
jordansisselcommented
mgmt reports a syntax error at the wrong location, though I believe the error itself is correct. My error, trying to use 'else if' (I didn't realize it wasn't a thing in mcl) It reports "unexpected IF, expecting OPEN_CURLY" -- This seems correct However, it reports the error at line 3 pos 19, which is the first "if" and position is the `{` The actual error (imo) is in "else if $foo ..." where the "if" is unexpected. mcl: ``` $foo = "bar" if $foo == "test" { # hmm } else if $foo == "bar" { # wheee } ``` Running: ``` ../mgmt/mgmt run lang --only-unify test.mcl This is: mgmt, version: 1.0.2-172-g7d335d04 Copyright (C) James Shubin and the project contributors Written by James Shubin <james@shubin.ca> and the project contributors 12:15:18 main: start: 1779650118977310824 12:15:18 cli: lang: lexing/parsing... 12:15:18 main: goodbye! cli parse error: could not generate AST: parser: `syntax error: unexpected IF, expecting OPEN_CURLY` @3:19 ``` To highlight: ``` $foo = "bar" if $foo == "test" { ^- This is line 3 position 19 # hmm } else if $foo == "bar" { ^ This is line 5, position 8, the real error. # wheee } ```
1 条评论