I’m writing my own Lezer grammar for a custom langauge. I have an EditorView using my custom parser.
Is there anyway for the CodeMirror 6 EditorView to display parsing errors (if fail) or parse tree (if success)?
Right now, I do not know how to display the Lezer parser data, except through highlighting.
syntaxTree(editorState).toString() tends to give a somewhat readable representation of the tree. If you want to display it directly in the editor content, that would require writing a custom plugin.
It worked. Thanks!
Can you also explain what a CodeMirror Reference Manual is and how to get a no-null one?
Originally, I thought the way to get a editorState was:
ParseContext.get().state but that was always null. I ended up using
editor: EditorView and that worked.
Just out of curiosity now, I am curious what a
ParseContext is and how we get a non-null one (as I suspect I’ll have to use one in the future.)
ParseContext.get only works when a parse is running. I.e. it is something you’d use if your parser needs access to the editor state somehow (about which you have to be very careful to keep incremental parsing correct). So I think this sounds like you’re trying to use it in a way that is not what it is intended for.
We created this template on Replit CodeMirror Lezer Language Template - Replit it has a dev helper that logs the syntax tree