Reputation: 1313
I have the following Xtext2 grammar:
Bibliography:
macros += Macro*
;
Macro:
"@string{" name = ID "=" value = LATEXSTRING "}"
;
terminal LATEXSTRING:
'"' (!('"'))* '"'
;
When parsing a the string
@string{ABBREV = "Some Long Text"}
and storing it in some object macro
of type Macro
it has the following values:
macro.name: ABBREV
macro.value: "Some Long Text"
both of type String
(EString
). I would like to have the value without quotes though. How can I achieve that?
Upvotes: 0
Views: 561
Reputation: 6729
You have to register a value convert for the rule LATEXSTRING. According to the docs, it should look like this:
@Inject
private LatexStringConverter latexStringConverter;
@ValueConverter(rule = "LATEXSTRING")
public IValueConverter<String> converterForLatexString() {
return latexStringConverter;
}
with
public class LatexStringConverter extends AbstractLexerBasedConverter<String> {
@Override
protected String toEscapedString(String value) {
..
}
public String toValue(String string, INode node) {
..
}
}
Upvotes: 1