1
0
silverbullet/plugs/query/query.grammar
2022-04-11 20:34:09 +02:00

45 lines
683 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 }
LogicalExpr { AndExpr | FilterExpr }
AndExpr { FilterExpr !logic "and" FilterExpr }
FilterExpr {
Name "<" Value
| Name "<=" Value
| Name "=" Value
| Name "!=" Value
| Name ">=" Value
| Name ">" Value
| Name "like" Value
}
@skip { space }
Bool {
"true" | "false"
}
@tokens {
space { std.whitespace+ }
Name { std.asciiLetter+ }
String { "\"" ![\"]* "\"" }
Number { std.digit+ }
}