How to match a string, but case-insensitively?

前端 未结 5 906
渐次进展
渐次进展 2020-12-29 05:59

Let\'s say that I want to match \"beer\", but don\'t care about case sensitivity.

Currently I am defining a token to be (\'b\'|\'B\' \'e\'|\'E\' \'e\'|\'E\' \'r\'|

5条回答
  •  温柔的废话
    2020-12-29 06:34

    How about define a lexer token for each permissible identifier character, then construct the parser token as a series of those?

    beer: B E E R;
    
    A : 'A'|'a';
    B: 'B'|'b';
    

    etc.

提交回复
热议问题