Match string in XText regardless of upper/lower case

808 views Asked by At

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
;
2

There are 2 answers

4
Sebastian Zarnekow On BEST ANSWER

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

0
Christoff Erasmus On

FYI.

    language = StandardLanguage {
        ...
        parserGenerator = {
            options = {
                ignoreCase = true //Case Insensitive Keywords
            }
        }
        scopeProvider = {
            ignoreCase = true //Case Insensitive "name=ID" 
        }
        ...
    }