This is an attempt to craft a tree-sitter grammar for Invisible XML. The primary motivation is to get correct syntax highlighting in editors that support tree-sitter.
I know very little about tree-sitter so take everything you find in here with a grain of salt.
The constraints of a tree-sitter grammar differ from the constraints of iXML. Some things that are easy in iXML are difficult or impossible in tree-sitter grammars.
Consequently, this grammar isn’t “the same” as iXML, though it’s expected to be close enough for useful syntax directed highlighting.
This grammar differs from iXML in a number of ways.
-
A tree-sitter grammar can’t have a nonterminal that matches nothing. To address this limitation, an
alt
has been defined so that it must contain at least oneterm
. In the places wherealt
appears, it has been made optional. -
The definition of a
set
in iXML includes bothstring
andrange
andrange
begins withcharacter
. Astring
containing a single character and acharacter
are indistinguishable. This leads to confusion about what["L"]
means (it’s either a string or a broken range). To work around this problem, the tree-sitter grammar definesset
a little differently. -
To support syntax highlighting, one of the goals of this grammar is to expose parts of the syntax that aren’t actually relevant to the grammar (the hyphens in ranges, the parenthesis around alts, etc.).
The ixml-ts-mode
supports tree-sitter based syntax highlighting in Emacs 29.1 assuming you have
all the basics covered.