1
0
silverbullet/common/markdown_parser/query.grammar

69 lines
1.2 KiB
Plaintext
Raw Normal View History

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