~juan457/+junk/zorba

« back to all changes in this revision

Viewing changes to src/compiler/parser/xquery_parser.y

  • Committer: Markos Zaharioudakis
  • Date: 2012-07-11 15:38:39 UTC
  • mfrom: (10924 zorba)
  • mto: This revision was merged to the branch mainline in revision 10932.
  • Revision ID: markos_za@yahoo.com-20120711153839-0mkh15cg2ubknchd
work in progress

Show diffs side-by-side

added added

removed removed

Lines of Context:
1964
1964
                                                    $1,
1965
1965
                                                    dynamic_cast<OccurrenceIndicator*>($2)));
1966
1966
    }
1967
 
;
 
1967
  | JSONTest
 
1968
    {
 
1969
      $$ = static_cast<parsenode*>(new SequenceType(LOC(@$), $1, NULL));
 
1970
    }
 
1971
  | JSONTest OccurrenceIndicator
 
1972
    {
 
1973
      $$ = static_cast<parsenode*>(new SequenceType(LOC(@$),
 
1974
                                                    $1,
 
1975
                                                    dynamic_cast<OccurrenceIndicator*>($2)));
 
1976
 
 
1977
    };
1968
1978
 
1969
1979
 
1970
1980
IndexDecl :
6476
6486
    ;
6477
6487
 
6478
6488
JSONInsertExpr :
6479
 
        INSERT JSON JSONPairList INTO ExprSingle
 
6489
        INSERT JSON LBRACE JSONPairList RBRACE INTO ExprSingle
6480
6490
        {
6481
6491
          $$ = new JSONObjectInsertExpr(LOC(@$),
6482
 
                                        static_cast<JSONPairList*>($3),
6483
 
                                        $5);
 
6492
                                        static_cast<JSONPairList*>($4),
 
6493
                                        $7);
6484
6494
        }
6485
6495
    |   INSERT JSON ExprSingle INTO ExprSingle AT POSITION ExprSingle
6486
6496
        {
6489
6499
    ;
6490
6500
 
6491
6501
JSONAppendExpr :
6492
 
        APPEND JSON ExprSingle TO ExprSingle
 
6502
        APPEND JSON LBRACK Expr RBRACK TO ExprSingle
6493
6503
        {
6494
 
          $$ = new JSONArrayAppendExpr(LOC(@$), $3, $5);
 
6504
          $$ = new JSONArrayAppendExpr(LOC(@$), $4, $7);
6495
6505
        }
6496
6506
    ;
6497
6507
 
6498
6508
JSONDeleteExpr :
6499
 
        _DELETE JSON PrimaryExpr LPAR ExprSingle RPAR
 
6509
        _DELETE JSON FilterExpr
6500
6510
        {
6501
 
          $$ = new JSONDeleteExpr(LOC(@$), $3, $5);
 
6511
          rchandle<DynamicFunctionInvocation> lDynamicFunctionInvocation = 
 
6512
          dynamic_cast<DynamicFunctionInvocation*>($3);
 
6513
 
 
6514
          if (lDynamicFunctionInvocation == NULL)
 
6515
          {
 
6516
            error(@3, "An object invocation is expected. A filter was found instead.");
 
6517
            YYERROR;
 
6518
          }
 
6519
 
 
6520
          rchandle<exprnode> lPrimaryExpr =
 
6521
          lDynamicFunctionInvocation->getPrimaryExpr().release();
 
6522
 
 
6523
          rchandle<ArgList> lArgList =
 
6524
          lDynamicFunctionInvocation->getArgList().release();
 
6525
 
 
6526
          if (lArgList->size() != 1)
 
6527
          {
 
6528
            error(@3, "An object invocation with exactly one argument is expected. Zero or more than one argument were found.");
 
6529
            YYERROR;
 
6530
          }
 
6531
 
 
6532
          rchandle<exprnode> lKey = (*lArgList)[0].release();
 
6533
          $$ = new JSONDeleteExpr(LOC(@$), lPrimaryExpr.release(), lKey.release());
6502
6534
        }
6503
6535
    ;
6504
6536
 
6505
6537
JSONRenameExpr :
6506
 
        RENAME JSON PrimaryExpr LPAR ExprSingle RPAR AS ExprSingle
 
6538
        RENAME JSON FilterExpr AS ExprSingle
6507
6539
        {
6508
 
          $$ = new JSONRenameExpr(LOC(@$), $3, $5, $8);
 
6540
          rchandle<DynamicFunctionInvocation> lDynamicFunctionInvocation = 
 
6541
          dynamic_cast<DynamicFunctionInvocation*>($3);
 
6542
 
 
6543
          if(lDynamicFunctionInvocation == NULL) 
 
6544
          {
 
6545
            error(@3, "An object invocation is expected. A filter was found instead.");
 
6546
            YYERROR;
 
6547
          }
 
6548
 
 
6549
          rchandle<exprnode> lPrimaryExpr =
 
6550
          lDynamicFunctionInvocation->getPrimaryExpr().release();
 
6551
 
 
6552
          rchandle<ArgList> lArgList =
 
6553
          lDynamicFunctionInvocation->getArgList().release();
 
6554
 
 
6555
          if (lArgList->size() != 1)
 
6556
          {
 
6557
            error(@3, "An object invocation with exactly one argument is expected. Zero or more than one argument were found.");
 
6558
            YYERROR;
 
6559
          }
 
6560
 
 
6561
          rchandle<exprnode> lKey = (*lArgList)[0].release();
 
6562
          $$ = new JSONRenameExpr(LOC(@$), lPrimaryExpr.release(), lKey.release(), $5);
6509
6563
        }
6510
6564
    ;
6511
6565
 
6512
6566
JSONReplaceExpr :
6513
 
        REPLACE JSON VALUE OF PrimaryExpr LPAR ExprSingle RPAR WITH ExprSingle
 
6567
        REPLACE JSON VALUE OF FilterExpr WITH ExprSingle
6514
6568
        {
6515
 
          $$ = new JSONReplaceExpr(LOC(@$), $5, $7, $10);
 
6569
          rchandle<DynamicFunctionInvocation> lDynamicFunctionInvocation = 
 
6570
          dynamic_cast<DynamicFunctionInvocation*>($5);
 
6571
 
 
6572
          if(lDynamicFunctionInvocation == NULL) 
 
6573
          {
 
6574
            error(@3, "An object invocation is expected. A filter was found instead.");
 
6575
            YYERROR;
 
6576
          }
 
6577
 
 
6578
          rchandle<exprnode> lPrimaryExpr =
 
6579
          lDynamicFunctionInvocation->getPrimaryExpr().release();
 
6580
 
 
6581
          rchandle<ArgList> lArgList =
 
6582
          lDynamicFunctionInvocation->getArgList().release();
 
6583
 
 
6584
          if (lArgList->size() != 1)
 
6585
          {
 
6586
            error(@3, "An object invocation with exactly one argument is expected. Zero or more than one argument were found.");
 
6587
            YYERROR;
 
6588
          }
 
6589
 
 
6590
          rchandle<exprnode> lKey = (*lArgList)[0].release();
 
6591
          $$ = new JSONReplaceExpr(LOC(@$), lPrimaryExpr.release(), lKey.release(), $7);
6516
6592
        }
6517
6593
    ;
6518
6594