-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
grammar
40 lines (22 loc) · 1.42 KB
/
grammar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Query grammar
<query> ::= select <resultcolumns> [ from <source> ] [where <expr> ] [group by <orderingterms>] [order by <orderingterms> [having <expr>]] [limit <digit> [offset <digit ]] ";"
<resultcolumns> ::= <resultcolumn> | <resultcolumn>,<resultcolumns>
<resultcolumn> ::= * | <expr> [ as <colname> ]
<colname> ::= <identifier>
<source> ::= tablename
<identifier> ::= letter {letter|digit}
<orderingterms> ::= <orderingterm> {, <orderingterm>}
<orderingterm> ::= <expr> [as <identifier>]
<digit> ::= 0-9
<letter> ::= a-zA-Z
<expr> ::= <literal> |
<colname> |
<unary-op> <expr> |
<expr> <binary-op> <expr> |
<function> (<expr>|*) |
( <expr> )
<literal> ::= "'"{ any_character }"'" | <number>
<number> ::= <digit> {<digit>} [ "." {<digit>}] | "." <digit> {<digit>} ["e" [+|-] <digit> {<digit>} ]
<unary-op> ::= "+" | "-" | "~" | NOT
<binary-op> ::= "||" | "*" | "/" | "%" | "+" | "-" | "<<" | ">>" | "&" | "|" | "<" | "<=" | ">" | ">=" | "=" | "==" | "!=" | "<>" | IS | IS NOT | AND | OR
<function> ::= COUNT | AVG | SUM | MIN | MAX | TRUNCATE | RSPLIT | IF | NAME | TRIM | LOWER | STDEV