Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. grammar Rdl;
  2.  
  3. filter
  4. : logical_expression
  5. | '[' ']'
  6. ;
  7.  
  8.  
  9. expression
  10. : conditional_expression
  11. | logical_expression
  12. | value
  13. ;
  14.  
  15. conditional_expression
  16. : '{' conditional_operator ':' '{' '"if"' ':' conditional_expression ',' '"then"' ':' expression ',' '"else"' ':' expression '}' '}'
  17. | logical_expression
  18. ;
  19.  
  20. logical_expression
  21. : compare_expression
  22. | '[' compare_expression (',' logical_operator ',' compare_expression)* ']'
  23. | '[' logical_expression ',' logical_operator ',' logical_expression ']'
  24. ;
  25.  
  26. compare_expression
  27. : '{' column_name ':' '{' comparison_operator ':' value '}' '}'
  28. ;
  29.  
  30. column_name
  31. : (ESC | SAFECODEPOINT)+ '.' (ESC | SAFECODEPOINT)+
  32. | STRING
  33. ;
  34.  
  35. comparison_operator
  36. : '"$eq"'
  37. | '"$ne"'
  38. | '"$gte"'
  39. | '"lte"'
  40. | '"$gt"'
  41. | '"$lt"'
  42. | '"$in"'
  43. ;
  44.  
  45. logical_operator
  46. : '"$and"'
  47. | '"$or"'
  48. ;
  49.  
  50. conditional_operator
  51. : '"$cond"'
  52. ;
  53.  
  54.  
  55.  
  56. scalar_function
  57. : math_function
  58. | string_function
  59. | date_function
  60. ;
  61.  
  62. math_function
  63. : '"$abs"'
  64. | '"$add"'
  65. | '"$ceil"'
  66. | '"$divide"'
  67. | '"$floor"'
  68. | '"$multiply"'
  69. | '"$pow"'
  70. | '"$subtract"'
  71. ;
  72.  
  73. string_function
  74. : '"$concat"'
  75. | '"$substring"'
  76. | '"$to_upper"'
  77. | '"$to_lower"'
  78. | '"$trim"'
  79. ;
  80.  
  81. date_function
  82. : '"$format_date"'
  83. | '"$month"'
  84. | '"$day"'
  85. | '"$year"'
  86. ;
  87.  
  88. aggregate_function
  89. : '"$avg"'
  90. | '"$count"'
  91. | '"$max"'
  92. | '"$min"'
  93. | '"$sum"'
  94. ;
  95.  
  96. value
  97. : STRING
  98. | NUMBER
  99. | column_name
  100. | array
  101. | 'true'
  102. | 'false'
  103. | 'null'
  104. ;
  105.  
  106. array
  107. : '[' value (',' value)* ']'
  108. | '[' ']'
  109. ;
  110.  
  111.  
  112. STRING
  113. : '"' (ESC | SAFECODEPOINT)* '"'
  114. ;
  115.  
  116.  
  117. fragment ESC
  118. : '\\' (["\\/bfnrt] | UNICODE)
  119. ;
  120. fragment UNICODE
  121. : 'u' HEX HEX HEX HEX
  122. ;
  123. fragment HEX
  124. : [0-9a-fA-F]
  125. ;
  126. fragment SAFECODEPOINT
  127. : ~ ["\\\u0000-\u001F]
  128. ;
  129.  
  130.  
  131. NUMBER
  132. : '-'? INT ('.' [0-9] +)? EXP?
  133. ;
  134.  
  135.  
  136. fragment INT
  137. : '0' | [1-9] [0-9]*
  138. ;
  139.  
  140. // no leading zeros
  141.  
  142. fragment EXP
  143. : [Ee] [+\-]? INT
  144. ;
  145.  
  146. // \- since - means "range" inside [...]
  147.  
  148. WS
  149. : [ \t\n\r] + -> skip
  150. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement