glow
glow copied to clipboard
Error Messages on Parser Failures
In GitLab by @AlexKnauth on Jun 9, 2021, 23:30
Currently when a program fails to parse, there's no error message, instead it produces a "shorter" output than it should. For example the program
#lang glow
A;
B;
C;
Would parse as (@module A B C)
if there are no errors, but parse as (@module A)
if there's an parse error in B
.
This needs to be changed to add error messages showing exactly what's wrong with B
.
In GitLab by @AlexKnauth on Jun 29, 2021, 03:05
marked this issue as related to #207
In GitLab by @kwanzknoel on Jul 27, 2021, 18:09
assigned to @kwanzknoel
In GitLab by @kwanzknoel on Jul 27, 2021, 19:02
To be more specific, there are two issues.
- [ ] Toplevel parser must end with EOF after valid statements and optional expression. !163
- [ ] Better error message / object instead of just returning
#f
in failing states.
First is incorrect parser logic. This is demonstrated by the above example. Concrete test:
(test-case "parseStr invalid subsequent statement"
(assert-equal!
(parseStr "let a = 1;
let b 2;")
'(@module (def a 1)))))) ;; FIXME: should be #f
It gives false positive for certain incorrect expressions rather than failing.
Second issue is with error reporting. This is demonstrated by:
(import :drewc/smug
:mukn/glow/compiler/parse/lexical
:mukn/glow/compiler/parse/expressions
)
(def parse-result (run Param (lexify "ajskd")))
(def parse-result-2 (run Param (lexify "(aaaaa")))
(displayln parse-result)
(displayln parse-result-2)
Which gives us:
$ gxi toy.ss
#<param #10 id: #<identifier #11 name: "ajskd"> typ: #f> // valid parse result
#f // invalid parse result needs to be more descriptive
Where we get #f rather than a more descriptive error message / object.
You can also look at tests in glow/compiler/parse/t/expressions-test.ss
, with expected value #f
.
In GitLab by @kwanzknoel on Jul 28, 2021, 18:56
mentioned in merge request !163