mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Attributes are unmaintained and unused. They have become more of a liability than a benefit. This change eliminates them from the codebase. The only user-visible change (assuming that attrs are not used) is that the attrs field will no longer appear in row JSON.
86 lines
4.1 KiB
Text
86 lines
4.1 KiB
Text
package pql
|
|
|
|
type PQL Peg {
|
|
Query
|
|
}
|
|
|
|
# All input queries consist of a sequence of calls, at the top level.
|
|
Calls <- sp (Call sp)* !.
|
|
Call <- "Set" {p.startCall("Set")} open col comma args (comma time)? close {p.endCall()}
|
|
/ "Clear" {p.startCall("Clear")} open col comma args close {p.endCall()}
|
|
/ "ClearRow" {p.startCall("ClearRow")} open arg close {p.endCall()}
|
|
/ "Store" {p.startCall("Store")} open Call comma arg close {p.endCall()}
|
|
/ "TopN" {p.startCall("TopN")} open posfield (comma allargs)? close {p.endCall()}
|
|
/ "TopK" {p.startCall("TopK")} open posfield (comma allargs)? close {p.endCall()}
|
|
/ "Percentile" {p.startCall("Percentile")} open posfield (comma allargs)? close {p.endCall()}
|
|
/ "Rows" {p.startCall("Rows")} open posfield (comma allargs)? close {p.endCall()}
|
|
/ "Min" {p.startCall("Min")} open posfield (comma allargs)? close {p.endCall()}
|
|
/ "Max" {p.startCall("Max")} open posfield (comma allargs)? close {p.endCall()}
|
|
/ "Sum" {p.startCall("Sum")} open posfield (comma allargs)? close {p.endCall()}
|
|
/ "Range" {p.startCall("Range")} open field eq value comma 'from='? {p.addField("from")} timefmt {p.addVal(text)} comma 'to='? sp {p.addField("to")} timefmt {p.addVal(text)} close {p.endCall()}
|
|
/ < IDENT > { p.startCall(text) } open allargs comma? close { p.endCall() }
|
|
allargs <- Call (comma Call)* (comma args)? / args / sp
|
|
args <- arg (comma args)? sp
|
|
arg <- field eq value
|
|
/ field sp COND sp value
|
|
/ conditional
|
|
COND <- '><' { p.addBTWN() }
|
|
/ '<=' { p.addLTE() }
|
|
/ '>=' { p.addGTE() }
|
|
/ '==' { p.addEQ() }
|
|
/ '!=' { p.addNEQ() }
|
|
/ '<' { p.addLT() }
|
|
/ '>' { p.addGT() }
|
|
|
|
conditional <- {p.startConditional()} condint condLT condfield condLT condint {p.endConditional()}
|
|
condint <- < decimal > sp {p.condAdd(text)}
|
|
condLT <- <('<=' / '<')> sp {p.condAdd(text)}
|
|
condfield <- <fieldExpr> sp {p.condAdd(text)}
|
|
|
|
value <- item
|
|
/ lbrack { p.startList() } items rbrack { p.endList() }
|
|
items <- item (comma items)?
|
|
item <- 'null' &(comma / close) { p.addVal(nil) }
|
|
/ 'true' &(comma / close) { p.addVal(true) }
|
|
/ 'false' &(comma / close) { p.addVal(false) }
|
|
/ timefmt { p.addVal(text) }
|
|
/ timestampfmt { p.addTimestampVal(text) }
|
|
/ < decimal > { p.addNumVal(text) }
|
|
/ < IDENT > { p.startCall(text) } open allargs comma? close { p.addVal(p.endCall()) }
|
|
/ < ([[A-Z]] / [0-9] / '-' / '_' / ':')+ > { p.addVal(text) }
|
|
/ < '"' doublequotedstring '"' > { p.addVal(text) }
|
|
/ < '\'' singlequotedstring '\'' > { p.addVal(text) }
|
|
|
|
doublequotedstring <- ( '\\"' / '\\\\' / '\\n' / '\\t' / [^"\\] )*
|
|
singlequotedstring <- ( '\\\'' / '\\\\' / '\\n' / '\\t' / [^'\\] )*
|
|
|
|
fieldExpr <- ( [[A-Z]] / '_' ) ( [[A-Z]] / [0-9] / '_' / '-' )*
|
|
field <- <fieldExpr / reserved> { p.addField(text) }
|
|
reserved <- '_row' / '_col' / '_start' / '_end' / '_timestamp' / '_field'
|
|
posfield <- 'field='? <fieldExpr> { p.addPosStr("_field", text) }
|
|
col <- < digits > {p.addPosNum("_col", text)}
|
|
/ < '\'' singlequotedstring '\'' > {p.addPosStr("_col", text)}
|
|
/ < '"' doublequotedstring '"' > {p.addPosStr("_col", text)}
|
|
|
|
open <- '(' sp
|
|
close <- sp ')' sp
|
|
sp <- [ \t\n]*
|
|
eq <- sp '=' sp
|
|
comma <- sp ',' sp
|
|
lbrack <- '[' sp
|
|
rbrack <- sp ']' sp
|
|
IDENT <- [[A-Z]] ([[A-Z]] / [0-9])*
|
|
digits <- [0-9]+
|
|
signedDigits <- '-'? digits
|
|
decimal <- signedDigits ('.' digits?)?
|
|
/ '-'? '.' digits
|
|
|
|
tz <- 'Z' / '-' [0-9][0-9]':'[0-9][0-9] / '+'[0-9][0-9]':'[0-9][0-9]
|
|
iso8601 <- [0-9][0-9][0-9][0-9]'-'[01][0-9]'-'[0-3][0-9]'T'[0-9][0-9]':'[0-9][0-9]':'[0-9][0-9] <tz>
|
|
iso8601nano <- [0-9][0-9][0-9][0-9]'-'[01][0-9]'-'[0-3][0-9]'T'[0-9][0-9]':'[0-9][0-9]':'[0-9][0-9]'.'[0-9]+ <tz>
|
|
timestampbasicfmt <- iso8601nano / iso8601
|
|
timestampfmt <- '"' <timestampbasicfmt> '"' / '\'' <timestampbasicfmt> '\'' / <timestampbasicfmt>
|
|
|
|
timebasicfmt <- [0-9][0-9][0-9][0-9]'-'[01][0-9]'-'[0-3][0-9]'T'[0-9][0-9]':'[0-9][0-9]
|
|
timefmt <- '"' <timebasicfmt> '"' / '\'' <timebasicfmt> '\'' / <timebasicfmt>
|
|
time <- <timefmt> {p.addPosStr("_timestamp", text)}
|