test: log parse error with line context #4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "log-context"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fail with context when failing to parse spec:
Related to https://github.com/lezer-parser/lezer/issues/25
@ -133,0 +143,4 @@return file.substring(index, endIndex).split(/\n/).map(str => ' | ' + str).join('\n');}Why the
|markers? I think showing a slice like this, without even taking care to round up/down to line boundaries, produces rather crude output. Wouldn't just outputting the line number be more useful?@ -133,0 +143,4 @@return file.substring(index, endIndex).split(/\n/).map(str => ' | ' + str).join('\n');}Well, the output looks exactly as shown in the PR description which I personally find helpful.
Showing line numbers unfortunately won't work, as you (or really anyone) can fiddle around with the file contents before passing it to the function. We do it here, for instance to remove the grammar to be parsed.
As for the rounding, it is not necessary. The regular expression will always match line boundaries so the start index always refers to the start of a line.
@ -133,0 +143,4 @@return file.substring(index, endIndex).split(/\n/).map(str => ' | ' + str).join('\n');}Good point about the line numbers and the start of line. If you add some logic that scans forward to the next line end when there is one or the end of the string otherwise this looks good.
@ -133,0 +143,4 @@return file.substring(index, endIndex).split(/\n/).map(str => ' | ' + str).join('\n');}https://github.com/lezer-parser/lezer-generator/pull/4/commits/be4aa4e860eedb31dae6c580eedd7d2e7f0b0834 ensures we print full 80 chars + end of last line.
Thanks!
Can we cut a release with this change and the other ones recently introduced?
Working of
masterseems not a good mid-term solution.Sorry for the slow turnaround—was on holiday. I've released a 0.9.1 with the new patches.
👍