testscript: formal grammar for txtar syntax highlight
I miss syntax highlighting for testscript files. While I would enjoy crafting the highlight files myself, the pressure of converting time to money forces me to leave this task to automatic converters, which accept some kind of formal grammar or meta definition of the language (list of keywords in machine readable format etc.) for input.
The syntax is extremely simple. One way of describing it formally is with a regular expression. This, for example:
^(.*\n)*?.*?(\n-- .+ --(\n.*)*?)*\n?$
Alternatively, one could just say that a file boundary is described by the regular expression:
^-- (.+) --$
The more interesting part of syntax highlighting with respect to txtar is that ideally the individual file parts get their own file-specific syntax highlighting according to the file extension of that part. I suspect that might be a challenge to implement depending on the capabilities of the editor's highlighting system.
See also https://github.com/rogpeppe/go-internal/issues/97
#97 indeed contains separate implementations written by hand. The formal grammar helps autogenerate highlighters that identify errors and highlight proper keywords. At least the keyword definitions and their grammar would be nice.