54 lines
843 B
Plaintext
54 lines
843 B
Plaintext
@precedence { logic @left }
|
|
|
|
@top Program { Query }
|
|
|
|
Query {
|
|
Name (WhereClause | OrderClause | LimitClause)*
|
|
}
|
|
|
|
WhereClause { "where" LogicalExpr }
|
|
OrderClause { "order" "by" Name Order? }
|
|
LimitClause { "limit" Number }
|
|
|
|
Order {
|
|
"desc" | "asc"
|
|
}
|
|
|
|
Value { Number | String | Bool | Regex | Null }
|
|
|
|
LogicalExpr { AndExpr | FilterExpr }
|
|
|
|
AndExpr { FilterExpr !logic "and" FilterExpr }
|
|
|
|
FilterExpr {
|
|
Name "<" Value
|
|
| Name "<=" Value
|
|
| Name "=" Value
|
|
| Name "!=" Value
|
|
| Name ">=" Value
|
|
| Name ">" Value
|
|
| Name "=~" Value
|
|
| Name "!=~" Value
|
|
}
|
|
|
|
@skip { space }
|
|
|
|
Bool {
|
|
"true" | "false"
|
|
}
|
|
|
|
Null {
|
|
"null"
|
|
}
|
|
|
|
@tokens {
|
|
space { std.whitespace+ }
|
|
Name { (std.asciiLetter | "-" | "_")+ }
|
|
String {
|
|
("\"" | "“" | "”") ![\"”“]* ("\"" | "“" | "”")
|
|
}
|
|
Regex { "/" ( ![/\\\n\r] | "\\" _ )* "/"? }
|
|
|
|
Number { std.digit+ }
|
|
}
|