问题
I want to create a rule in XText that matches to a string, but does not care in what case the string is. For example, I want it to match against both "DUCK", "DucK" and "duck". Is there a more simple way of doing it than covering all cases, like:
Rule:
'Duck'|'DucK'|'DuCK'|... and so on
;
回答1:
There is a flag that you can configure in the mwe2 workflow. Replace the XtextAntlrGeneratorFragment
by the org.eclipse.xtext.generator.parser.antlr.ex.rt.AntlrGeneratorFragment
and pass options = { ignoreCase = true }
. Same for the XtextAntlrUiGeneratorFragment
and the org.eclipse.xtext.generator.parser.antlr.ex.ca.ContentAssistParserGeneratorFragment
回答2:
FYI.
language = StandardLanguage {
...
parserGenerator = {
options = {
ignoreCase = true //Case Insensitive Keywords
}
}
scopeProvider = {
ignoreCase = true //Case Insensitive "name=ID"
}
...
}
来源:https://stackoverflow.com/questions/30889847/match-string-in-xtext-regardless-of-upper-lower-case