Repository navigation
feat: add highlighting mode that includes unparsed syntax - #138
Conversation
|
This looks really good! A couple questions before merge:
|
| if let some lastPos := (← get).lastPos? then | ||
| if lastPos < pos then | ||
| let text ← getFileMap | ||
| openUntil <| text.toPosition lastPos |
There was a problem hiding this comment.
I think parser errors may need a little more clever handling here. They may occur in a substring of the unparsed region, after all. I think this code should probably segment the unparsed region according to the messages that occur in it, and emit it accordingly. Does that make sense?
There was a problem hiding this comment.
Yes, I think 768d912 should address this? (As I note in the TODO, it's not entirely clear to me where messages without an end position should be terminated, since the existing highlighter does this automatically by virtue of token emission. I figured whitespace was a close enough heuristic for now.)
Yes, I'm pretty certain we still want the old
Got it; that makes sense to me. I've tried to at least lay the foundation for this in 2a2a8d5, but if this misses the mark, I can easily revert it and let you handle this part. (I had to make some educated guesses about the intended behavior of a few of the relevant functions on unparsed inputs, which may have been incorrect.)
I've added a test here, albeit with slightly ad-hoc infrastructure (the existing "example" commands, being elaborators, don't support unparseable inputs). |
|
Ad-hoc infrastructure is the name of the game when you want to support every Lean :-) |
This PR adds a
highlightIncludingUnparsedmethod to theHighlightingmodule, which will insert unparsed syntax regions into the outputHighlightedvalue. Unparsed regions are determined using the positions on the input syntax and are filled in using the file map. This is useful for demonstrating parsing errors alongside elaboration errors in a single code block.