|
Re: accepting php html in xtext grammar [message #777611 is a reply to message #777569] |
Tue, 10 January 2012 20:04 |
Meinte Boersma Messages: 434 Registered: July 2009 Location: Leiden, Netherlands |
Senior Member |
|
|
The thing you have to understand first and foremost for this is that the input (i.e., the DSL file) is first lexed before it is parsed. Lexing is a pretty straightforward process and lexing cannot be influenced by the parsing, so the lexing happens completely oblivious of any context: in this case, whether you are inside a PHP block or in HTML context. It is usually tricky to get good (maintainable/expandable) grammars for these kinds of "mixed context" languages, typically depending on the number and nature of keywords in the contexts. Often, it is easiest to write a custom lexer that is -to some extent- context-aware. I've done that for SGML/XML: see my GitHub repo - all the projects with sgml, dtd or simplemarkup in their names.
In your case, it's important to know that the terminal BETWEEN_HTML is not called but rather matched from the HTML rule. (Also, the "X returns X:" is superfluous in this situation: "X:" will do fine.)
Xtext blogs: executable models...again? | workshop material | custom scoping with Xtend
|
|
|
Powered by
FUDForum. Page generated in 0.03105 seconds