0

I have an Xtext grammar for a CNL sentence and in some its variants I would require the user to write the same parts in the sentence:

Formula: 
'It' 'should' 'be' e1=Expr 'and' 'again' e2=Expr;

where Expr is a recursive expression like a boolean formula and the parser should accept the sentence only if e1 and e2 are the same (if e1 = a and b, then e2 should also be a and b).

  1. Can I do it without writing code only by means of Xtext grammar?
  2. How to prompt the user in a popup window on Ctrl+Space in the generated IDE that the user should write the same Expr here as it was just written before?
SeregASM
  • 75
  • 12

1 Answers1

0

Do you expect e1 and e2 to be the same node in the tree? Or are they different but they should be similar?

I'd argue for the former, and in that case I'd suggest making e2 a cross-reference and implementing scoping such that only e1 may be referenced at that point. I'm afraid this requires some Java implementation. This will also implement your 2nd question.

user1292456
  • 778
  • 4
  • 12