0

I have redefined the STRING terminal this way

terminal STRING : ('.'|'+'|'('|')'|'a'..'z'|'A'..'Z'|'_'|'0'..'9')*;

because I have to recognize STRING not delimited by " or '

the problem is that, though the generated parser works, it truncates the first and the last character of the recognized string. What am I missing?

Andrea Sindico
  • 7,358
  • 6
  • 47
  • 84

1 Answers1

1

If you customize the STRING rule, you'll have to adapt the respective value converter, too.

Something like this has to be bound in your runtime module:

public class MyStringValueConverter extends STRINGValueConverter {

    @Override
    protected String toEscapedString(String value) {
        return value;
    }

    public String toValue(String string, INode node) {
        if (string == null)
            return null;
        return string;
    }
}

See the docs for details.

Sebastian Zarnekow
  • 6,609
  • 20
  • 23