~zorba-coders/zorba/ebnf

« back to all changes in this revision

Viewing changes to zorba.ebnf

  • Committer: William Candillon
  • Date: 2012-02-15 14:55:38 UTC
  • Revision ID: william.candillon@28msec.com-20120215145538-r66fglir66nu3zj2
Add Scripting syntax.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
VersionDecl
4
4
         ::= 'xquery' ( 'encoding' StringLiteral | 'version' StringLiteral ( 'encoding' StringLiteral )? ) Separator
5
5
MainModule
6
 
         ::= Prolog QueryBody
 
6
         ::= Prolog Program
7
7
LibraryModule
8
8
         ::= ModuleDecl Prolog
9
9
ModuleDecl
77
77
ContextItemDecl
78
78
         ::= 'declare' 'context' 'item' ( 'as' ItemType )? ( ':=' VarValue | 'external' ( ':=' VarDefaultValue )? )
79
79
FunctionDecl
80
 
         ::= 'function' EQName '(' ParamList? ')' ( 'as' SequenceType )? ( FunctionBody | 'external' )
 
80
         ::= "function" EQName "(" ParamList? ")" ("as" SequenceType)? ("{" StatementsAndOptionalExpr "}" | "external")
81
81
ParamList
82
82
         ::= Param ( ',' Param )*
83
83
Param    ::= '$' EQName TypeDeclaration?
90
90
QueryBody
91
91
         ::= Expr
92
92
Expr     ::= ExprSingle ( ',' ExprSingle )*
93
 
ExprSingle
94
 
         ::= FLWORExpr
95
 
           | QuantifiedExpr
96
 
           | SwitchExpr
97
 
           | TypeswitchExpr
98
 
           | IfExpr
99
 
           | TryCatchExpr
100
 
           | InsertExpr
101
 
           | DeleteExpr
102
 
           | RenameExpr
103
 
           | ReplaceExpr
104
 
           | TransformExpr
105
 
           | OrExpr
 
93
 
 
94
ExprSingle ::=
 
95
      ExprSimple
 
96
  |   FLWORExpr
 
97
  |   IfExpr
 
98
  |   SwitchExpr
 
99
  |   TryCatchExpr
 
100
  |   TypeswitchExpr
 
101
    
 
102
ExprSimple ::=
 
103
      QuantifiedExpr
 
104
  |   OrExpr
 
105
  |   InsertExpr
 
106
  |   DeleteExpr
 
107
  |   RenameExpr
 
108
  |   ReplaceExpr
 
109
  |   TransformExpr    
 
110
 
106
111
FLWORExpr
107
112
         ::= InitialClause IntermediateClause* ReturnClause
108
113
InitialClause
351
356
           | CharRef
352
357
           | '{{'
353
358
           | '}}'
354
 
           | EnclosedExpr
 
359
           | BlockExpr
355
360
DirCommentConstructor
356
361
         ::= '<!--' DirCommentContents '-->'
357
362
          /* ws: explicit */
370
375
           | CompCommentConstructor
371
376
           | CompPIConstructor
372
377
CompDocConstructor
373
 
         ::= 'document' '{' Expr '}'
 
378
         ::= 'document' '{' BlockExpr '}'
374
379
CompElemConstructor
375
380
         ::= 'element' ( EQName | '{' Expr '}' ) '{' ContentExpr? '}'
376
381
ContentExpr
377
 
         ::= Expr
 
382
         ::= StatementsAndExpr
378
383
CompAttrConstructor
379
 
         ::= 'attribute' ( EQName | '{' Expr '}' ) '{' Expr? '}'
 
384
         ::= "attribute" (EQName | ("{" Expr "}")) ("{" "}" | BlockExpr)
380
385
CompNamespaceConstructor
381
386
         ::= 'namespace' ( Prefix | '{' PrefixExpr '}' ) '{' URIExpr? '}'
382
387
Prefix   ::= NCName
384
389
         ::= Expr
385
390
URIExpr  ::= Expr
386
391
CompTextConstructor
387
 
         ::= 'text' '{' Expr '}'
 
392
         ::= 'text' '{' BlockExpr '}'
388
393
CompCommentConstructor
389
 
         ::= 'comment' '{' Expr '}'
 
394
         ::= 'comment' '{' BlockExpr '}'
390
395
CompPIConstructor
391
 
         ::= 'processing-instruction' ( NCName | '{' Expr '}' ) '{' Expr? '}'
 
396
         ::= "processing-instruction" (NCName | ("{" Expr "}")) ("{" "}" | BlockExpr)
392
397
FunctionItemExpr
393
398
         ::= LiteralFunctionItem
394
399
           | InlineFunction
616
621
TransformExpr
617
622
         ::= "copy" "$" VarName ":=" ExprSingle ("," "$" VarName ":=" ExprSingle)* "modify" ExprSingle "return" ExprSingle
618
623
 
 
624
Program ::= StatementsAndOptionalExpr
 
625
          
 
626
Statements ::= Statement*
 
627
      
 
628
StatementsAndExpr ::= Statements Expr
 
629
      
 
630
StatementsAndOptionalExpr ::= Statements1 Expr?
 
631
 
 
632
Statement ::= Statement1 | Statement2
 
633
 
 
634
Statement1 ::=
 
635
   AssignStatement
 
636
 | BlockStatement
 
