modernc.org/ql@v1.4.7/ql.ebnf (about)

     1  andand = "&&" .
     2  andnot = "&^" .
     3  ascii_letter = "a" … "z" | "A" … "Z" .
     4  big_u_value = "\\" "U" hex_digit hex_digit hex_digit hex_digit hex_digit hex_digit hex_digit hex_digit .
     5  byte_value = octal_byte_value | hex_byte_value .
     6  decimal_digit = "0" … "9" .
     7  decimal_lit = ( "1" … "9" ) { decimal_digit } .
     8  decimals = decimal_digit { decimal_digit } .
     9  eq = "==" | "=" .
    10  escaped_char = "\\" (
    11  		  "a"
    12  		| "b"
    13  		| "f"
    14  		| "n"
    15  		| "r"
    16  		| "t"
    17  		| "v"
    18  		| "\\"
    19  		| "'"
    20  		| "\""
    21  	  ) .
    22  exponent = ( "e" | "E" ) [ "+" | "-" ] decimals .
    23  float_lit = decimals "." [ decimals ] [ exponent ]
    24  	| decimals exponent
    25  	| "." decimals [ exponent ] .
    26  ge = ">=" .
    27  hex_byte_value = "\\" "x" hex_digit hex_digit .
    28  hex_digit = "0" … "9"
    29  	| "A" … "F"
    30  	| "a" … "f" .
    31  hex_lit = "0" ( "x" | "X" ) hex_digit { hex_digit } .
    32  identifier = normal_identifier 
    33  		| quoted_identifier .
    34  normal_identifier = letter {
    35  		  letter
    36  		| decimal_digit
    37  		| unicode_digit
    38  	  } .
    39  quoted_identifier = "«" { unicode_char | newline } "»".
    40  imaginary_lit = ( decimals | float_lit ) "i" .
    41  int_lit = decimal_lit
    42  	| octal_lit
    43  	| hex_lit .
    44  interpreted_string_lit = "\"" { unicode_value | byte_value } "\"" .
    45  le = "<=" .
    46  letter = ascii_letter
    47  	| unicode_letter
    48  	| "_" .
    49  little_u_value = "\\" "u" hex_digit hex_digit hex_digit hex_digit .
    50  lsh = "<<" .
    51  neq = "!=" .
    52  newline = .
    53  octal_byte_value = "\\" octal_digit octal_digit octal_digit .
    54  octal_digit = "0" … "7" .
    55  octal_lit = "0" { octal_digit } .
    56  oror = "||" .
    57  ql_parameter = ( "?" | "$" ) "1" … "9" { "0" … "9" } .
    58  raw_string_lit = "`" { unicode_char | newline } "`" .
    59  rsh = ">>" .
    60  rune_lit = "'" ( unicode_value | byte_value ) "'" .
    61  string_lit = raw_string_lit | interpreted_string_lit .
    62  unicode_char = .
    63  unicode_digit = .
    64  unicode_letter = .
    65  unicode_value = unicode_char
    66  	| little_u_value
    67  	| big_u_value
    68  	| escaped_char .
    69  
    70  AlterTableStmt = "ALTER" "TABLE" TableName (
    71  		  "ADD" ColumnDef
    72  		| "DROP" "COLUMN" ColumnName
    73  	  ) .
    74  Assignment = ColumnName "=" Expression .
    75  AssignmentList = Assignment { "," Assignment } [ "," ] .
    76  BeginTransactionStmt = "BEGIN" "TRANSACTION" .
    77  Call = "(" [ "*" | ExpressionList ] ")" .
    78  ColumnDef = ColumnName Type [
    79  		  "NOT" "NULL"
    80  		| Expression
    81  	  ] [ "DEFAULT" Expression ] .
    82  ColumnName = identifier .
    83  ColumnNameList = ColumnName { "," ColumnName } [ "," ] .
    84  CommitStmt = "COMMIT" .
    85  Conversion = Type "(" Expression ")" .
    86  CreateIndexStmt = "CREATE" [ "UNIQUE" ] "INDEX" [
    87  		 "IF" "NOT" "EXISTS"
    88  	  ] IndexName "ON" TableName "(" ExpressionList ")" .
    89  CreateTableStmt = "CREATE" "TABLE" [
    90  		 "IF" "NOT" "EXISTS"
    91  	  ] TableName "(" ColumnDef { "," ColumnDef } [ "," ] ")" .
    92  DeleteFromStmt = "DELETE" "FROM" TableName [ WhereClause ] .
    93  DropIndexStmt = "DROP" "INDEX" [ "IF" "EXISTS" ] IndexName .
    94  DropTableStmt = "DROP" "TABLE" [ "IF" "EXISTS" ] TableName .
    95  EmptyStmt = .
    96  ExplainStmt = "EXPLAIN" Statement .
    97  Expression = Term {
    98  		 ( oror | "OR" ) Term
    99  	  } .
   100  ExpressionList = Expression { "," Expression } [ "," ] .
   101  Factor = PrimaryFactor {
   102  		 (
   103  			  ge
   104  			| ">"
   105  			| le
   106  			| "<"
   107  			| neq
   108  			| eq
   109  			| "LIKE"
   110  		  ) PrimaryFactor
   111  	  } [ Predicate ] .
   112  Field = Expression [ "AS" identifier ] .
   113  FieldList = Field { "," Field } [ "," ] .
   114  GroupByClause = "GROUP BY" ColumnNameList .
   115  Index = "[" Expression "]" .
   116  IndexName = identifier .
   117  InsertIntoStmt = "INSERT" "INTO" TableName [
   118  		 "(" ColumnNameList ")"
   119  	  ] ( Values | SelectStmt ) .
   120  JoinClause = (
   121  		  "LEFT"
   122  		| "RIGHT"
   123  		| "FULL"
   124  	  ) [ "OUTER" ] "JOIN" RecordSet "ON" Expression .
   125  Limit = "Limit" Expression .
   126  Literal = "FALSE"
   127  	| "NULL"
   128  	| "TRUE"
   129  	| float_lit
   130  	| imaginary_lit
   131  	| int_lit
   132  	| rune_lit
   133  	| string_lit
   134  	| ql_parameter .
   135  Offset = "OFFSET" Expression .
   136  Operand = Literal
   137  	| QualifiedIdent
   138  	| "(" Expression ")" .
   139  OrderBy = "ORDER" "BY" ExpressionList [ "ASC" | "DESC" ] .
   140  Predicate = (
   141  		  [ "NOT" ] (
   142  			  "IN" "(" ExpressionList ")"
   143  			| "IN" "(" SelectStmt [ ";" ] ")"
   144  			| "BETWEEN" PrimaryFactor "AND" PrimaryFactor
   145  		  )
   146  		| "IS" [ "NOT" ] "NULL"
   147  	  ) .
   148  PrimaryExpression = Operand
   149  	| Conversion
   150  	| PrimaryExpression Index
   151  	| PrimaryExpression Slice
   152  	| PrimaryExpression Call .
   153  PrimaryFactor = PrimaryTerm {
   154  		 (
   155  			  "^"
   156  			| "|"
   157  			| "-"
   158  			| "+"
   159  		  ) PrimaryTerm
   160  	  } .
   161  PrimaryTerm = UnaryExpr {
   162  		 (
   163  			  andnot
   164  			| "&"
   165  			| lsh
   166  			| rsh
   167  			| "%"
   168  			| "/"
   169  			| "*"
   170  		  ) UnaryExpr
   171  	  } .
   172  QualifiedIdent = identifier [ "." identifier ] .
   173  RecordSet = (
   174  		  TableName
   175  		| "(" SelectStmt [ ";" ] ")"
   176  	  ) [ "AS" identifier ] .
   177  RecordSetList = RecordSet { "," RecordSet } [ "," ] .
   178  RollbackStmt = "ROLLBACK" .
   179  SelectStmt = "SELECT" [ "DISTINCT" ] ( "*" | FieldList ) [ "FROM" RecordSetList ] [ JoinClause ] [ WhereClause ] [ GroupByClause ] [ OrderBy ] [ Limit ] [ Offset ] .
   180  Slice = "[" [ Expression ] ":" [ Expression ] "]" .
   181  Statement = EmptyStmt
   182  	| AlterTableStmt
   183  	| BeginTransactionStmt
   184  	| CommitStmt
   185  	| CreateIndexStmt
   186  	| CreateTableStmt
   187  	| DeleteFromStmt
   188  	| DropIndexStmt
   189  	| DropTableStmt
   190  	| InsertIntoStmt
   191  	| RollbackStmt
   192  	| SelectStmt
   193  	| TruncateTableStmt
   194  	| UpdateStmt
   195  	| ExplainStmt .
   196  StatementList = Statement { ";" Statement } .
   197  TableName = identifier .
   198  Term = Factor {
   199  		 ( andand | "AND" ) Factor
   200  	  } .
   201  TruncateTableStmt = "TRUNCATE" "TABLE" TableName .
   202  Type = "bigint"
   203  	| "bigrat"
   204  	| "blob"
   205  	| "bool"
   206  	| "byte"
   207  	| "complex128"
   208  	| "complex64"
   209  	| "duration"
   210  	| "float"
   211  	| "float32"
   212  	| "float64"
   213  	| "int"
   214  	| "int16"
   215  	| "int32"
   216  	| "int64"
   217  	| "int8"
   218  	| "rune"
   219  	| "string"
   220  	| "time"
   221  	| "uint"
   222  	| "uint16"
   223  	| "uint32"
   224  	| "uint64"
   225  	| "uint8" .
   226  UnaryExpr = [
   227  		  "^"
   228  		| "!"
   229  		| "-"
   230  		| "+"
   231  	  ] PrimaryExpression .
   232  UpdateStmt = "UPDATE" TableName [ "SET" ] AssignmentList [ WhereClause ] .
   233  Values = "VALUES" "(" ExpressionList ")" {
   234  		 "," "(" ExpressionList ")"
   235  	  } [ "," ] .
   236  WhereClause = "WHERE" Expression
   237  	| "WHERE" "EXISTS" "(" SelectStmt ")"
   238  	| "WHERE" "NOT" "EXISTS" "(" SelectStmt ")" .