RuleLexer.g4 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. lexer grammar RuleLexer;
  2. COUNT : 'count';
  3. AVG : 'avg';
  4. SUM : 'sum';
  5. MAX : 'max';
  6. MIN : 'min';
  7. AND : 'and'|'&&'|','|'\u5e76\u4e14'|'\u4e14';
  8. OR : 'or'|'||'|'\u6216\u8005'|'\u6216';
  9. Datatype : 'String'
  10. | 'int'
  11. | 'Integer'
  12. | 'double'
  13. | 'Double'
  14. | 'long'
  15. | 'Long'
  16. | 'float'
  17. | 'Float'
  18. | 'BigDecimal'
  19. | 'boolean'
  20. | 'Boolean'
  21. | 'Date'
  22. | 'List'
  23. | 'Set'
  24. | 'Map'
  25. | 'Enum'
  26. | 'Object'
  27. ;
  28. GreaterThen : '>'|'\u5927\u4e8e';
  29. GreaterThenOrEquals : '>='|'\u5927\u4e8e\u7b49\u4e8e';
  30. LessThen : '<'|'\u5c0f\u4e8e';
  31. LessThenOrEquals : '<='|'\u5c0f\u4e8e\u7b49\u4e8e';
  32. Equals : '=='|'\u7b49\u4e8e';
  33. NotEquals : '!='|'\u4e0d\u7b49\u4e8e';
  34. EndWith : 'EndWith'|'\u7ed3\u675f\u4e8e';
  35. NotEndWith : 'NotEndWith'|'\u4e0d\u7ed3\u675f\u4e8e' ;
  36. StartWith : 'StartWith'|'\u5f00\u59cb\u4e8e';
  37. NotStartWith : 'NotStartWith'|'\u4e0d\u5f00\u59cb\u4e8e';
  38. In : 'In'|'\u5728\u96c6\u5408\u4e2d';
  39. NotIn : 'NotIn'|'\u4e0d\u5728\u96c6\u5408\u4e2d';
  40. Match : 'Match'|'\u5339\u914d';
  41. NotMatch : 'NotMatch'|'\u4e0d\u5339\u914d';
  42. Contain : 'Contain'|'\u5305\u542b';
  43. NotContain : 'NotContain'|'\u4e0d\u5305\u542b';
  44. EqualsIgnoreCase : 'EqualsIgnoreCase'|'\u5ffd\u7565\u5927\u5c0f\u5199\u7b49\u4e8e';
  45. NotEqualsIgnoreCase : 'NotEqualsIgnoreCase'|'\u5ffd\u7565\u5927\u5c0f\u5199\u4e0d\u7b49\u4e8e';
  46. ARITH
  47. :
  48. '+'
  49. | '-'
  50. | '*'
  51. | '/'
  52. | '%'
  53. ;
  54. NUMBER
  55. :
  56. '-'? INT '.' INT EXP? // ('-'? INT '.' INT EXP?)1.35, 1.35E-9, 0.3, -4.5
  57. | '-'? INT EXP // 1e10 -3e4
  58. | '-'? INT // -3, 45
  59. ;
  60. Boolean : 'true'
  61. | 'false'
  62. ;
  63. Identifier
  64. :
  65. StartChar Char*
  66. ;
  67. STRING :
  68. '"' STRING_CONTENT '"'
  69. ;
  70. fragment
  71. STRING_CONTENT :
  72. ( EscapeSequence | ~('"'))*
  73. ;
  74. fragment
  75. INT
  76. :
  77. DIGIT+
  78. ;
  79. fragment
  80. EXP
  81. :
  82. [Ee] [+\-]? INT
  83. ; // \- since - means "range" inside [...]
  84. fragment
  85. EscapeSequence
  86. : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
  87. | UnicodeEscape
  88. | OctalEscape
  89. ;
  90. fragment
  91. OctalEscape
  92. : '\\' ('0'..'3') ('0'..'7') ('0'..'7')
  93. | '\\' ('0'..'7') ('0'..'7')
  94. | '\\' ('0'..'7')
  95. ;
  96. fragment
  97. UnicodeEscape
  98. :
  99. '\\' 'u' HEX HEX HEX HEX
  100. ;
  101. fragment
  102. Char : StartChar
  103. | '-' | '_' | DIGIT
  104. | '\u00B7'
  105. | '\u0300'..'\u036F'
  106. | '\u203F'..'\u2040'
  107. ;
  108. fragment
  109. StartChar
  110. : [a-zA-Z]
  111. | '\u2070'..'\u218F'
  112. | '\u2C00'..'\u2FEF'
  113. | '\u3001'..'\uD7FF'
  114. | '\uF900'..'\uFDCF'
  115. | '\uFDF0'..'\uFFFD'
  116. ;
  117. fragment
  118. DIGIT
  119. :
  120. [0-9]
  121. ;
  122. fragment
  123. HEX
  124. :
  125. [0-9a-fA-F]
  126. ;
  127. WS
  128. :
  129. [ \t\r\n]+ -> channel(HIDDEN)
  130. ;
  131. NL
  132. :
  133. '\r'? '\n' ->channel(HIDDEN)
  134. ;
  135. COMMENT
  136. : '/*' .*? '*/' ->channel(HIDDEN);
  137. LINE_COMMENT
  138. : '//' ~[\r\n]* '\r'? '\n' ->channel(HIDDEN)
  139. ;