637
 | BreakStatement
 
638
 | ContinueStatement
 
639
 | ExitStatement
 
640
 | VarDeclStatement
 
641
 | WhileStatement
 
642
 
 
643
Statement2 ::=
 
644
   ApplyStatement
 
645
 | FLWORStatement
 
646
 | IfStatement
 
647
 | SwitchStatement
 
648
 | TryCatchStatement
 
649
 | TypeswitchStatement
 
650
 
 
651
Statements1 ::= Statement1*
 
652
 
 
653
ApplyStatement ::= ExprSimple ";"
 
654
AssignStatement ::= "$" VarName ":=" ExprSingle ";"
 
655
BlockStatement ::= "{" Statements "}"
 
656
BreakStatement ::= "break" "loop" ";"
 
657
ContinueStatement ::= "continue" "loop" ";"
 
658
ExitStatement ::= "exit" "returning" ExprSingle ";"
 
659
FLWORStatement ::= InitialClause IntermediateClause* ReturnStatement
 
660
ReturnStatement ::= "return" Statement
 
661
IfStatement ::= "if" "(" Expr ")" "then" Statement "else" Statement
 
662
SwitchStatement ::= "switch" "(" Expr ")" SwitchCaseStatement+ "default" "return" Statement
 
663
SwitchCaseStatement ::= ("case" SwitchCaseOperand)+ "return" Statement
 
664
TryCatchStatement ::= "try" BlockStatement ("catch" CatchErrorList BlockStatement)+
 
665
TypeswitchStatement ::= "typeswitch" "(" Expr ")" CaseStatement+ "default" ("$" VarName)? "return" Statement          
 
666
CaseStatement ::= "case" ("$" VarName "as")? SequenceType "return" Statement          
 
667
VarDeclStatement ::= Annotation* "variable" "$" VarName TypeDeclaration? (":=" ExprSingle)?
 
668
    ("," "$" VarName TypeDeclaration? (":=" ExprSingle)?)* ";"
 
669
WhileStatement ::= "while" "(" Expr ")" Statement
 
670
 
 
671
BlockExpr ::= "{" StatementsAndExpr "}"
619
672
 
620
673
<?TOKENS?>
621
674
 
720
773
           | ( ( [^(:] | '('+ [^(:] | ':'+ [^:)] )+ | ':' ) ':'* &':'
721
774
'*'       << Wildcard '*'^OccurrenceIndicator
722
775
EQName^Token
723
 
          << 'ancestor' 'ancestor-or-self' 'and' 'ascending' 'attribute' 'case' 'cast' 'castable' 'child' 'collation' 'comment' 'count' 'declare' 'default' 'descendant' 'descendant-or-self' 'descending' 'div' 'document' 'document-node' 'element' 'else' 'empty' 'empty-sequence' 'end' 'eq' 'every' 'except' 'following' 'following-sibling' 'for' 'function' 'ge' 'group' 'gt' 'idiv' 'if' 'import' 'instance' 'intersect' 'is' 'item' 'le' 'let' 'lt' 'mod' 'module' 'namespace' 'namespace-node' 'ne' 'node' 'only' 'or' 'order' 'ordered' 'parent' 'preceding' 'preceding-sibling' 'processing-instruction' 'return' 'satisfies' 'schema-attribute' 'schema-element' 'self' 'some' 'stable' 'start' 'switch' 'text' 'to' 'treat' 'try' 'typeswitch' 'union' 'unordered' 'validate' 'where' 'xquery' "after" "as" "before" "copy" "delete" "insert" "into" "modify" "rename" "replace" "with"
 
776
          << 'ancestor' 'ancestor-or-self' 'and' 'ascending' 'attribute' 'case' 'cast' 'castable' 'child' 'collation' 'comment' 'count' 'declare' 'default' 'descendant' 'descendant-or-self' 'descending' 'div' 'document' 'document-node' 'element' 'else' 'empty' 'empty-sequence' 'end' 'eq' 'every' 'except' 'following' 'following-sibling' 'for' 'function' 'ge' 'group' 'gt' 'idiv' 'if' 'import' 'instance' 'intersect' 'is' 'item' 'le' 'let' 'lt' 'mod' 'module' 'namespace' 'namespace-node' 'ne' 'node' 'only' 'or' 'order' 'ordered' 'parent' 'preceding' 'preceding-sibling' 'processing-instruction' 'return' 'satisfies' 'schema-attribute' 'schema-element' 'self' 'some' 'stable' 'start' 'switch' 'text' 'to' 'treat' 'try' 'typeswitch' 'union' 'unordered' 'validate' 'where' 'xquery' "after" "as" "before" "copy" "delete" "insert" "into" "modify" "rename" "replace" "with" "break" "catch" "continue" "exit" "variable" "while"
724
777
NCName^Token
725
778
          << 'and' 'ascending' 'case' 'cast' 'castable' 'collation' 'count' 'default' 'descending' 'div' 'else' 'empty' 'end' 'eq' 'except' 'for' 'ge' 'group' 'gt' 'idiv' 'instance' 'intersect' 'is' 'le' 'let' 'lt' 'mod' 'ne' 'only' 'or' 'order' 'return' 'satisfies' 'stable' 'start' 'to' 'treat' 'union' 'where' "after" "as" "before" "into" "modify" "with"