A while ago I’ve started to rewrite NHaml from its ground up to use an AST based parsing approach instead of directly creating the output while parsing. I did this because of the following reasons:
- Separate parser from output generation
- Allow to reuse the parser for syntax highlighting plugins like this one for Visual Studio or a possible ones for Sharpdevelop or Monodevelop
- Error reporting with line and index of error source
- Fully parse the document and report all errors at the end
- Better maintainability since the separate steps are less complicated
Since this all dose not fit within the current codebase, so I’ve started an empty one at GitHub. Since i work the most time at trains offline, git is much more useable for me than SVN and i really like the GitHub forking model. So if the other members are agree, it is possible that we move the source code of NHaml to GitHub later.
Currently the entire codebase pass the haml-spec test suite from Norman Clarke. Big thank to Norman, without that spec it would have cost me much more time to bring the codebase to the current state. But this means not that it is useable. The current DebugVisitor which generates the HTML output from AST is only a intermediate step. It only output HTML and no compiler or any dynamic code is involved.
The next step, is to track the line number and character index for each node. This is ware i work on currently. And here it is:
This is a little test editor written with the Windows.Forms.RichTextBox. Initially I’ve used the WPF RichtTextBox, but since it is very very slow for this scenario and the optimization would cost much time I’ve switched over to Windows.Forms. Note: My goal is it no to create an editor for NHaml, i only use it for testing. As you can see not all nodes are highlighted yet.
The next step would be to report errors like when you only type “%” without a name behind (possibly this information could be used in a future syntax highlighting plugin too). After that I’ve want to extend the test suite for some missing parts like the alligator notation.
When all this is done, i plan to reintegrate the compiler and mvc stuff and publish it all together as NHaml 3.0. But don’t expect it to be soon.