1
0
silverbullet/plugs/directive/query.grammar

66 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-04-11 18:34:09 +00:00
@precedence { logic @left }
@top Program { Query }
Query {
Name ( WhereClause | OrderClause | LimitClause | SelectClause | RenderClause )*
2022-04-11 18:34:09 +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 }
SelectClause { "select" commaSep<Name> }
2022-08-09 13:37:47 +00:00
RenderClause { "render" (PageRef | String) }
2022-04-11 18:34:09 +00:00
Order {
"desc" | "asc"
}
Value { Number | String | Bool | Regex | Null | List }
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
| Name "=~" Value
| Name "!=~" Value
| Name "in" Value
2022-04-11 18:34:09 +00:00
}
List { "[" commaSep<Value> "]" }
2022-04-11 18:34:09 +00:00
@skip { space }
2022-04-11 18:34:09 +00:00
Bool {
"true" | "false"
}
Null {
"null"
}
2022-04-11 18:34:09 +00:00
@tokens {
space { std.whitespace+ }
Name { (std.asciiLetter | "-" | "_")+ }
String {
("\"" | "“" | "”") ![\"”“]* ("\"" | "“" | "”")
}
2022-08-09 13:37:47 +00:00
PageRef {
"[" "[" ![\]]* "]" "]"
}
Regex { "/" ( ![/\\\n\r] | "\\" _ )* "/"? }
2022-04-11 18:34:09 +00:00
Number { std.digit+ }
}