2022-04-11 18:34:09 +00:00
|
|
|
@precedence { logic @left }
|
|
|
|
|
|
|
|
@top Program { Query }
|
|
|
|
|
|
|
|
Query {
|
2022-04-21 09:46:33 +00:00
|
|
|
Name ( WhereClause | OrderClause | LimitClause | SelectClause )*
|
2022-04-11 18:34:09 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 09:46:33 +00:00
|
|
|
commaSep<content> { content ("," content)* }
|
|
|
|
|
2022-04-11 18:34:09 +00:00
|
|
|
WhereClause { "where" LogicalExpr }
|
|
|
|
OrderClause { "order" "by" Name Order? }
|
|
|
|
LimitClause { "limit" Number }
|
2022-04-21 09:46:33 +00:00
|
|
|
SelectClause { "select" commaSep<Name> }
|
2022-04-11 18:34:09 +00:00
|
|
|
|
|
|
|
Order {
|
|
|
|
"desc" | "asc"
|
|
|
|
}
|
|
|
|
|
2022-04-13 12:46:52 +00:00
|
|
|
Value { Number | String | Bool | Regex | Null }
|
2022-04-11 18:34:09 +00:00
|
|
|
|
|
|
|
LogicalExpr { AndExpr | FilterExpr }
|
|
|
|
|
|
|
|
AndExpr { FilterExpr !logic "and" FilterExpr }
|
|
|
|
|
|
|
|
FilterExpr {
|
|
|
|
Name "<" Value
|
|
|
|
| Name "<=" Value
|
|
|
|
| Name "=" Value
|
|
|
|
| Name "!=" Value
|
|
|
|
| Name ">=" Value
|
|
|
|
| Name ">" Value
|
2022-04-12 11:33:07 +00:00
|
|
|
| Name "=~" Value
|
2022-04-13 12:46:52 +00:00
|
|
|
| Name "!=~" Value
|
2022-04-11 18:34:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@skip { space }
|
|
|
|
|
2022-04-21 09:46:33 +00:00
|
|
|
|
|
|
|
|
2022-04-11 18:34:09 +00:00
|
|
|
Bool {
|
|
|
|
"true" | "false"
|
|
|
|
}
|
|
|
|
|
2022-04-13 12:46:52 +00:00
|
|
|
Null {
|
|
|
|
"null"
|
|
|
|
}
|
|
|
|
|
2022-04-11 18:34:09 +00:00
|
|
|
@tokens {
|
|
|
|
space { std.whitespace+ }
|
2022-04-19 14:54:47 +00:00
|
|
|
Name { (std.asciiLetter | "-" | "_")+ }
|
2022-04-12 11:33:07 +00:00
|
|
|
String {
|
|
|
|
("\"" | "“" | "”") ![\"”“]* ("\"" | "“" | "”")
|
|
|
|
}
|
|
|
|
Regex { "/" ( ![/\\\n\r] | "\\" _ )* "/"? }
|
|
|
|
|
2022-04-11 18:34:09 +00:00
|
|
|
Number { std.digit+ }
|
|
|
|
}
|