Louis Pearson Home Contact

Dialog Tree-sitter Parser

I like syntax highlighting OK?

Dialog is a domain-specific language for creating works of interactive fiction. It is heavily inspired by Inform 7 (Graham Nelson et al. 2006) and Prolog (Alain Colmerauer et al. 1972).

—Linus Åkesson, linusakesson.net

Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited.

—The tree-sitter documentation

I find the Dialog language fascinating! It's a logic programming language designed for writing interactive fiction in a declarative way. At some point, I want to make a game with it. Unlike Linus Åkesson, I like to have syntax highlighting when I am coding. My preferred text editor, Helix, uses tree-sitter parsers to enable syntax highlighting.
The result is I spent a weekend writing a Dialog parser using tree-sitter, and I now have syntax highlighting for Dialog in Helix! If you are interested in using the parser, the repository can be found here on codeberg.org