Getting started with Wisent

Inasmuch as I’d wanted for a long time to have an excuse to write an Emacs mode that uses a Semantic Wisent parser, I recently started writing a new mode for RELAX NG compact syntax files. The mode-in-progress is available on GitHub at https://github.com/tkg/nrnc.git, and here’s my thoughts so far on using Wisent:

  • Start from the examples in the documentation – My first attempt at a top-level production was incorrect and failed to match anything, so nothing matched. I eventually resorted to reusing the entire wisent-graphviz-dot-mode parsing code with one added production for RELAX NG compact syntax namespace declarations and built it up from there until I’d sufficiently got the hang of the productions to remove the remaining wisent-graphviz-dot-mode training wheels and go it alone.
  • Make sure your syntax table is correct – The mode was initially based on rnc-mode by David Rosenberg of Pantor Engineering AB and used the syntax table defined in it. At one point when things weren’t working, I remembered that the wisent-graphviz-dot-mode code that I’d been using as an example included a comment about needing to modify the syntax table of graphviz-dot-mode. Sure enough, rnc-mode was missing a syntax-table entry that was needed for Semantic parsing of .rnc files. And just today I had to set the “?” character as a symbol character to get one more part working properly.
  • Use the debug functions – Forgive me for restating the very, very obvious, but you will find these useful. For example, `semantic-show-unmatched-syntax-mode‘ is useful, though initially disheartening, for showing which parts of the file are not being matched by displaying a red line under the unmatched parts. Occasionally, you may also note the absence of the red line under parts that you don’t expect to be matched yet.

2 thoughts on “Getting started with Wisent

  1. What’s not to like? It’s fun programming, and I’m more productive as a result.

Comments are closed.