[yaala] YAQL syntax.
Макс
yaala@verplant.org
Mon, 10 Mar 2003 22:56:51 +0600
Here is main ideas about syntax of query statements.
I tried to make it close to SQL and quite readable (intuitively clean).
Basic idea is object/properties paradigm:
Each (sub)expression defines some property of YAQL object
(either Definition, or Arrangament).
Data expression defined just as any expression in SQL or any other language.
Properties (attributes) are applied using special operators with keywords, like in
SQL.
Sinplified grammar of YAQL:
DefinitionExpr :=
DataExpression
DefinitionExpr : TypeSpec /* type specification */
DefinitionExpr : FormatSpec /* splitf-ike formatting */
DefinitionExpr AS Label
DefinitionExpr WITH Expr /* input filter */
SelectionExpr :=
DefinitionExpr FOR ArrangementExpr
SelectionExpr WHERE Expr /* output filter */
SelectionExrr SORT ExprList /* sort order */
SelectionStatement :=
SELECT SelectionExpr;
These rules allows to concatenate several attribute operators.
Egg:
SELECT amount = SUM(bytes) AS "Amount of downloaded" :number :"%'d"
FOR clients WHERE amount > 1024 SORT amount;
It may (and will) be conenient to apply attributes to several (or all)
statements, not to each separately.
I see 3 ways of making this.
1. using grouping brackets:
( DefinitionExprList ) AttributeOperator
2. applying attribute to void expr after list of expr:
DefinitionExprList, AttributeOperator
3. using 'alternative' attrributes semantic:
DefinitionExprList, AttributeOperatorList
Latter rule make the following interpretation:
expr1, expr2, attr1, attr2
=> (expr1, expr2) attr1, (expr1, expr2) attr2
This maybe very usefull to making that, what i call once 'keyvar
separation).
Egg, for some hypotetical iptraffic accounting log:
SELECT SUM(bytes), COUNT(clients),
WITH direction == 'outgoing' AS "Outgoing",
WITH direction == 'incoming' AS "Incoming"
Third rule may be also applied to 'FOR-operator':
SELECT some_data_definitions,
FOR arrangement1,
FOR arrangement2;
And finally, ArrangementExpr:
ArrangementExpr :=
KeyVarList
ArrangementExpr / KeyVarList
KeyVarList :=
<empty>
=
KeyVarDef
KeyVarList, KeyVarDef
KeyVarDef := may be attributed with label or format (with AS or ':' operators)
This defines list of expressions (or variables), separated with commas
or '/'. The '/' splits whole list into rows/columns/tables/pages
grouping.
Empty sublist denotes to put data variables there.
Otherwise '=' is used to put datavars into user-specified splitting.
--
qMax