Parsers…

I’m burnt a bit. Need a break. I think I have a basic idea of how I want to proceed. Basically just a css parser (ast tree output) and the html parser with the visitor pattern. Visit each node and traverse the AST tree for all matching css rules…for each match append an annotation to the html node. Then have another pass that will actually generate the output. At least as a start.

I’ve been looking at ANTLR quite a bit and I’m pretty impressed. It looks like ANTLR 3 will use the StringTemplate ‘engine’ for generating the actual code. The idea is that you could feasibly have 1 grammar and multiple output templates to render the grammar in different languages. Exactly what I was looking at maybe having to write…thank god because it looks like they know a hell of a lot more about lexers/parsers/compilers than I do…and I like where they are taking it (MVC separation). So I may evenually have 1 css grammar that would generate a parser for java, jsp, perl, javascript, php, ruby, python…etc. Awesome.

I also found it interesting how closely css syntax resembles the syntax used in the grammars and the string template files…

Leave a Reply