52 |
52 |
53 /** |
53 /** |
54 * Enumeration of possible expression operators. |
54 * Enumeration of possible expression operators. |
55 */ |
55 */ |
56 typedef enum { |
56 typedef enum { |
57 DAVQL_NOOP, |
57 DAVQL_NOOP, DAVQL_CALL, DAVQL_ARGLIST, // internal representations |
58 DAVQL_ADD, DAVQL_SUB, DAVQL_MUL, DAVQL_DIV, |
58 DAVQL_ADD, DAVQL_SUB, DAVQL_MUL, DAVQL_DIV, |
59 DAVQL_AND, DAVQL_OR, DAVQL_XOR, DAVQL_NEG, |
59 DAVQL_AND, DAVQL_OR, DAVQL_XOR, DAVQL_NEG, // airthmetic |
60 DAVQL_NOT, DAVQL_LAND, DAVQL_LOR, DAVQL_LXOR, |
60 DAVQL_NOT, DAVQL_LAND, DAVQL_LOR, DAVQL_LXOR, // logical |
61 DAVQL_EQ, DAVQL_NEQ, DAVQL_LT, DAVQL_GT, DAVQL_LE, DAVQL_GE, |
61 DAVQL_EQ, DAVQL_NEQ, DAVQL_LT, DAVQL_GT, DAVQL_LE, DAVQL_GE, |
62 DAVQL_LIKE, DAVQL_UNLIKE |
62 DAVQL_LIKE, DAVQL_UNLIKE // comparisons |
63 } davqloperator_t; |
63 } davqloperator_t; |
64 |
64 |
65 /** |
65 /** |
66 * An expression within a DAVQL query. |
66 * An expression within a DAVQL query. |
67 */ |
67 */ |
108 * Expression = Expression, BinaryOperator, Expression |
108 * Expression = Expression, BinaryOperator, Expression |
109 * | UnaryOperator, Expression |
109 * | UnaryOperator, Expression |
110 * | FunctionCall | Identifier | Literal |
110 * | FunctionCall | Identifier | Literal |
111 * | "(", Expression, ")"; |
111 * | "(", Expression, ")"; |
112 * |
112 * |
113 * FunctionCall = Identifier, "(", Expression, ")"; |
113 * FunctionCall = Identifier, "(", ArgumentList, ")"; |
|
114 * ArgumentList = Expression, {",", Expression}; |
114 * Identifier = IdentifierChar - ?Digit?, {IdentifierChar} |
115 * Identifier = IdentifierChar - ?Digit?, {IdentifierChar} |
115 * | "`", ?Character?, {?Character?}, "`"; |
116 * | "`", ?Character?, {?Character?}, "`"; |
116 * IdentifierChar = ?Character - (" "|",")?; |
117 * IdentifierChar = ?Character - (" "|",")?; |
117 * Literal = Number | String; |
118 * Literal = Number | String; |
118 * Number = ?Digit?, {?Digit?} | "%d"; |
119 * Number = ?Digit?, {?Digit?} | "%d"; |
132 * FieldExpressions = "*", {",", Expression, " as ", String} |
133 * FieldExpressions = "*", {",", Expression, " as ", String} |
133 * | FieldExpression, {",", FieldExpression} |
134 * | FieldExpression, {",", FieldExpression} |
134 * | "-"; |
135 * | "-"; |
135 * FieldExpression = Identifier |
136 * FieldExpression = Identifier |
136 * | Expression, " as ", String; |
137 * | Expression, " as ", String; |
137 * SetExpressions = SetExpression, {",", {SetExpressions}; |
138 * SetExpressions = SetExpression, {",", SetExpressions}; |
138 * SetExpression = Identifier, "=", Expression; |
139 * SetExpression = Identifier, "=", Expression; |
139 * |
140 * |
140 * WithClause = "depth", "=", (Number | "infinity"); |
141 * WithClause = "depth", "=", (Number | "infinity"); |
|
142 * |
|
143 * OrderByClause = OrderByCriterion, {",", OrderByCriterion}; |
|
144 * OrderByCriterion = (Identifier | Number), [" asc"|" desc"]; |
141 * |
145 * |
142 * </pre> |
146 * </pre> |
143 * |
147 * |
144 * Note: mandatory spaces are part of the grammar. But you may also insert an |
148 * Note: mandatory spaces are part of the grammar. But you may also insert an |
145 * arbitrary amount of optional spaces between two symbols if they are not part |
149 * arbitrary amount of optional spaces between two symbols if they are not part |
147 * |
151 * |
148 * <b>GET:</b> |
152 * <b>GET:</b> |
149 * <pre> |
153 * <pre> |
150 * GetStatement = "get ", FieldExpressions, |
154 * GetStatement = "get ", FieldExpressions, |
151 * " from ", Identifier, |
155 * " from ", Identifier, |
|
156 * [" with ", WithClause], |
152 * [" where ", LogicalExpression], |
157 * [" where ", LogicalExpression], |
153 * [" with ", WithClause]; |
158 * [" order by ", OrderByClause]; |
154 * </pre> |
159 * </pre> |
155 * |
160 * |
156 * <b>SET:</b> |
161 * <b>SET:</b> |
157 * <pre> |
162 * <pre> |
158 * "set ",SetExpressions, |
163 * "set ",SetExpressions, |
159 * " at ", Identifier, |
164 * " at ", Identifier, |
160 * (" where ", LogicalExpression) | " anywhere", |
165 * [" with ", WithClause], |
161 * [" with ", WithClause]; |
166 * (" where ", LogicalExpression) | " anywhere"; |
162 * </pre> |
167 * </pre> |
163 * |
168 * |
164 */ |
169 */ |
165 typedef struct { |
170 typedef struct { |
166 /** |
171 /** |