Comments in the AST [message #640653] |
Mon, 22 November 2010 17:16 |
Sean McFee Messages: 2 Registered: November 2010 |
Junior Member |
|
|
In my textual DSL it was necessary to capture single-line comments in the AST so that they could be brought into a model. This was accomplished in oAW 4.3.1 by moving the default rule into the grammar as a Native type, as follows:
Native SL_COMMENT
: "'//' ~('\n'|'\r')* '\r'? '\n'";
You then must account for the many places in your language a comment can occur, which is tedious but doable.
Migrating to the Eclipse Xtext, this rule was replaced with a terminal type:
terminal SL_COMMENT
: "'//' ~('\n'|'\r')* '\r'? '\n'";
Comments now no longer parse at all. The parser error for any line in which a comment is inserted (at the start or mid-way) is:
mismatched input '/' expecting EOF
Multi-line comments, which were not overridden in the grammar, continue to parse correctly (but do not end up in the AST obviously).
Any idea how I can get this working again?
EDIT: This issue is resolved. Instead of importing the default Xtext terminals I deep-copied them into my grammar and imported ecore directly, and changed the grammar definition to not hide the comments. The definition of SL_COMMENT had changed slightly in the last couple of years and adopting the current one resolved the parse errors.
[Updated on: Mon, 22 November 2010 19:02] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.02859 seconds