0

I have written a validation which works fine but I want to know how I can set the error marker(the red line drawn underneath the input) at the proper position.
The Problem is that the part of my grammar looks like that:

Declaration:
name = ID "=" singleContent=VarContent (OPERATOR nextCon+=VarContent)*
;

The validator now detects an error at a specififc element of nextCon so my question is how can I refer to that particular element so the error-functions knows where to draw the line.

The input I validate looks like that:

var = 3 * 4 + -var2

The "-" within var2 is wrong and therefore I want to highlight the error right there or highlight the complete "-var2" statement.

Greetings Krzmbrzl

Raven
  • 2,951
  • 2
  • 26
  • 42

1 Answers1

1

In your validation rule, you can use one of the overloaded variants of error(..) or warning(..) that accepts an index in case you have a multi-value feature like nextCon.

The grammar snippet that you posted indicates that you don't use a tree to parse an expression but a list of values. You may want to have a look at the documentation to learn how to fix this.

Sebastian Zarnekow
  • 6,609
  • 20
  • 23
  • What is the advantage of using a tree in this case? I mean it works just fine as it is... – Raven May 18 '15 at 18:19
  • A tree would ensure that you get proper precedences in case of + and * – Sebastian Zarnekow May 19 '15 at 20:15
  • Ah okay now I understand... Thanks for that tip but for my purpose I don't need to care about precedence at all since I only want to create an elicited plug in for an existing language (and I won't implement a compiler) – Raven May 20 '15 at 13:19