Match string in XText regardless of upper/lower case

落花浮王杯 提交于 2019-12-11 13:33:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!