[英]XText: first and last character truncated in custom STRING terminals
I have redefined the STRING terminal this way 我已经用这种方式重新定义了STRING终端
terminal STRING : ('.'|'+'|'('|')'|'a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
because I have to recognize STRING not delimited by " or ' 因为我必须认识到STRING不能以“或”分隔
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?
我想念什么?
If you customize the STRING rule, you'll have to adapt the respective value converter, too. 如果自定义STRING规则,则还必须调整相应的值转换器。
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. 有关详细信息,请参阅文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.