program = _{ SOI ~ ";"* ~ (stmt ~ ";"+) ~ stmt? ~ EOI }
stmt = _{ expr }
expr = {
new_db |
perm_db |
drop_db |
drop_user |
new |
drop |
exists |
length |
ttl |
put |
put_when |
put_pointer |
get |
get_when |
get_pointer |
get_view |
get_clip |
get_index |
get_range |
search_typing |
delete |
delete_when |
delete_pointer |
delete_clip
}
new_db = { "db"~"."~"new"~"("~object~")" }
perm_db = { "db"~"."~"permit"~"("~object~")" }
drop_db = { "db"~"."~"drop"~"("~db~")" }
drop_user = { "db"~"("~db~")"~"."~"user"~"("~quots~")"~"."~"drop"~"("~")" }
new = { "new" ~ "(" ~ object ~ ")" }
drop = { "drop" ~ "(" ~ collection ~ ")" }
exists = { "exists" ~ "(" ~ pointer ~ ")"~"."~"into"~"(" ~ collection ~ ")" }
length = { "length"~"("~ collection ~ ")" }
flush = { "flush"~"("~ collection ~ ")" }
put = { "put"~"(" ~ document ~ ")"~"."~"into"~"(" ~ collection ~ ")" }
put_when = { "put"~"("~document~")"~"."~"when"~"("~condition~")"~"."~"into"~"(" ~ collection ~ ")" }
put_pointer = { "put"~"("~document~")"~"."~"pointer"~"("~pointer~")"~"."~"into"~"(" ~ collection ~ ")" }
ttl = { "ttl"~"("~u64~")"~"."~"if"~"("~condition~")"~"."~"into"~"(" ~ collection ~ ")" }
get = { "get"~"."~"from"~"("~ collection ~")" ~ ("."~"sort"~"(") ~ sort ~ (")") ~ ("."~"page"~"(") ~limit~ (")") }
get_when = { "get"~"."~"when"~"(" ~ condition ~ ")"~"."~"from"~"("~collection~")" ~ ("."~"sort"~"(") ~ sort ~ (")") ~ ("."~"page"~"(") ~limit~ (")") }
get_pointer = { "get"~"."~"pointer"~"("~ pointer ~ ")"~"."~"from"~"("~collection~")" }
get_view = { "get"~"."~"view"~"(" ~ view ~ ")"~"."~"from"~"("~collection~")" }
get_clip = { "get"~"."~"clip"~"(" ~ clip ~ ")"~"."~"from"~"("~collection~")" }
get_index = { "get"~"."~"index"~"("~quots~")"~"."~"from"~"("~collection~")" }
get_range = { "get"~"."~"range"~"("~"start"~":"~quots~","~"end"~":"~quots~","~"on"~":"~quots~")"~"."~"from"~"("~collection~")" }
search_typing = { "search"~"."~"typing"~"("~quots~")"~"."~"from"~"("~collection~")" }
delete = { "delete"~"."~"from"~"(" ~ collection ~ ")" }
delete_when = { "delete"~"."~"when"~"(" ~ condition ~ ")"~"."~"from"~"("~collection~")" }
delete_pointer = { "delete"~"."~"pointer"~"("~ pointer ~ ")"~"."~"from"~"("~collection~")" }
delete_clip = { "delete"~"."~"clip"~"(" ~ clip ~ ")"~"."~"from"~"("~collection~")" }
db = @{quots}
collection = @{quots}
pointer = @{quots}
view = @{quots}
clip = @{quots}
document = @{object}
condition = @{ "'" ~ ( "''" | (!"'" ~ ANY) )* ~ "'" }
u64 = @{ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*}
limit = @{null | ((ASCII_DIGIT*)~","~(ASCII_DIGIT*))}
sort = @{null | (quots~","~("'ASC'" | "'DESC'"))}
quots = @{ "'" ~ ( "''" | (!"'" ~ ANY) )* ~ "'" }
object = {
"{" ~ "}" |
"{" ~ pair ~ ("," ~ pair)* ~ "}"
}
array = {
"[" ~ "]" |
"[" ~ value ~ ("," ~ value)* ~ "]"
}
string = ${ "\"" ~ inner ~ "\"" }
value = _{ object | array | string | number | boolean | null }
number = @{
"-"?
~ ("0" | ASCII_NONZERO_DIGIT ~ ASCII_DIGIT*)
~ ("." ~ ASCII_DIGIT*)?
~ (^"e" ~ ("+" | "-")? ~ ASCII_DIGIT+)?
}
boolean = { "true" | "false" }
null = { "null" }
inner = @{ char* }
char = {
!("\"" | "\\") ~ ANY
| "\\" ~ ("\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t")
| "\\" ~ ("u" ~ ASCII_HEX_DIGIT{4})
}
pair = { string ~ ":" ~ value }
WHITESPACE = _{ " " | "\t" | "\r" | "\n" }
COMMENT = _{ "#" ~ (!"\n" ~ ANY)* }