commentsindentationxtext

Xtext indentation with single line comment


I was having problems with indentation and single line comments in my xtext grammar. I tried the same thing in xtext example project

org.eclipse.xtext.example.homeautomation

(with Xtext installed, you can import this project like this: File → New → Example → Xtext Examples → Xtext Home Automation Example) and results were the same. Is this and xtext bug? If so how can i open document and preparse it (to get rid of sl comments) and then give it to xtext lexer?

Device Window can be open, closed
Device Heater can be on, off, error

Rule 'Save energy' when Window.open then //asdasdd
    fire(Heater.off)
    println('Another penny to the piggy bank!')

enter image description here

Marker text:

1: - missing RULE_BEGIN at 'fire'

2: - mismatched input ''expecting RULE_END

Thanks.


Solution

  • can you file a ticket at eclipse for that

    you may use the following workaround (dont know if there are negative side effects

    terminal SL_COMMENT: '//' !('\n'|'\r')*;