Two-layered lexer for templating language
Hi,
are there existing classes which would help me to create lexer in two phases:
1/ top lexer to locate my language within the outer one
2/ my lang lexer to parse the parts of my language
I'm trying to write support for Latte templating language (part of Nette framework in PHP), which supports injecting the language into several parts of HTML code, for example:
- into curly brackets, e.g. {if $something}
- into html attributes
- with quotes, e.g. <a n:if="$something">
- with apostrophes, e.g. <a n:if='$something'>
I thought about writing a LatteTopLexer, which would lex out the whole macros out of HTML, and then LatteLexer to lex just contents of the macros from top lexer. How would this be possible?
Thanks
Please sign in to leave a comment.
We have a framework for this in IntelliJ IDEA, but unfortunately we don't have an open-source example for its usage. See the following post for some information: http://devnet.jetbrains.net/message/5302122#5302122
What a pitty. There is lack of good examples.
I created a LookAhedLexer with this sub-lexer capability: https://gist.github.com/1678538, it may be useful to someone else in the future.