Esempio n. 1
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  ParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  **
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
  ** without this code, their parser segfaults.  I'm not sure what there
  ** parser is doing to make this happen.  This is the second bug report
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
  ** that it has not been previously stressed...  (SQLite ticket #2172)
  */
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  yygotominor = yyzerominor;


  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 4: /* decl ::= REPORT TO STR */
#line 22 "cfg.y"
{set_report(ps,yymsp[0].minor.yy0);}
#line 739 "cfg.c"
        break;
      case 5: /* decl ::= LISTEN ON STR */
#line 23 "cfg.y"
{set_listen(ps,yymsp[0].minor.yy0);}
#line 744 "cfg.c"
        break;
      case 6: /* job ::= JOB LCURLY sbody RCURLY */
#line 24 "cfg.y"
{push_job(ps);}
#line 749 "cfg.c"
        break;
      case 9: /* kv ::= NAME STR */
#line 27 "cfg.y"
{set_name(ps,yymsp[0].minor.yy0);}
#line 754 "cfg.c"
        break;
      case 11: /* kv ::= DIR path */
#line 29 "cfg.y"
{set_dir(ps,yymsp[0].minor.yy0);}
#line 759 "cfg.c"
        break;
      case 12: /* kv ::= OUT path */
#line 30 "cfg.y"
{set_out(ps,yymsp[0].minor.yy0);}
#line 764 "cfg.c"
        break;
      case 13: /* kv ::= IN path */
#line 31 "cfg.y"
{set_in(ps,yymsp[0].minor.yy0);}
#line 769 "cfg.c"
        break;
      case 14: /* kv ::= ERR path */
#line 32 "cfg.y"
{set_err(ps,yymsp[0].minor.yy0);}
#line 774 "cfg.c"
        break;
      case 15: /* kv ::= USER STR */
#line 33 "cfg.y"
{set_user(ps,yymsp[0].minor.yy0);}
#line 779 "cfg.c"
        break;
      case 16: /* kv ::= ORDER STR */
#line 34 "cfg.y"
{set_ord(ps,yymsp[0].minor.yy0);}
#line 784 "cfg.c"
        break;
      case 17: /* kv ::= ENV STR */
#line 35 "cfg.y"
{set_env(ps,yymsp[0].minor.yy0);}
#line 789 "cfg.c"
        break;
      case 18: /* kv ::= ULIMIT STR STR */
      case 34: /* pairs ::= pairs STR STR */ yytestcase(yyruleno==34);
#line 36 "cfg.y"
{set_ulimit(ps,yymsp[-1].minor.yy0,yymsp[0].minor.yy0);}
#line 795 "cfg.c"
        break;
      case 20: /* kv ::= DISABLED */
#line 38 "cfg.y"
{set_dis(ps);  }
#line 800 "cfg.c"
        break;
      case 21: /* kv ::= WAIT */
#line 39 "cfg.y"
{set_wait(ps); }
#line 805 "cfg.c"
        break;
      case 22: /* kv ::= ONCE */
#line 40 "cfg.y"
{set_once(ps); }
#line 810 "cfg.c"
        break;
      case 23: /* kv ::= BOUNCE EVERY STR */
#line 41 "cfg.y"
{set_bounce(ps,yymsp[0].minor.yy0);}
#line 815 "cfg.c"
        break;
      case 25: /* cmd ::= path */
#line 43 "cfg.y"
{set_cmd(ps,yymsp[0].minor.yy0);}
#line 820 "cfg.c"
        break;
      case 26: /* cmd ::= path args */
#line 44 "cfg.y"
{set_cmd(ps,yymsp[-1].minor.yy0);}
#line 825 "cfg.c"
        break;
      case 27: /* path ::= STR */
      case 30: /* arg ::= STR */ yytestcase(yyruleno==30);
#line 45 "cfg.y"
{yygotominor.yy0=yymsp[0].minor.yy0;}
#line 831 "cfg.c"
        break;
      case 28: /* args ::= args arg */
      case 29: /* args ::= arg */ yytestcase(yyruleno==29);
#line 46 "cfg.y"
{utarray_push_back(&ps->job->cmdv,&yymsp[0].minor.yy0);}
#line 837 "cfg.c"
        break;
      case 31: /* arg ::= QUOTEDSTR */
#line 49 "cfg.y"
{yygotominor.yy0=unquote(yymsp[0].minor.yy0);}
#line 842 "cfg.c"
        break;
      case 32: /* paths ::= paths path */
      case 33: /* paths ::= path */ yytestcase(yyruleno==33);
#line 50 "cfg.y"
{utarray_push_back(&ps->job->depv,&yymsp[0].minor.yy0);}
#line 848 "cfg.c"
        break;
      default:
      /* (0) file ::= decls */ yytestcase(yyruleno==0);
      /* (1) decls ::= decls job */ yytestcase(yyruleno==1);
      /* (2) decls ::= decls decl */ yytestcase(yyruleno==2);
      /* (3) decls ::= */ yytestcase(yyruleno==3);
      /* (7) sbody ::= sbody kv */ yytestcase(yyruleno==7);
      /* (8) sbody ::= kv */ yytestcase(yyruleno==8);
      /* (10) kv ::= CMD cmd */ yytestcase(yyruleno==10);
      /* (19) kv ::= ULIMIT LCURLY pairs RCURLY */ yytestcase(yyruleno==19);
      /* (24) kv ::= DEPENDS LCURLY paths RCURLY */ yytestcase(yyruleno==24);
      /* (35) pairs ::= */ yytestcase(yyruleno==35);
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  if( yyact < YYNSTATE ){
#ifdef NDEBUG
    /* If we are not debugging and the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = (YYACTIONTYPE)yyact;
      yymsp->major = (YYCODETYPE)yygoto;
      yymsp->minor = yygotominor;
    }else
#endif
    {
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YYNSTATE + YYNRULE + 1 );
    yy_accept(yypParser);
  }
}
Esempio n. 2
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  ParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  **
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
  ** without this code, their parser segfaults.  I'm not sure what there
  ** parser is doing to make this happen.  This is the second bug report
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
  ** that it has not been previously stressed...  (SQLite ticket #2172)
  */
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  yygotominor = yyzerominor;


  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0: /* module ::= statements */
      case 1: /* statements ::= statement */
      case 2: /* statements ::= statements statement */
      case 34: /* element ::= operation */
      case 35: /* element ::= directive */
      case 38: /* element ::= */
      case 39: /* statements ::= statements error statement */
#line 56 "grammar.y"
{
}
#line 747 "grammar.c"
        break;
      case 3: /* statement ::= directive EOL */
      case 4: /* statement ::= constant EOL */
      case 5: /* statement ::= function EOL */
      case 6: /* statement ::= EOL */
      case 32: /* block ::= element EOL */
      case 33: /* block ::= block element EOL */
#line 61 "grammar.y"
{
  yy_destructor(1,&yymsp[0].minor);
}
#line 759 "grammar.c"
        break;
      case 7: /* constant ::= IDENT EQ expr */
#line 66 "grammar.y"
{
         Module_create_constant(state, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); free(yymsp[-2].minor.yy0);
      yy_destructor(3,&yymsp[-1].minor);
}
#line 767 "grammar.c"
        break;
      case 8: /* parameters ::= LPAREN args RPAREN */
#line 70 "grammar.y"
{ yygotominor.yy7 = yymsp[-1].minor.yy7;   yy_destructor(4,&yymsp[-2].minor);
  yy_destructor(5,&yymsp[0].minor);
}
#line 774 "grammar.c"
        break;
      case 9: /* parameters ::= */
      case 12: /* args ::= */
#line 71 "grammar.y"
{ yygotominor.yy7 = calloc(1,sizeof(Parameters)); }
#line 780 "grammar.c"
        break;
      case 10: /* args ::= args COMMA expr */
#line 73 "grammar.y"
{ yymsp[-2].minor.yy7->args[yymsp[-2].minor.yy7->i++] = yymsp[0].minor.yy0; yygotominor.yy7=yymsp[-2].minor.yy7;   yy_destructor(6,&yymsp[-1].minor);
}
#line 786 "grammar.c"
        break;
      case 11: /* args ::= expr */
#line 74 "grammar.y"
{ yygotominor.yy7 = calloc(1,sizeof(Parameters)); yygotominor.yy7->args[yygotominor.yy7->i++] = yymsp[0].minor.yy0;}
#line 791 "grammar.c"
        break;
      case 13: /* operation ::= OP DOT TYPE parameters */
#line 78 "grammar.y"
{ Call_operation(state, state->current, yymsp[-3].minor.yy0, yymsp[-1].minor.yy0, yymsp[0].minor.yy7);   yy_destructor(8,&yymsp[-2].minor);
}
#line 797 "grammar.c"
        break;
      case 14: /* operation ::= OP parameters */
#line 81 "grammar.y"
{ Call_operation(state, state->current, yymsp[-1].minor.yy0, NULL, yymsp[0].minor.yy7); }
#line 802 "grammar.c"
        break;
      case 15: /* expr ::= HEX */
      case 16: /* expr ::= FLOAT */
      case 17: /* expr ::= INT */
      case 18: /* expr ::= STR */
      case 19: /* expr ::= CHR */
      case 20: /* expr ::= REG */
#line 83 "grammar.y"
{ yygotominor.yy0 = yymsp[0].minor.yy0; }
#line 812 "grammar.c"
        break;
      case 21: /* expr ::= IDENT */
#line 89 "grammar.y"
{ yygotominor.yy0 = Module_resolve_data(state, yymsp[0].minor.yy0); }
#line 817 "grammar.c"
        break;
      case 22: /* expr ::= function_reference */
#line 90 "grammar.y"
{ yygotominor.yy0 = yymsp[0].minor.yy52; }
#line 822 "grammar.c"
        break;
      case 23: /* expr ::= function_reference DOT IDENT */
#line 92 "grammar.y"
{ yygotominor.yy0 = Module_outside_function_data(state, yymsp[-2].minor.yy52, yymsp[0].minor.yy0);   yy_destructor(8,&yymsp[-1].minor);
}
#line 828 "grammar.c"
        break;
      case 24: /* expr ::= LABEL */
#line 95 "grammar.y"
{ yygotominor.yy0 = Label_expression(state->current, yymsp[0].minor.yy0); }
#line 833 "grammar.c"
        break;
      case 25: /* function_reference ::= IDENT DOT IDENT */
#line 99 "grammar.y"
{ yygotominor.yy52 = Module_resolve_function(state, yymsp[-2].minor.yy0, yymsp[0].minor.yy0);   yy_destructor(8,&yymsp[-1].minor);
}
#line 839 "grammar.c"
        break;
      case 26: /* directive ::= PERCENT IDENT parameters */
#line 102 "grammar.y"
{ Module_call_directive(state, yymsp[-1].minor.yy0, yymsp[0].minor.yy7);   yy_destructor(17,&yymsp[-2].minor);
}
#line 845 "grammar.c"
        break;
      case 27: /* function ::= FUNCTION function_decl block END */
#line 105 "grammar.y"
{ yygotominor.yy9 = Function_finalize(state, yymsp[-2].minor.yy9, yymsp[0].minor.yy0);   yy_destructor(18,&yymsp[-3].minor);
}
#line 851 "grammar.c"
        break;
      case 28: /* function_decl ::= IDENT LPAREN function_params RPAREN COLON TYPE */
#line 108 "grammar.y"
{
            yygotominor.yy9 = Function_create(state, yymsp[0].minor.yy0->value, yymsp[-5].minor.yy0->start, yymsp[-5].minor.yy0->len, yymsp[-3].minor.yy14); 
            free(yymsp[-5].minor.yy0); free(yymsp[0].minor.yy0);
          yy_destructor(4,&yymsp[-4].minor);
  yy_destructor(5,&yymsp[-2].minor);
  yy_destructor(20,&yymsp[-1].minor);
}
#line 862 "grammar.c"
        break;
      case 29: /* function_params ::= IDENT COLON TYPE */
#line 114 "grammar.y"
{ yygotominor.yy14 = FunctionParam_create(NULL, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); free(yymsp[-2].minor.yy0); free(yymsp[0].minor.yy0);   yy_destructor(20,&yymsp[-1].minor);
}
#line 868 "grammar.c"
        break;
      case 30: /* function_params ::= function_params COMMA IDENT COLON TYPE */
#line 117 "grammar.y"
{
                    yygotominor.yy14 = FunctionParam_create(yymsp[-4].minor.yy14, yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
                    free(yymsp[-2].minor.yy0);  // these have to be here or double free
                    free(yymsp[0].minor.yy0);
                  yy_destructor(6,&yymsp[-3].minor);
  yy_destructor(20,&yymsp[-1].minor);
}
#line 879 "grammar.c"
        break;
      case 31: /* function_params ::= */
#line 122 "grammar.y"
{ yygotominor.yy14 = NULL; }
#line 884 "grammar.c"
        break;
      case 36: /* element ::= LABEL */
#line 129 "grammar.y"
{ Label_statement(state->current, yymsp[0].minor.yy0); free(yymsp[0].minor.yy0); }
#line 889 "grammar.c"
        break;
      case 37: /* element ::= IDENT EQ expr */
#line 130 "grammar.y"
{
         Module_create_function_constant(state, yymsp[-2].minor.yy0, yymsp[0].minor.yy0); free(yymsp[-2].minor.yy0);
        yy_destructor(3,&yymsp[-1].minor);
}
#line 897 "grammar.c"
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,yygoto);
  if( yyact < YYNSTATE ){
#ifdef NDEBUG
    /* If we are not debugging and the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = yyact;
      yymsp->major = yygoto;
      yymsp->minor = yygotominor;
    }else
#endif
    {
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YYNSTATE + YYNRULE + 1 );
    yy_accept(yypParser);
  }
}
Esempio n. 3
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  ParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  **
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
  ** without this code, their parser segfaults.  I'm not sure what there
  ** parser is doing to make this happen.  This is the second bug report
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
  ** that it has not been previously stressed...  (SQLite ticket #2172)
  */
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  yygotominor = yyzerominor;


  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0: /* program ::= expr */
#line 74 "parser.y"
{
  if (result->error_type == Result::NOT_ACCEPTED &&
      IsFinite(yymsp[0].minor.yy0)){
    result->value = yymsp[0].minor.yy0;
  } else {
    result->error_type = Result::RESULT_OVERFLOW;
  }
}
#line 727 "parser.c"
        break;
      case 1: /* expr ::= expr MINUS expr */
#line 83 "parser.y"
{
  yygotominor.yy0 = yymsp[-2].minor.yy0 - yymsp[0].minor.yy0;
  result->CheckValue(yygotominor.yy0);
}
#line 735 "parser.c"
        break;
      case 2: /* expr ::= expr PLUS expr */
#line 87 "parser.y"
{
  yygotominor.yy0 = yymsp[-2].minor.yy0 + yymsp[0].minor.yy0;
  result->CheckValue(yygotominor.yy0);
}
#line 743 "parser.c"
        break;
      case 3: /* expr ::= expr TIMES expr */
#line 91 "parser.y"
{
  yygotominor.yy0 = yymsp[-2].minor.yy0 * yymsp[0].minor.yy0;
  result->CheckValue(yygotominor.yy0);
}
#line 751 "parser.c"
        break;
      case 4: /* expr ::= MINUS expr */
#line 95 "parser.y"
{ yygotominor.yy0 = - yymsp[0].minor.yy0; }
#line 756 "parser.c"
        break;
      case 5: /* expr ::= PLUS expr */
      case 10: /* expr ::= INTEGER */ yytestcase(yyruleno==10);
#line 96 "parser.y"
{ yygotominor.yy0 = yymsp[0].minor.yy0; }
#line 762 "parser.c"
        break;
      case 6: /* expr ::= expr POW expr */
#line 97 "parser.y"
{
  yygotominor.yy0 = pow(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
  result->CheckValue(yygotominor.yy0);
}
#line 770 "parser.c"
        break;
      case 7: /* expr ::= LP expr RP */
#line 101 "parser.y"
{ yygotominor.yy0 = yymsp[-1].minor.yy0; }
#line 775 "parser.c"
        break;
      case 8: /* expr ::= expr DIVIDE expr */
#line 102 "parser.y"
{
  if (yymsp[0].minor.yy0 != 0.0) {
    yygotominor.yy0 = yymsp[-2].minor.yy0 / yymsp[0].minor.yy0;
    result->CheckValue(yygotominor.yy0);
  } else {
    result->error_type = Result::DIVIDE_BY_ZERO;
  }
}
#line 787 "parser.c"
        break;
      case 9: /* expr ::= expr MOD expr */
#line 110 "parser.y"
{
  if (yymsp[0].minor.yy0 != 0.0) {
    yygotominor.yy0 = fmod(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    result->CheckValue(yygotominor.yy0);
  } else {
    result->error_type = Result::DIVIDE_BY_ZERO;
  }
}
#line 799 "parser.c"
        break;
      default:
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  if( yyact < YYNSTATE ){
#ifdef NDEBUG
    /* If we are not debugging and the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = (YYACTIONTYPE)yyact;
      yymsp->major = (YYCODETYPE)yygoto;
      yymsp->minor = yygotominor;
    }else
#endif
    {
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YYNSTATE + YYNRULE + 1 );
    yy_accept(yypParser);
  }
}
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  ParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    yysize = yyRuleInfo[yyruleno].nrhs;
    fprintf(yyTraceFILE, "%sReduce [%s] -> state %d.\n", yyTracePrompt,
      yyRuleName[yyruleno], yymsp[-yysize].stateno);
  }
#endif /* NDEBUG */

  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  **
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
  ** without this code, their parser segfaults.  I'm not sure what there
  ** parser is doing to make this happen.  This is the second bug report
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
  ** that it has not been previously stressed...  (SQLite ticket #2172)
  */
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  yygotominor = yyzerominor;


  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0: /* expression ::= expr */
#line 35 "/home/veei/git/calculator/expressions.grammar.y"
{ state->root = yymsp[0].minor.yy0; }
#line 809 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 1: /* identifier ::= IDENTIFIER */
#line 38 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_identifier(yymsp[0].minor.yy0, state->vpool);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
}
#line 817 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 2: /* identifier ::= identifier DOT IDENTIFIER */
#line 44 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_access_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
  yy_destructor(yypParser,18,&yymsp[-1].minor);
}
#line 827 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 3: /* term ::= identifier */
      case 8: /* expr ::= term */ yytestcase(yyruleno==8);
#line 50 "/home/veei/git/calculator/expressions.grammar.y"
{ yygotominor.yy0 = yymsp[0].minor.yy0; }
#line 833 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 4: /* term ::= INTEGER */
#line 53 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_integer(yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
}
#line 841 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 5: /* term ::= FLOAT */
#line 59 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_float(yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
}
#line 849 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 6: /* term ::= BOOLEAN */
#line 65 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_boolean(yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
}
#line 857 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 7: /* term ::= STRING */
#line 71 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_string(yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
}
#line 865 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 9: /* expr ::= expr PLUS expr */
#line 79 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_add_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,11,&yymsp[-1].minor);
}
#line 876 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 10: /* expr ::= expr MINUS expr */
#line 87 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_sub_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,12,&yymsp[-1].minor);
}
#line 887 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 11: /* expr ::= expr DIVIDE expr */
#line 95 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_div_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,15,&yymsp[-1].minor);
}
#line 898 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 12: /* expr ::= expr MOD expr */
#line 103 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_mod_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,16,&yymsp[-1].minor);
}
#line 909 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 13: /* expr ::= expr TIMES expr */
#line 111 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_times_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,14,&yymsp[-1].minor);
}
#line 920 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 14: /* expr ::= LEFT_P expr RIGHT_P */
#line 119 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = yymsp[-1].minor.yy0;
  yy_destructor(yypParser,23,&yymsp[-2].minor);
  yy_destructor(yypParser,24,&yymsp[0].minor);
}
#line 929 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 15: /* expr ::= MINUS expr */
#line 124 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_minus_operator(yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,12,&yymsp[-1].minor);
}
#line 939 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 16: /* expr ::= NOT expr */
#line 131 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_not_operator(yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,4,&yymsp[-1].minor);
}
#line 949 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 17: /* expr ::= expr AND expr */
#line 138 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_and_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,2,&yymsp[-1].minor);
}
#line 960 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 18: /* expr ::= expr OR expr */
#line 146 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_or_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,3,&yymsp[-1].minor);
}
#line 971 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 19: /* expr ::= expr LESS expr */
#line 154 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_less_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,5,&yymsp[-1].minor);
}
#line 982 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 20: /* expr ::= expr LESS_OR_EQUAL expr */
#line 162 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_less_or_equal_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,6,&yymsp[-1].minor);
}
#line 993 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 21: /* expr ::= expr GREATER expr */
#line 170 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_greater_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,7,&yymsp[-1].minor);
}
#line 1004 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 22: /* expr ::= expr GREATER_OR_EQUAL expr */
#line 178 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_greater_or_equal_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,8,&yymsp[-1].minor);
}
#line 1015 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 23: /* expr ::= expr EQUAL expr */
#line 186 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_equal_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,9,&yymsp[-1].minor);
}
#line 1026 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 24: /* expr ::= expr NOT_EQUAL expr */
#line 194 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_not_equal_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,10,&yymsp[-1].minor);
}
#line 1037 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      case 25: /* expr ::= identifier ASSIGN expr */
#line 202 "/home/veei/git/calculator/expressions.grammar.y"
{
    yygotominor.yy0 = create_assignment_operator(yymsp[-2].minor.yy0, yymsp[0].minor.yy0);
    add_to_temp_set(yygotominor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[-2].minor.yy0, state->temp_set);
    remove_from_temp_set(yymsp[0].minor.yy0, state->temp_set);
  yy_destructor(yypParser,1,&yymsp[-1].minor);
}
#line 1048 "/home/veei/git/calculator/expressions.grammar.cpp"
        break;
      default:
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  if( yyact <= YY_MAX_SHIFTREDUCE ){
    if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
    /* If the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = (YYACTIONTYPE)yyact;
      yymsp->major = (YYCODETYPE)yygoto;
      yymsp->minor = yygotominor;
      yyTraceShift(yypParser, yyact);
    }else{
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YY_ACCEPT_ACTION );
    yy_accept(yypParser);
  }
}
Esempio n. 5
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  BbParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0:
#line 28 "core/bb-p.lemon"
{ yygotominor.yy5 = bb_program_new ();
	  bb_program_add_function_begin (yygotominor.yy5);
	  bb_program_append_program (yygotominor.yy5, yymsp[-2].minor.yy5);
	  bb_program_append_program (yygotominor.yy5, yymsp[0].minor.yy5);
	  bb_program_add_lazy_function (yygotominor.yy5, "add");   yy_destructor(2,&yymsp[-1].minor);
}
#line 592 "core/bb-p.c"
        break;
      case 1:
#line 34 "core/bb-p.lemon"
{ yygotominor.yy5 = bb_program_new ();
	  bb_program_add_function_begin (yygotominor.yy5);
	  bb_program_append_program (yygotominor.yy5, yymsp[-2].minor.yy5);
	  bb_program_append_program (yygotominor.yy5, yymsp[0].minor.yy5);
	  bb_program_add_lazy_function (yygotominor.yy5, "mul");   yy_destructor(4,&yymsp[-1].minor);
}
#line 602 "core/bb-p.c"
        break;
      case 2:
#line 40 "core/bb-p.lemon"
{ yygotominor.yy5 = bb_program_new ();
	  bb_program_add_function_begin (yygotominor.yy5);
	  bb_program_append_program (yygotominor.yy5, yymsp[-2].minor.yy5);
	  bb_program_append_program (yygotominor.yy5, yymsp[0].minor.yy5);
	  bb_program_add_lazy_function (yygotominor.yy5, "sub");   yy_destructor(3,&yymsp[-1].minor);
}
#line 612 "core/bb-p.c"
        break;
      case 3:
#line 46 "core/bb-p.lemon"
{ yygotominor.yy5 = bb_program_new ();
	  bb_program_add_function_begin (yygotominor.yy5);
	  bb_program_append_program (yygotominor.yy5, yymsp[0].minor.yy5);
	  bb_program_add_lazy_function (yygotominor.yy5, "neg");   yy_destructor(3,&yymsp[-1].minor);
}
#line 621 "core/bb-p.c"
        break;
      case 4:
#line 51 "core/bb-p.lemon"
{ yygotominor.yy5 = bb_program_new ();
	  bb_program_add_function_begin (yygotominor.yy5);
	  bb_program_append_program (yygotominor.yy5, yymsp[-2].minor.yy5);
	  bb_program_append_program (yygotominor.yy5, yymsp[0].minor.yy5);
	  bb_program_add_lazy_function (yygotominor.yy5, "div");   yy_destructor(5,&yymsp[-1].minor);
}
#line 631 "core/bb-p.c"
        break;
      case 5:
#line 58 "core/bb-p.lemon"
{ yygotominor.yy5 = bb_program_new ();
	  bb_program_append_program (yygotominor.yy5, yymsp[-1].minor.yy5);   yy_destructor(7,&yymsp[-2].minor);
  yy_destructor(8,&yymsp[0].minor);
}
#line 639 "core/bb-p.c"
        break;
      case 6:
#line 61 "core/bb-p.lemon"
{ yygotominor.yy5 = bb_program_new ();
	  bb_program_append_program (yygotominor.yy5, yymsp[-2].minor.yy5);
	  bb_program_append_program (yygotominor.yy5, yymsp[0].minor.yy5);   yy_destructor(1,&yymsp[-1].minor);
}
#line 647 "core/bb-p.c"
        break;
      case 7:
#line 65 "core/bb-p.lemon"
{ GValue value;
          char *end;
          gdouble nvalue = strtod (yymsp[0].minor.yy0, &end);
          if (yymsp[0].minor.yy0 == end)
            g_error ("error parsing number from %s", yymsp[0].minor.yy0);
	  memset (&value, 0, sizeof (value));
          if (strcmp (end, "sec") == 0 || strcmp (end, "s") == 0)
            {
              g_value_init (&value, BB_TYPE_DURATION);
              bb_value_set_duration (&value, BB_DURATION_UNITS_SECONDS, nvalue);
            }
          else if (strcmp (end, "samp") == 0)
            {
              g_value_init (&value, BB_TYPE_DURATION);
              bb_value_set_duration (&value, BB_DURATION_UNITS_SAMPLES, nvalue);
            }
          else if (strcmp (end, "beat") == 0 || strcmp (end, "b") == 0)
            {
              g_value_init (&value, BB_TYPE_DURATION);
              bb_value_set_duration (&value, BB_DURATION_UNITS_BEATS, nvalue);
            }
          else if (strcmp (end, "%") == 0)
            {
              g_value_init (&value, BB_TYPE_DURATION);
              bb_value_set_duration (&value, BB_DURATION_UNITS_NOTE_LENGTHS, nvalue * 0.01);
            }
          else if (*end != 0)
            {
              g_error ("garbage after number (garbage is '%s'", end);
            }
          else
            {
              g_value_init (&value, G_TYPE_DOUBLE);
              g_value_set_double (&value, nvalue);
            }
	  yygotominor.yy5 = bb_program_new ();
	  bb_program_add_push (yygotominor.yy5, &value); }
#line 688 "core/bb-p.c"
        break;
      case 8:
#line 104 "core/bb-p.lemon"
{ /* find or allocate parameter */
	  guint i;
	  for (i = 0; i < context->pspec_array->len; i++)
	    {
	      GParamSpec *p = g_ptr_array_index (context->pspec_array, i);
	      if (bb_param_spec_names_equal (p->name, yymsp[0].minor.yy0))
	        break;
            }
	  if (i == context->pspec_array->len)
	    {
              for (i = 0; i < context->n_source_pspecs; i++)
                if (bb_param_spec_names_equal (yymsp[0].minor.yy0, context->source_pspecs[i]->name))
                  break;
              if (i == context->n_source_pspecs)
		{
		  g_message ("warning: allocating double parameter named %s", yymsp[0].minor.yy0);
		  g_ptr_array_add (context->pspec_array,
				   g_param_spec_double (yymsp[0].minor.yy0,yymsp[0].minor.yy0,NULL,
				      -1e9,1e9,0,G_PARAM_READWRITE));
		  }
              else
                g_ptr_array_add (context->pspec_array, context->source_pspecs[i]);
              i = context->pspec_array->len - 1;
	    }
	  yygotominor.yy5 = bb_program_new ();
	  bb_program_add_push_param (yygotominor.yy5, i); }
#line 718 "core/bb-p.c"
        break;
      case 9:
#line 132 "core/bb-p.lemon"
{ BbBuiltinFunc f;
          yygotominor.yy5 = bb_program_new ();
	  f = bb_builtin_lookup (yymsp[-3].minor.yy0);
	  if (f != NULL)
	    {
	      bb_program_append_program (yygotominor.yy5, yymsp[-1].minor.yy5);
	      bb_program_add_builtin (yygotominor.yy5, yymsp[-3].minor.yy0, f);
	    }
	  else
	    {
	      /* TODO: try resolving the function now */
	      bb_program_add_function_begin (yygotominor.yy5);
	      bb_program_append_program (yygotominor.yy5, yymsp[-1].minor.yy5);
	      bb_program_add_lazy_function (yygotominor.yy5, yymsp[-3].minor.yy0);
	    }
	  yy_destructor(7,&yymsp[-2].minor);
  yy_destructor(8,&yymsp[0].minor);
}
#line 740 "core/bb-p.c"
        break;
      case 10:
#line 149 "core/bb-p.lemon"
{ BbBuiltinFunc f;
          yygotominor.yy5 = bb_program_new ();
	  f = bb_builtin_lookup (yymsp[-2].minor.yy0);
	  if (f != NULL)
	    bb_program_add_builtin (yygotominor.yy5, yymsp[-2].minor.yy0, f);
	  else
	    {
	      bb_program_add_function_begin (yygotominor.yy5);
	      bb_program_add_lazy_function (yygotominor.yy5, yymsp[-2].minor.yy0);
	    }
	  yy_destructor(7,&yymsp[-1].minor);
  yy_destructor(8,&yymsp[0].minor);
}
#line 757 "core/bb-p.c"
        break;
      case 11:
#line 163 "core/bb-p.lemon"
{ GType type = g_type_from_name (yymsp[-2].minor.yy0);
          guint v;
          GValue ev;
          if (type == 0 || !g_type_is_a (type, G_TYPE_ENUM))
            g_error ("no enum named '%s'", yymsp[-2].minor.yy0);
          if (!bb_enum_value_lookup (type, yymsp[0].minor.yy0, &v))
            g_error ("no value of %s named %s", yymsp[-2].minor.yy0, yymsp[0].minor.yy0);

          memset (&ev, 0, sizeof (ev));
          g_value_init (&ev, type);
          g_value_set_enum (&ev, v);
          yygotominor.yy5 = bb_program_new ();
          bb_program_add_push (yygotominor.yy5, &ev);   yy_destructor(6,&yymsp[-1].minor);
}
#line 775 "core/bb-p.c"
        break;
      case 12:
#line 178 "core/bb-p.lemon"
{ yygotominor.yy5 = bb_program_new ();
	  bb_program_add_push_special (yygotominor.yy5, BB_VM_SPECIAL_ARRAY_BEGIN);
	  bb_program_append_program (yygotominor.yy5, yymsp[-1].minor.yy5);
	  bb_program_add_builtin (yygotominor.yy5, "create_array", bb_builtin_create_array);   yy_destructor(11,&yymsp[-2].minor);
  yy_destructor(12,&yymsp[0].minor);
}
#line 785 "core/bb-p.c"
        break;
      case 13:
#line 184 "core/bb-p.lemon"
{ GValue v = BB_VALUE_INIT;
          yygotominor.yy5 = bb_program_new ();
	  g_value_init (&v, G_TYPE_STRING);
          g_value_set_string (&v, yymsp[0].minor.yy0);
	  bb_program_add_push (yygotominor.yy5, &v); }
#line 794 "core/bb-p.c"
        break;
      case 14:
#line 191 "core/bb-p.lemon"
{ if (context->program)
	    { g_warning ("got two programs"); }
	  else
	    { context->program = bb_program_ref (yymsp[0].minor.yy5); }
	}
#line 803 "core/bb-p.c"
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yypParser,yygoto);
  if( yyact < YYNSTATE ){
    yy_shift(yypParser,yyact,yygoto,&yygotominor);
  }else if( yyact == YYNSTATE + YYNRULE + 1 ){
    yy_accept(yypParser);
  }
}
Esempio n. 6
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  lcn_query_parser_ARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0:
#line 100 "query_parser.y"
{
    info->query = yymsp[0].minor.yy36;
}
#line 643 "query_parser.c"
        break;
      case 1:
#line 104 "query_parser.y"
{
    (void) lcn_list_add( yymsp[-2].minor.yy12, apr_pstrdup( info->pool, yymsp[0].minor.yy0->text) );
    yygotominor.yy12 = yymsp[-2].minor.yy12;
}
#line 651 "query_parser.c"
        break;
      case 2:
#line 109 "query_parser.y"
{
    (void) lcn_list_create( &(yygotominor.yy12), 10, info->pool );
    (void) lcn_list_add( yygotominor.yy12, apr_pstrdup( info->pool, yymsp[0].minor.yy0->text ) );
}
#line 659 "query_parser.c"
        break;
      case 3:
#line 114 "query_parser.y"
{
    lcn_list_t *term_list;
    unsigned int i;

    (void) lcn_multi_phrase_query_create( &(yygotominor.yy36), info->pool );
    (void) lcn_list_create( &term_list, 10, info->pool );

    for( i = 0; i < lcn_list_size( yymsp[-1].minor.yy12 ); i++ )
    {
        lcn_term_t *term;
        lcn_term_create( &term,
                         yymsp[-4].minor.yy0->text,
                         (char*) lcn_list_get( yymsp[-1].minor.yy12, i ),
                         LCN_TERM_TEXT_COPY,
                         info->pool );
        (void) lcn_multi_phrase_query_add_term( yygotominor.yy36, term );
    }
}
#line 681 "query_parser.c"
        break;
      case 4:
#line 133 "query_parser.y"
{
    lcn_term_t *term;

    (void) lcn_term_create( &term, yymsp[-2].minor.yy0->text, "", LCN_TERM_TEXT_COPY, info->pool );
    (void) lcn_prefix_query_create( &(yygotominor.yy36), term, info->pool );
}
#line 691 "query_parser.c"
        break;
      case 5:
#line 140 "query_parser.y"
{
    lcn_term_t *term;

    (void) lcn_term_create( &term, yymsp[-3].minor.yy0->text, yymsp[-1].minor.yy0->text, LCN_TERM_TEXT_COPY, info->pool );
    (void) lcn_prefix_query_create( &(yygotominor.yy36), term, info->pool );
}
#line 701 "query_parser.c"
        break;
      case 6:
#line 147 "query_parser.y"
{
    (void) lcn_term_query_create_by_chars( &(yygotominor.yy36), yymsp[-2].minor.yy0->text, yymsp[0].minor.yy0->text, info->pool );
}
#line 708 "query_parser.c"
        break;
      case 7:
#line 151 "query_parser.y"
{
    lcn_query_t *q = query_list_to_query( yymsp[-1].minor.yy12, info->pool );
    yygotominor.yy36 = q;
}
#line 716 "query_parser.c"
        break;
      case 8:
      case 9:
      case 10:
      case 11:
#line 156 "query_parser.y"
{ yygotominor.yy36 = yymsp[0].minor.yy36; }
#line 724 "query_parser.c"
        break;
      case 12:
#line 162 "query_parser.y"
{
    struct lcn_query_with_clause_t* q = apr_pcalloc( info->pool, sizeof(struct lcn_query_with_clause_t));
    (void) lcn_list_create( &(yygotominor.yy12), 10, info->pool );
    q->query = yymsp[0].minor.yy36;
    q->clause = (*(yymsp[-1].minor.yy0->text) == '-' ? LCN_BOOLEAN_CLAUSE_MUST_NOT : LCN_BOOLEAN_CLAUSE_MUST);
    (void) lcn_list_add( yygotominor.yy12, q );
}
#line 735 "query_parser.c"
        break;
      case 13:
#line 170 "query_parser.y"
{
    struct lcn_query_with_clause_t* q = apr_pcalloc( info->pool, sizeof(struct lcn_query_with_clause_t));
    (void) lcn_list_create( &(yygotominor.yy12), 10, info->pool );
    q->query = yymsp[0].minor.yy36;
    q->clause = LCN_BOOLEAN_CLAUSE_SHOULD;
    (void) lcn_list_add( yygotominor.yy12, q );
}
#line 746 "query_parser.c"
        break;
      case 14:
#line 178 "query_parser.y"
{
    struct lcn_query_with_clause_t* q = apr_pcalloc( info->pool, sizeof(struct lcn_query_with_clause_t));
    q->query = yymsp[0].minor.yy36;
    q->clause = (*(yymsp[-1].minor.yy0->text) == '-' ? LCN_BOOLEAN_CLAUSE_MUST_NOT : LCN_BOOLEAN_CLAUSE_MUST);
    (void) lcn_list_add( yymsp[-3].minor.yy12, q );
    yygotominor.yy12 = yymsp[-3].minor.yy12;
}
#line 757 "query_parser.c"
        break;
      case 15:
#line 186 "query_parser.y"
{
    struct lcn_query_with_clause_t* q = apr_pcalloc( info->pool, sizeof(struct lcn_query_with_clause_t));
    q->query = yymsp[0].minor.yy36;
    q->clause = LCN_BOOLEAN_CLAUSE_SHOULD;
    (void) lcn_list_add( yymsp[-2].minor.yy12, q );
    yygotominor.yy12 = yymsp[-2].minor.yy12;
}
#line 768 "query_parser.c"
        break;
      case 16:
#line 194 "query_parser.y"
{
    yygotominor.yy36 = query_list_to_query( yymsp[0].minor.yy12, info->pool );
}
#line 775 "query_parser.c"
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yypParser,yygoto);
  if( yyact < YYNSTATE ){
    yy_shift(yypParser,yyact,yygoto,&yygotominor);
  }else if( yyact == YYNSTATE + YYNRULE + 1 ){
    yy_accept(yypParser);
  }
}
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
    yyParser *yypParser,         /* The parser */
    int yyruleno                 /* Number of the rule by which to reduce */
) {
    int yygoto;                     /* The next state */
    int yyact;                      /* The next action */
    YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
    yyStackEntry *yymsp;            /* The top of the parser's stack */
    int yysize;                     /* Amount to pop the stack */
    DSVariablePoolParserARG_FETCH;
    yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
    if( yyTraceFILE && yyruleno>=0
            && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ) {
        fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
                yyRuleName[yyruleno]);
    }
#endif /* NDEBUG */

    /* Silence complaints from purify about yygotominor being uninitialized
    ** in some cases when it is copied into the stack after the following
    ** switch.  yygotominor is uninitialized when a rule reduces that does
    ** not set the value of its left-hand side nonterminal.  Leaving the
    ** value of the nonterminal uninitialized is utterly harmless as long
    ** as the value is never used.  So really the only thing this code
    ** accomplishes is to quieten purify.
    **
    ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
    ** without this code, their parser segfaults.  I'm not sure what there
    ** parser is doing to make this happen.  This is the second bug report
    ** from wireshark this week.  Clearly they are stressing Lemon in ways
    ** that it has not been previously stressed...  (SQLite ticket #2172)
    */
    /*memset(&yygotominor, 0, sizeof(yygotominor));*/
    yygotominor = yyzerominor;


    switch( yyruleno ) {
    /* Beginning here are the reduction cases.  A typical example
    ** follows:
    **   case 0:
    **  #line <lineno> <grammarfile>
    **     { ... }           // User supplied code
    **  #line <lineno> <thisfile>
    **     break;
    */
    case 3: /* statement ::= QUOTE IDENTIFIER QUOTE ASSIGN VALUE */
    {
        DSVariablePoolAddVariableWithName(pool, (const char *)yymsp[-3].minor.yy0);
        DSVariablePoolSetValueForVariableWithName(pool, (const char *)yymsp[-3].minor.yy0, *yymsp[0].minor.yy0);
    }
    break;
    case 4: /* statement ::= IDENTIFIER ASSIGN VALUE */
    {
        DSVariablePoolAddVariableWithName(pool, (const char *)yymsp[-2].minor.yy0);
        DSVariablePoolSetValueForVariableWithName(pool, (const char *)yymsp[-2].minor.yy0, *yymsp[0].minor.yy0);
    }
    break;
    case 5: /* statement ::= IDENTIFIER */
    {
        DSVariablePoolAddVariableWithName(pool, (const char *)yymsp[0].minor.yy0);
    }
    break;
    default:
        /* (0) program ::= expr */
        yytestcase(yyruleno==0);
        /* (1) expr ::= statement */ yytestcase(yyruleno==1);
        /* (2) expr ::= expr SEPERATOR statement */ yytestcase(yyruleno==2);
        break;
    };
    yygoto = yyRuleInfo[yyruleno].lhs;
    yysize = yyRuleInfo[yyruleno].nrhs;
    yypParser->yyidx -= yysize;
    yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
    if( yyact < YYNSTATE ) {
#ifdef NDEBUG
        /* If we are not debugging and the reduce action popped at least
        ** one element off the stack, then we can push the new element back
        ** onto the stack here, and skip the stack overflow test in yy_shift().
        ** That gives a significant speed improvement. */
        if( yysize ) {
            yypParser->yyidx++;
            yymsp -= yysize-1;
            yymsp->stateno = (YYACTIONTYPE)yyact;
            yymsp->major = (YYCODETYPE)yygoto;
            yymsp->minor = yygotominor;
        } else
#endif
        {
            yy_shift(yypParser,yyact,yygoto,&yygotominor);
        }
    } else {
        assert( yyact == YYNSTATE + YYNRULE + 1 );
        yy_accept(yypParser);
    }
}
Esempio n. 8
0
/* The main parser program.
** The first argument is a pointer to a structure obtained from
** "configparserAlloc" which describes the current state of the parser.
** The second argument is the major token number.  The third is
** the minor token.  The fourth optional argument is whatever the
** user wants (and specified in the grammar) and is available for
** use by the action routines.
**
** Inputs:
** <ul>
** <li> A pointer to the parser (an opaque structure.)
** <li> The major token number.
** <li> The minor token number.
** <li> An option argument of a grammar-specified type.
** </ul>
**
** Outputs:
** None.
*/
void configparser(
  void *yyp,                   /* The parser */
  int yymajor,                 /* The major token code number */
  configparserTOKENTYPE yyminor       /* The value for the token */
  configparserARG_PDECL               /* Optional %extra_argument parameter */
){
  YYMINORTYPE yyminorunion;
  int yyact;            /* The parser action. */
  int yyendofinput;     /* True if we are at the end of input */
  int yyerrorhit = 0;   /* True if yymajor has invoked an error */
  yyParser *yypParser;  /* The parser */

  /* (re)initialize the parser, if necessary */
  yypParser = (yyParser*)yyp;
  if( yypParser->yyidx<0 ){
    if( yymajor==0 ) return;
    yypParser->yyidx = 0;
    yypParser->yyerrcnt = -1;
    yypParser->yystack[0].stateno = 0;
    yypParser->yystack[0].major = 0;
  }
  yyminorunion.yy0 = yyminor;
  yyendofinput = (yymajor==0);
  configparserARG_STORE;

#ifndef NDEBUG
  if( yyTraceFILE ){
    fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
  }
#endif

  do{
    yyact = yy_find_shift_action(yypParser,yymajor);
    if( yyact<YYNSTATE ){
      yy_shift(yypParser,yyact,yymajor,&yyminorunion);
      yypParser->yyerrcnt--;
      if( yyendofinput && yypParser->yyidx>=0 ){
        yymajor = 0;
      }else{
        yymajor = YYNOCODE;
      }
    }else if( yyact < YYNSTATE + YYNRULE ){
      yy_reduce(yypParser,yyact-YYNSTATE);
    }else if( yyact == YY_ERROR_ACTION ){
      int yymx;
#ifndef NDEBUG
      if( yyTraceFILE ){
        fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt);
      }
#endif
#ifdef YYERRORSYMBOL
      /* A syntax error has occurred.
      ** The response to an error depends upon whether or not the
      ** grammar defines an error token "ERROR".
      **
      ** This is what we do if the grammar does define ERROR:
      **
      **  * Call the %syntax_error function.
      **
      **  * Begin popping the stack until we enter a state where
      **    it is legal to shift the error symbol, then shift
      **    the error symbol.
      **
      **  * Set the error count to three.
      **
      **  * Begin accepting and shifting new tokens.  No new error
      **    processing will occur until three tokens have been
      **    shifted successfully.
      **
      */
      if( yypParser->yyerrcnt<0 ){
        yy_syntax_error(yypParser,yymajor,yyminorunion);
      }
      yymx = yypParser->yystack[yypParser->yyidx].major;
      if( yymx==YYERRORSYMBOL || yyerrorhit ){
#ifndef NDEBUG
        if( yyTraceFILE ){
          fprintf(yyTraceFILE,"%sDiscard input token %s\n",
             yyTracePrompt,yyTokenName[yymajor]);
        }
#endif
        yy_destructor(yymajor,&yyminorunion);
        yymajor = YYNOCODE;
      }else{
         while(
          yypParser->yyidx >= 0 &&
          yymx != YYERRORSYMBOL &&
          (yyact = yy_find_shift_action(yypParser,YYERRORSYMBOL)) >= YYNSTATE
        ){
          yy_pop_parser_stack(yypParser);
        }
        if( yypParser->yyidx < 0 || yymajor==0 ){
          yy_destructor(yymajor,&yyminorunion);
          yy_parse_failed(yypParser);
          yymajor = YYNOCODE;
        }else if( yymx!=YYERRORSYMBOL ){
          YYMINORTYPE u2;
          u2.YYERRSYMDT = 0;
          yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2);
        }
      }
      yypParser->yyerrcnt = 3;
      yyerrorhit = 1;
#else  /* YYERRORSYMBOL is not defined */
      /* This is what we do if the grammar does not define ERROR:
      **
      **  * Report an error message, and throw away the input token.
      **
      **  * If the input token is $, then fail the parse.
      **
      ** As before, subsequent error messages are suppressed until
      ** three input tokens have been successfully shifted.
      */
      if( yypParser->yyerrcnt<=0 ){
        yy_syntax_error(yypParser,yymajor,yyminorunion);
      }
      yypParser->yyerrcnt = 3;
      yy_destructor(yymajor,&yyminorunion);
      if( yyendofinput ){
        yy_parse_failed(yypParser);
      }
      yymajor = YYNOCODE;
#endif
    }else{
      yy_accept(yypParser);
      yymajor = YYNOCODE;
    }
  }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 );
  return;
}
Esempio n. 9
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  phannot_ARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0:
#line 86 "parser.php5.lemon"
{
	status->ret = yymsp[0].minor.yy36;
}
#line 632 "parser.php5.c"
        break;
      case 1:
      case 14:
      case 15:
#line 94 "parser.php5.lemon"
{
	yygotominor.yy36 = yymsp[0].minor.yy36;
}
#line 641 "parser.php5.c"
        break;
      case 2:
#line 102 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_zval_list(yymsp[-1].minor.yy36, yymsp[0].minor.yy36);
}
#line 648 "parser.php5.c"
        break;
      case 3:
      case 8:
#line 106 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_zval_list(NULL, yymsp[0].minor.yy36);
}
#line 656 "parser.php5.c"
        break;
      case 4:
#line 114 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_annotation(yymsp[-3].minor.yy0, yymsp[-1].minor.yy36, status->scanner_state);
  yy_destructor(2,&yymsp[-4].minor);
  yy_destructor(4,&yymsp[-2].minor);
  yy_destructor(5,&yymsp[0].minor);
}
#line 666 "parser.php5.c"
        break;
      case 5:
#line 118 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_annotation(yymsp[-2].minor.yy0, NULL, status->scanner_state);
  yy_destructor(2,&yymsp[-3].minor);
  yy_destructor(4,&yymsp[-1].minor);
  yy_destructor(5,&yymsp[0].minor);
}
#line 676 "parser.php5.c"
        break;
      case 6:
#line 122 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_annotation(yymsp[0].minor.yy0, NULL, status->scanner_state);
  yy_destructor(2,&yymsp[-1].minor);
}
#line 684 "parser.php5.c"
        break;
      case 7:
#line 130 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_zval_list(yymsp[-2].minor.yy36, yymsp[0].minor.yy36);
  yy_destructor(1,&yymsp[-1].minor);
}
#line 692 "parser.php5.c"
        break;
      case 9:
#line 142 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_named_item(NULL, yymsp[0].minor.yy36);
}
#line 699 "parser.php5.c"
        break;
      case 10:
      case 12:
#line 146 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_named_item(yymsp[-2].minor.yy0, yymsp[0].minor.yy36);
  yy_destructor(7,&yymsp[-1].minor);
}
#line 708 "parser.php5.c"
        break;
      case 11:
      case 13:
#line 150 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_named_item(yymsp[-2].minor.yy0, yymsp[0].minor.yy36);
  yy_destructor(8,&yymsp[-1].minor);
}
#line 717 "parser.php5.c"
        break;
      case 16:
#line 174 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_literal_zval(PHANNOT_T_IDENTIFIER, yymsp[0].minor.yy0);
}
#line 724 "parser.php5.c"
        break;
      case 17:
#line 178 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_literal_zval(PHANNOT_T_INTEGER, yymsp[0].minor.yy0);
}
#line 731 "parser.php5.c"
        break;
      case 18:
#line 182 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_literal_zval(PHANNOT_T_STRING, yymsp[0].minor.yy0);
}
#line 738 "parser.php5.c"
        break;
      case 19:
#line 186 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_literal_zval(PHANNOT_T_DOUBLE, yymsp[0].minor.yy0);
}
#line 745 "parser.php5.c"
        break;
      case 20:
#line 190 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_literal_zval(PHANNOT_T_NULL, NULL);
  yy_destructor(11,&yymsp[0].minor);
}
#line 753 "parser.php5.c"
        break;
      case 21:
#line 194 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_literal_zval(PHANNOT_T_FALSE, NULL);
  yy_destructor(12,&yymsp[0].minor);
}
#line 761 "parser.php5.c"
        break;
      case 22:
#line 198 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_literal_zval(PHANNOT_T_TRUE, NULL);
  yy_destructor(13,&yymsp[0].minor);
}
#line 769 "parser.php5.c"
        break;
      case 23:
#line 202 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_array(yymsp[-1].minor.yy36);
  yy_destructor(14,&yymsp[-2].minor);
  yy_destructor(15,&yymsp[0].minor);
}
#line 778 "parser.php5.c"
        break;
      case 24:
#line 206 "parser.php5.lemon"
{
	yygotominor.yy36 = phannot_ret_array(yymsp[-1].minor.yy36);
  yy_destructor(16,&yymsp[-2].minor);
  yy_destructor(17,&yymsp[0].minor);
}
#line 787 "parser.php5.c"
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yypParser,yygoto);
  if( yyact < YYNSTATE ){
    yy_shift(yypParser,yyact,yygoto,&yygotominor);
  }else if( yyact == YYNSTATE + YYNRULE + 1 ){
    yy_accept(yypParser);
  }
}
Esempio n. 10
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  LineParserARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  **
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
  ** without this code, their parser segfaults.  I'm not sure what there
  ** parser is doing to make this happen.  This is the second bug report
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
  ** that it has not been previously stressed...  (SQLite ticket #2172)
  */
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  yygotominor = yyzerominor;


  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0: /* redirection ::= REDIRECT_INPUT_FROM_FILE ARGUMENT */
#line 51 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy4 = redir_alloc();
    BREAK_IF_ERRNO
    yygotominor.yy4->left_fd = redir_parse_left_fd(yymsp[-1].minor.yy0, 1, STDIN_FILENO);
    yygotominor.yy4->type = REDIRECT_INPUT_FROM_FILE;
    yygotominor.yy4->right_file = yymsp[0].minor.yy0;
}
#line 770 "line_parser.c"
        break;
      case 1: /* redirection ::= REDIRECT_INPUT_FROM_FILE_DESCRIPTOR ARGUMENT */
#line 59 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy4 = redir_alloc();
    BREAK_IF_ERRNO
    yygotominor.yy4->left_fd = redir_parse_left_fd(yymsp[-1].minor.yy0, 2, STDIN_FILENO);
    yygotominor.yy4->type = REDIRECT_INPUT_FROM_FILE_DESCRIPTOR;
    yygotominor.yy4->right_fd = redir_parse_fd(yymsp[0].minor.yy0);
    free(yymsp[0].minor.yy0);
}
#line 783 "line_parser.c"
        break;
      case 2: /* redirection ::= REDIRECT_OUTPUT_TO_FILE ARGUMENT */
#line 68 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy4 = redir_alloc();
    BREAK_IF_ERRNO
    yygotominor.yy4->left_fd = redir_parse_left_fd(yymsp[-1].minor.yy0, 1, STDOUT_FILENO);
    yygotominor.yy4->type = REDIRECT_OUTPUT_TO_FILE;
    yygotominor.yy4->right_file = yymsp[0].minor.yy0;
}
#line 795 "line_parser.c"
        break;
      case 3: /* redirection ::= REDIRECT_OUTPUT_TO_FILE_DESCRIPTOR ARGUMENT */
#line 76 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy4 = redir_alloc();
    BREAK_IF_ERRNO
    yygotominor.yy4->left_fd = redir_parse_left_fd(yymsp[-1].minor.yy0, 2, STDOUT_FILENO);
    yygotominor.yy4->type = REDIRECT_OUTPUT_TO_FILE_DESCRIPTOR;
    yygotominor.yy4->right_fd = redir_parse_fd(yymsp[0].minor.yy0);
    free(yymsp[0].minor.yy0);
}
#line 808 "line_parser.c"
        break;
      case 4: /* redirection ::= REDIRECT_OUTPUT_APPEND_TO_FILE ARGUMENT */
#line 85 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy4 = redir_alloc();
    BREAK_IF_ERRNO
    yygotominor.yy4->left_fd = redir_parse_left_fd(yymsp[-1].minor.yy0, 2, STDOUT_FILENO);
    yygotominor.yy4->type = REDIRECT_OUTPUT_APPEND_TO_FILE;
    yygotominor.yy4->right_file = yymsp[0].minor.yy0;
}
#line 820 "line_parser.c"
        break;
      case 5: /* command ::= ARGUMENT */
#line 94 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy2 = cmd_alloc();
    BREAK_IF_ERRNO
    strarr_append(&(yygotominor.yy2->args), yymsp[0].minor.yy0);
}
#line 830 "line_parser.c"
        break;
      case 6: /* command ::= redirection */
#line 100 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy2 = cmd_alloc();
    BREAK_IF_ERRNO
    ptrarr_append(&(yygotominor.yy2->redirs), yymsp[0].minor.yy4);
}
#line 840 "line_parser.c"
        break;
      case 7: /* command ::= command ARGUMENT */
#line 106 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy2 = yymsp[-1].minor.yy2;
    strarr_append(&(yygotominor.yy2->args), yymsp[0].minor.yy0);
}
#line 849 "line_parser.c"
        break;
      case 8: /* command ::= command redirection */
#line 111 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy2 = yymsp[-1].minor.yy2;
    ptrarr_append(&(yygotominor.yy2->redirs), yymsp[0].minor.yy4);
}
#line 858 "line_parser.c"
        break;
      case 9: /* commandList ::= command */
#line 117 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy13 = cmd_list_alloc();
    BREAK_IF_ERRNO
    ptrarr_append(&(yygotominor.yy13->cmds), yymsp[0].minor.yy2);
}
#line 868 "line_parser.c"
        break;
      case 10: /* commandList ::= commandList PIPE command */
#line 123 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy13 = yymsp[-2].minor.yy13;
    intarr_append(&(yygotominor.yy13->ops), PIPE);
    ptrarr_append(&(yygotominor.yy13->cmds), yymsp[0].minor.yy2);
  yy_destructor(yypParser,7,&yymsp[-1].minor);
}
#line 879 "line_parser.c"
        break;
      case 11: /* commandList ::= commandList OR command */
#line 129 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy13 = yymsp[-2].minor.yy13;
    intarr_append(&(yygotominor.yy13->ops), OR);
    ptrarr_append(&(yygotominor.yy13->cmds), yymsp[0].minor.yy2);
  yy_destructor(yypParser,8,&yymsp[-1].minor);
}
#line 890 "line_parser.c"
        break;
      case 12: /* commandList ::= commandList AND command */
#line 135 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy13 = yymsp[-2].minor.yy13;
    intarr_append(&(yygotominor.yy13->ops), AND);
    ptrarr_append(&(yygotominor.yy13->cmds), yymsp[0].minor.yy2);
  yy_destructor(yypParser,9,&yymsp[-1].minor);
}
#line 901 "line_parser.c"
        break;
      case 13: /* commandList ::= commandList BACKGROUND command */
#line 141 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy13 = yymsp[-2].minor.yy13;
    intarr_append(&(yygotominor.yy13->ops), BACKGROUND);
    ptrarr_append(&(yygotominor.yy13->cmds), yymsp[0].minor.yy2);
  yy_destructor(yypParser,10,&yymsp[-1].minor);
}
#line 912 "line_parser.c"
        break;
      case 14: /* commandList ::= commandList BACKGROUND */
#line 147 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy13 = yymsp[-1].minor.yy13;
    intarr_append(&(yygotominor.yy13->ops), BACKGROUND);
  yy_destructor(yypParser,10,&yymsp[0].minor);
}
#line 922 "line_parser.c"
        break;
      case 15: /* commandList ::= commandList SEMICOLON command */
#line 152 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy13 = yymsp[-2].minor.yy13;
    intarr_append(&(yygotominor.yy13->ops), SEMICOLON);
    ptrarr_append(&(yygotominor.yy13->cmds), yymsp[0].minor.yy2);
  yy_destructor(yypParser,11,&yymsp[-1].minor);
}
#line 933 "line_parser.c"
        break;
      case 16: /* commandList ::= commandList SEMICOLON */
#line 158 "line_parser.y"
{
    BREAK_IF_ERRNO
    yygotominor.yy13 = yymsp[-1].minor.yy13;
    intarr_append(&(yygotominor.yy13->ops), SEMICOLON);
  yy_destructor(yypParser,11,&yymsp[0].minor);
}
#line 943 "line_parser.c"
        break;
      case 17: /* start ::= commandList */
#line 164 "line_parser.y"
{
    BREAK_IF_ERRNO
    // Save our AST from being freed by Lemon!
    *cmd_list_p = yymsp[0].minor.yy13;
}
#line 952 "line_parser.c"
        break;
      default:
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  if( yyact < YYNSTATE ){
#ifdef NDEBUG
    /* If we are not debugging and the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = (YYACTIONTYPE)yyact;
      yymsp->major = (YYCODETYPE)yygoto;
      yymsp->minor = yygotominor;
    }else
#endif
    {
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YYNSTATE + YYNRULE + 1 );
    yy_accept(yypParser);
  }
}
Esempio n. 11
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  ParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    yysize = yyRuleInfo[yyruleno].nrhs;
    fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
      yyRuleName[yyruleno], yymsp[-yysize].stateno);
  }
#endif /* NDEBUG */
  yygotominor = yyzerominor;

  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
/********** Begin reduce actions **********************************************/
      case 4: /* stmt ::= expr ENDS */
#line 49 "grammar.lemon"
{ pEval->parseSetResult(yymsp[-1].minor.yy0.valid ? yymsp[-1].minor.yy0.dValue : NAN); }
#line 737 "grammar.c"
        break;
      case 5: /* stmt ::= expr SEMCOL */
#line 50 "grammar.lemon"
{ pEval->parseSetResult(NAN); }
#line 742 "grammar.c"
        break;
      case 6: /* expr ::= VALUE */
#line 52 "grammar.lemon"
{ yygotominor.yy0.dValue = yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=true; }
#line 747 "grammar.c"
        break;
      case 7: /* expr ::= expr UNIT */
#line 53 "grammar.lemon"
{ yygotominor.yy0.dValue = yymsp[-1].minor.yy0.dValue * yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[-1].minor.yy0.valid; }
#line 752 "grammar.c"
        break;
      case 8: /* expr ::= MINUS expr */
#line 54 "grammar.lemon"
{ yygotominor.yy0.dValue = -yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[0].minor.yy0.valid; }
#line 757 "grammar.c"
        break;
      case 9: /* expr ::= VAR */
#line 55 "grammar.lemon"
{ yygotominor.yy0.dValue = pEval->getVar(yymsp[0].minor.yy0.text); yygotominor.yy0.valid=true; }
#line 762 "grammar.c"
        break;
      case 10: /* expr ::= VAR ASSIGN expr */
#line 56 "grammar.lemon"
{ pEval->setVar(yymsp[-2].minor.yy0.text, yymsp[0].minor.yy0.dValue); yygotominor.yy0.dValue = yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=false; }
#line 767 "grammar.c"
        break;
      case 11: /* expr ::= expr PLUS expr */
#line 57 "grammar.lemon"
{ yygotominor.yy0.dValue = yymsp[-2].minor.yy0.dValue + yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[0].minor.yy0.valid; }
#line 772 "grammar.c"
        break;
      case 12: /* expr ::= expr MINUS expr */
#line 58 "grammar.lemon"
{ yygotominor.yy0.dValue = yymsp[-2].minor.yy0.dValue - yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[0].minor.yy0.valid; }
#line 777 "grammar.c"
        break;
      case 13: /* expr ::= expr MULT expr */
#line 59 "grammar.lemon"
{ yygotominor.yy0.dValue = yymsp[-2].minor.yy0.dValue * yymsp[0].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[0].minor.yy0.valid; }
#line 782 "grammar.c"
        break;
      case 14: /* expr ::= expr DIVIDE expr */
#line 60 "grammar.lemon"
{
   if (yymsp[0].minor.yy0.dValue != 0.0) {
      yygotominor.yy0.dValue = yymsp[-2].minor.yy0.dValue / yymsp[0].minor.yy0.dValue;
   }
   else pEval->parseError("Div by zero");
   yygotominor.yy0.valid=yymsp[0].minor.yy0.valid; 
}
#line 793 "grammar.c"
        break;
      case 15: /* expr ::= PARENL expr PARENR */
#line 67 "grammar.lemon"
{ yygotominor.yy0.dValue = yymsp[-1].minor.yy0.dValue; yygotominor.yy0.valid=yymsp[-1].minor.yy0.valid; }
#line 798 "grammar.c"
        break;
      default:
      /* (0) main ::= in */ yytestcase(yyruleno==0);
      /* (1) in ::= stmt */ yytestcase(yyruleno==1);
      /* (2) in ::= in stmt */ yytestcase(yyruleno==2);
      /* (3) stmt ::= ENDS */ yytestcase(yyruleno==3);
        break;
/********** End reduce actions ************************************************/
  };
  assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  if( yyact <= YY_MAX_SHIFTREDUCE ){
    if( yyact>YY_MAX_SHIFT ) yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
    /* If the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = (YYACTIONTYPE)yyact;
      yymsp->major = (YYCODETYPE)yygoto;
      yymsp->minor = yygotominor;
      yyTraceShift(yypParser, yyact);
    }else{
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YY_ACCEPT_ACTION );
    yy_accept(yypParser);
  }
}
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
		      yyParser *yypParser,         /* The parser */
		      int yyruleno                 /* Number of the rule by which to reduce */
		      ){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  DSGMASystemParserARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
      && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
	    yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  **
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
  ** without this code, their parser segfaults.  I'm not sure what there
  ** parser is doing to make this happen.  This is the second bug report
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
  ** that it has not been previously stressed...  (SQLite ticket #2172)
  */
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  yygotominor = yyzerominor;


  switch( yyruleno ){
    /* Beginning here are the reduction cases.  A typical example
    ** follows:
    **   case 0:
    **  #line <lineno> <grammarfile>
    **     { ... }           // User supplied code
    **  #line <lineno> <thisfile>
    **     break;
    */
      case 3: /* expression ::= term */
      case 5: /* expression ::= expression PLUS term */ yytestcase(yyruleno==5);
{
        DSGMAParserAuxSetSign(*parser_aux, AUX_SIGN_POSITIVE);
        DSGMAParserAuxNewTerm(*parser_aux);
        *parser_aux = DSGMAParserAuxNextNode(*parser_aux);
}
        break;
      case 4: /* expression ::= MINUS term */
      case 6: /* expression ::= expression MINUS term */ yytestcase(yyruleno==6);
{
        DSGMAParserAuxSetSign(*parser_aux, AUX_SIGN_NEGATIVE);
        DSGMAParserAuxNewTerm(*parser_aux);
        *parser_aux = DSGMAParserAuxNextNode(*parser_aux);
}
        break;
      case 11: /* powerlaw ::= CONSTANT */
{
        DSGMAParserAuxAddConstantBase(*parser_aux, DSExpressionTokenDouble((struct expression_token *)yymsp[0].minor.yy0));
}
        break;
      case 12: /* powerlaw ::= ID */
{
        DSGMAParserAuxAddVariableExponentPair(*parser_aux,
                                              DSExpressionTokenString((struct expression_token *)yymsp[0].minor.yy0), 1.0);
}
        break;
      case 13: /* powerlaw ::= ID POWER CONSTANT */
{
        DSGMAParserAuxAddVariableExponentPair(*parser_aux,
        DSExpressionTokenString((struct expression_token *)yymsp[-2].minor.yy0),
        DSExpressionTokenDouble((struct expression_token *)yymsp[0].minor.yy0));
}
        break;
      case 14: /* powerlaw ::= ID POWER MINUS CONSTANT */
{
        DSGMAParserAuxAddVariableExponentPair(*parser_aux,
        DSExpressionTokenString((struct expression_token *)yymsp[-3].minor.yy0),
        -DSExpressionTokenDouble((struct expression_token *)yymsp[0].minor.yy0));
}
        break;
      default:
      /* (0) start ::= equation */ yytestcase(yyruleno==0);
      /* (1) equation ::= ID PRIME EQUALS expression */ yytestcase(yyruleno==1);
      /* (2) equation ::= CONSTANT EQUALS expression */ yytestcase(yyruleno==2);
      /* (7) term ::= powerlaw */ yytestcase(yyruleno==7);
      /* (8) term ::= PLUS powerlaw */ yytestcase(yyruleno==8);
      /* (9) term ::= term TIMES powerlaw */ yytestcase(yyruleno==9);
      /* (10) term ::= term DIVIDE powerlaw */ yytestcase(yyruleno==10);
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  if( yyact < YYNSTATE ){
#ifdef NDEBUG
    /* If we are not debugging and the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = (YYACTIONTYPE)yyact;
      yymsp->major = (YYCODETYPE)yygoto;
      yymsp->minor = yygotominor;
    }else
#endif
      {
	yy_shift(yypParser,yyact,yygoto,&yygotominor);
      }
  }else{
    assert( yyact == YYNSTATE + YYNRULE + 1 );
    yy_accept(yypParser);
  }
}
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  ssiexprparserARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0
        && (size_t)yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0:
#line 29 "./mod_ssi_exprparser.y"
{
  ctx->val.bo = ssi_val_tobool(yymsp[0].minor.yy29);
  ctx->val.type = SSI_TYPE_BOOL;

  ssi_val_free(yymsp[0].minor.yy29);
}
#line 588 "mod_ssi_exprparser.c"
        break;
      case 1:
#line 36 "./mod_ssi_exprparser.y"
{
  int cmp;

  if (yymsp[-2].minor.yy29->type == SSI_TYPE_STRING &&
      yymsp[0].minor.yy29->type == SSI_TYPE_STRING) {
       cmp = strcmp(yymsp[-2].minor.yy29->str->ptr, yymsp[0].minor.yy29->str->ptr);
  } else {
    cmp = ssi_val_tobool(yymsp[-2].minor.yy29) - ssi_val_tobool(yymsp[0].minor.yy29);
  }

  yygotominor.yy29 = yymsp[-2].minor.yy29;

  switch(yymsp[-1].minor.yy8) {
  case SSI_COND_EQ: yygotominor.yy29->bo = (cmp == 0) ? 1 : 0; break;
  case SSI_COND_NE: yygotominor.yy29->bo = (cmp != 0) ? 1 : 0; break;
  case SSI_COND_GE: yygotominor.yy29->bo = (cmp >= 0) ? 1 : 0; break;
  case SSI_COND_GT: yygotominor.yy29->bo = (cmp > 0) ? 1 : 0; break;
  case SSI_COND_LE: yygotominor.yy29->bo = (cmp <= 0) ? 1 : 0; break;
  case SSI_COND_LT: yygotominor.yy29->bo = (cmp < 0) ? 1 : 0; break;
  }

  yygotominor.yy29->type = SSI_TYPE_BOOL;

  ssi_val_free(yymsp[0].minor.yy29);
}
#line 617 "mod_ssi_exprparser.c"
        break;
      case 2:
#line 61 "./mod_ssi_exprparser.y"
{
  yygotominor.yy29 = yymsp[0].minor.yy29;
}
#line 624 "mod_ssi_exprparser.c"
        break;
      case 3:
#line 64 "./mod_ssi_exprparser.y"
{
  int e;

  e = ssi_val_tobool(yymsp[-2].minor.yy29) && ssi_val_tobool(yymsp[0].minor.yy29);

  yygotominor.yy29 = yymsp[-2].minor.yy29;
  yygotominor.yy29->bo = e;
  yygotominor.yy29->type = SSI_TYPE_BOOL;
  ssi_val_free(yymsp[0].minor.yy29);
}
#line 638 "mod_ssi_exprparser.c"
  yy_destructor(1,&yymsp[-1].minor);
        break;
      case 4:
#line 75 "./mod_ssi_exprparser.y"
{
  int e;

  e = ssi_val_tobool(yymsp[-2].minor.yy29) || ssi_val_tobool(yymsp[0].minor.yy29);

  yygotominor.yy29 = yymsp[-2].minor.yy29;
  yygotominor.yy29->bo = e;
  yygotominor.yy29->type = SSI_TYPE_BOOL;
  ssi_val_free(yymsp[0].minor.yy29);
}
#line 653 "mod_ssi_exprparser.c"
  yy_destructor(2,&yymsp[-1].minor);
        break;
      case 5:
#line 86 "./mod_ssi_exprparser.y"
{
  int e;

  e = !ssi_val_tobool(yymsp[0].minor.yy29);

  yygotominor.yy29 = yymsp[0].minor.yy29;
  yygotominor.yy29->bo = e;
  yygotominor.yy29->type = SSI_TYPE_BOOL;
}
#line 667 "mod_ssi_exprparser.c"
  yy_destructor(9,&yymsp[-1].minor);
        break;
      case 6:
#line 95 "./mod_ssi_exprparser.y"
{
  yygotominor.yy29 = yymsp[-1].minor.yy29;
}
#line 675 "mod_ssi_exprparser.c"
  yy_destructor(10,&yymsp[-2].minor);
  yy_destructor(11,&yymsp[0].minor);
        break;
      case 7:
#line 99 "./mod_ssi_exprparser.y"
{
  yygotominor.yy29 = ssi_val_init();
  yygotominor.yy29->str = yymsp[0].minor.yy19;
  yygotominor.yy29->type = SSI_TYPE_STRING;
}
#line 686 "mod_ssi_exprparser.c"
        break;
      case 8:
#line 105 "./mod_ssi_exprparser.y"
{
  yygotominor.yy19 = yymsp[0].minor.yy0;
}
#line 693 "mod_ssi_exprparser.c"
        break;
      case 9:
#line 109 "./mod_ssi_exprparser.y"
{
  yygotominor.yy19 = yymsp[-1].minor.yy19;
  buffer_append_string_buffer(yygotominor.yy19, yymsp[0].minor.yy0);
  buffer_free(yymsp[0].minor.yy0);
}
#line 702 "mod_ssi_exprparser.c"
        break;
      case 10:
#line 115 "./mod_ssi_exprparser.y"
{ yygotominor.yy8 = SSI_COND_EQ; }
#line 707 "mod_ssi_exprparser.c"
  yy_destructor(3,&yymsp[0].minor);
        break;
      case 11:
#line 116 "./mod_ssi_exprparser.y"
{ yygotominor.yy8 = SSI_COND_NE; }
#line 713 "mod_ssi_exprparser.c"
  yy_destructor(4,&yymsp[0].minor);
        break;
      case 12:
#line 117 "./mod_ssi_exprparser.y"
{ yygotominor.yy8 = SSI_COND_LE; }
#line 719 "mod_ssi_exprparser.c"
  yy_destructor(8,&yymsp[0].minor);
        break;
      case 13:
#line 118 "./mod_ssi_exprparser.y"
{ yygotominor.yy8 = SSI_COND_GE; }
#line 725 "mod_ssi_exprparser.c"
  yy_destructor(6,&yymsp[0].minor);
        break;
      case 14:
#line 119 "./mod_ssi_exprparser.y"
{ yygotominor.yy8 = SSI_COND_LT; }
#line 731 "mod_ssi_exprparser.c"
  yy_destructor(7,&yymsp[0].minor);
        break;
      case 15:
#line 120 "./mod_ssi_exprparser.y"
{ yygotominor.yy8 = SSI_COND_GT; }
#line 737 "mod_ssi_exprparser.c"
  yy_destructor(5,&yymsp[0].minor);
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yypParser,yygoto);
  if( yyact < YYNSTATE ){
    yy_shift(yypParser,yyact,yygoto,&yygotominor);
  }else if( yyact == YYNSTATE + YYNRULE + 1 ){
    yy_accept(yypParser);
  }
}
Esempio n. 14
0
/* The main parser program.
** The first argument is a pointer to a structure obtained from
** "ParseAlloc" which describes the current state of the parser.
** The second argument is the major token number.  The third is
** the minor token.  The fourth optional argument is whatever the
** user wants (and specified in the grammar) and is available for
** use by the action routines.
**
** Inputs:
** <ul>
** <li> A pointer to the parser (an opaque structure.)
** <li> The major token number.
** <li> The minor token number.
** <li> An option argument of a grammar-specified type.
** </ul>
**
** Outputs:
** None.
*/
void
Parse (void *yyp,		/* The parser */
       int yymajor,		/* The major token code number */
       ParseTOKENTYPE yyminor	/* The value for the token */
       ParseARG_PDECL		/* Optional %extra_argument parameter */
    )
{
    YYMINORTYPE yyminorunion;
    int yyact;			/* The parser action. */
    int yyendofinput;		/* True if we are at the end of input */
#ifdef YYERRORSYMBOL
    int yyerrorhit = 0;		/* True if yymajor has invoked an error */
#endif
    yyParser *yypParser;	/* The parser */

    /* (re)initialize the parser, if necessary */
    yypParser = (yyParser *) yyp;
    if (yypParser->yyidx < 0)
      {
#if YYSTACKDEPTH<=0
	  if (yypParser->yystksz <= 0)
	    {
		/*memset(&yyminorunion, 0, sizeof(yyminorunion)); */
		yyminorunion = yyzerominor;
		yyStackOverflow (yypParser, &yyminorunion);
		return;
	    }
#endif
	  yypParser->yyidx = 0;
	  yypParser->yyerrcnt = -1;
	  yypParser->yystack[0].stateno = 0;
	  yypParser->yystack[0].major = 0;
      }
    yyminorunion.yy0 = yyminor;
    yyendofinput = (yymajor == 0);
    ParseARG_STORE;

#ifndef NDEBUG
    if (yyTraceFILE)
      {
	  fprintf (yyTraceFILE, "%sInput %s\n", yyTracePrompt,
		   yyTokenName[yymajor]);
      }
#endif

    do
      {
	  yyact = yy_find_shift_action (yypParser, (YYCODETYPE) yymajor);
	  if (yyact < YYNSTATE)
	    {
		assert (!yyendofinput);	/* Impossible to shift the $ token */
		yy_shift (yypParser, yyact, yymajor, &yyminorunion);
		yypParser->yyerrcnt--;
		yymajor = YYNOCODE;
	    }
	  else if (yyact < YYNSTATE + YYNRULE)
	    {
		yy_reduce (yypParser, yyact - YYNSTATE);
	    }
	  else
	    {
		assert (yyact == YY_ERROR_ACTION);
#ifdef YYERRORSYMBOL
		int yymx;
#endif
#ifndef NDEBUG
		if (yyTraceFILE)
		  {
		      fprintf (yyTraceFILE, "%sSyntax Error!\n", yyTracePrompt);
		  }
#endif
#ifdef YYERRORSYMBOL
		/* A syntax error has occurred.
		 ** The response to an error depends upon whether or not the
		 ** grammar defines an error token "ERROR".  
		 **
		 ** This is what we do if the grammar does define ERROR:
		 **
		 **  * Call the %syntax_error function.
		 **
		 **  * Begin popping the stack until we enter a state where
		 **    it is legal to shift the error symbol, then shift
		 **    the error symbol.
		 **
		 **  * Set the error count to three.
		 **
		 **  * Begin accepting and shifting new tokens.  No new error
		 **    processing will occur until three tokens have been
		 **    shifted successfully.
		 **
		 */
		if (yypParser->yyerrcnt < 0)
		  {
		      yy_syntax_error (yypParser, yymajor, yyminorunion);
		  }
		yymx = yypParser->yystack[yypParser->yyidx].major;
		if (yymx == YYERRORSYMBOL || yyerrorhit)
		  {
#ifndef NDEBUG
		      if (yyTraceFILE)
			{
			    fprintf (yyTraceFILE, "%sDiscard input token %s\n",
				     yyTracePrompt, yyTokenName[yymajor]);
			}
#endif
		      yy_destructor (yypParser, (YYCODETYPE) yymajor,
				     &yyminorunion);
		      yymajor = YYNOCODE;
		  }
		else
		  {
		      while (yypParser->yyidx >= 0 &&
			     yymx != YYERRORSYMBOL &&
			     (yyact =
			      yy_find_reduce_action (yypParser->yystack
						     [yypParser->yyidx].stateno,
						     YYERRORSYMBOL)) >=
			     YYNSTATE)
			{
			    yy_pop_parser_stack (yypParser);
			}
		      if (yypParser->yyidx < 0 || yymajor == 0)
			{
			    yy_destructor (yypParser, (YYCODETYPE) yymajor,
					   &yyminorunion);
			    yy_parse_failed (yypParser);
			    yymajor = YYNOCODE;
			}
		      else if (yymx != YYERRORSYMBOL)
			{
			    YYMINORTYPE u2;
			    u2.YYERRSYMDT = 0;
			    yy_shift (yypParser, yyact, YYERRORSYMBOL, &u2);
			}
		  }
		yypParser->yyerrcnt = 3;
		yyerrorhit = 1;
#elif defined(YYNOERRORRECOVERY)
		/* If the YYNOERRORRECOVERY macro is defined, then do not attempt to
		 ** do any kind of error recovery.  Instead, simply invoke the syntax
		 ** error routine and continue going as if nothing had happened.
		 **
		 ** Applications can set this macro (for example inside %include) if
		 ** they intend to abandon the parse upon the first syntax error seen.
		 */
		yy_syntax_error (yypParser, yymajor, yyminorunion);
		yy_destructor (yypParser, (YYCODETYPE) yymajor, &yyminorunion);
		yymajor = YYNOCODE;

#else /* YYERRORSYMBOL is not defined */
		/* This is what we do if the grammar does not define ERROR:
		 **
		 **  * Report an error message, and throw away the input token.
		 **
		 **  * If the input token is $, then fail the parse.
		 **
		 ** As before, subsequent error messages are suppressed until
		 ** three input tokens have been successfully shifted.
		 */
		if (yypParser->yyerrcnt <= 0)
		  {
		      yy_syntax_error (yypParser, yymajor, yyminorunion);
		  }
		yypParser->yyerrcnt = 3;
		yy_destructor (yypParser, (YYCODETYPE) yymajor, &yyminorunion);
		if (yyendofinput)
		  {
		      yy_parse_failed (yypParser);
		  }
		yymajor = YYNOCODE;
#endif
	    }
      }
    while (yymajor != YYNOCODE && yypParser->yyidx >= 0);
    return;
}
Esempio n. 15
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
    yyParser *yypParser,         /* The parser */
    int yyruleno                 /* Number of the rule by which to reduce */
) {
    int yygoto;                     /* The next state */
    int yyact;                      /* The next action */
    YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
    yyStackEntry *yymsp;            /* The top of the parser's stack */
    int yysize;                     /* Amount to pop the stack */
    CLIParserARG_FETCH;
    yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
    if( yyTraceFILE && yyruleno>=0
            && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ) {
        fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
                yyRuleName[yyruleno]);
    }
#endif /* NDEBUG */

    /* Silence complaints from purify about yygotominor being uninitialized
    ** in some cases when it is copied into the stack after the following
    ** switch.  yygotominor is uninitialized when a rule reduces that does
    ** not set the value of its left-hand side nonterminal.  Leaving the
    ** value of the nonterminal uninitialized is utterly harmless as long
    ** as the value is never used.  So really the only thing this code
    ** accomplishes is to quieten purify.
    **
    ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
    ** without this code, their parser segfaults.  I'm not sure what there
    ** parser is doing to make this happen.  This is the second bug report
    ** from wireshark this week.  Clearly they are stressing Lemon in ways
    ** that it has not been previously stressed...  (SQLite ticket #2172)
    */
    /*memset(&yygotominor, 0, sizeof(yygotominor));*/
    yygotominor = yyzerominor;


    switch( yyruleno ) {
    /* Beginning here are the reduction cases.  A typical example
    ** follows:
    **   case 0:
    **  #line <lineno> <grammarfile>
    **     { ... }           // User supplied code
    **  #line <lineno> <thisfile>
    **     break;
    */
    case 1: /* commands ::= commands command */
#line 41 "CLIParser.y"
        {
            commands->push_back(Pointer<CLICommand>(yymsp[0].minor.yy78));
        }
#line 801 "CLIParser.c"
        break;
    case 3: /* command ::= KEYWORD_RULE rule_command */
#line 46 "CLIParser.y"
        {   yygotominor.yy78 = yymsp[0].minor.yy78;
            yy_destructor(yypParser,3,&yymsp[-1].minor);
        }
#line 807 "CLIParser.c"
        break;
    case 4: /* command ::= KEYWORD_DEVICE device_command */
#line 47 "CLIParser.y"
        {   yygotominor.yy78 = yymsp[0].minor.yy78;
            yy_destructor(yypParser,4,&yymsp[-1].minor);
        }
#line 813 "CLIParser.c"
        break;
    case 5: /* rule_command ::= KEYWORD_APPEND string rule_append_options */
#line 52 "CLIParser.y"
        {
            yygotominor.yy78 = new RuleAppend(*yymsp[-1].minor.yy5, *yymsp[0].minor.yy39);
            delete yymsp[0].minor.yy39;
            yy_destructor(yypParser,5,&yymsp[-2].minor);
        }
#line 822 "CLIParser.c"
        break;
    case 6: /* rule_append_options ::= rule_append_options OPTION_PARENT seqn_value */
#line 57 "CLIParser.y"
        {
            yygotominor.yy39 = yymsp[-2].minor.yy39;
            yygotominor.yy39->parent_seqn = yymsp[0].minor.yy63;
            yy_destructor(yypParser,6,&yymsp[-1].minor);
        }
#line 831 "CLIParser.c"
        break;
    case 7: /* rule_append_options ::= rule_append_options OPTION_TIMEOUT timeout_value */
#line 62 "CLIParser.y"
        {
            yygotominor.yy39 = yymsp[-2].minor.yy39;
            yygotominor.yy39->timeout = yymsp[0].minor.yy63;
            yy_destructor(yypParser,7,&yymsp[-1].minor);
        }
#line 840 "CLIParser.c"
        break;
    case 8: /* rule_append_options ::= rule_append_options OPTION_PERMANENT boolean_value */
#line 67 "CLIParser.y"
        {
            yygotominor.yy39 = yymsp[-2].minor.yy39;
            yygotominor.yy39->permanent = yymsp[0].minor.yy65;
            yy_destructor(yypParser,8,&yymsp[-1].minor);
        }
#line 849 "CLIParser.c"
        break;
    case 9: /* rule_append_options ::= */
#line 72 "CLIParser.y"
        {
            yygotominor.yy39 = new RuleAppend::Options();
        }
#line 856 "CLIParser.c"
        break;
    case 10: /* rule_command ::= KEYWORD_REMOVE rule_remove_args */
#line 80 "CLIParser.y"
        {
            yy_destructor(yypParser,9,&yymsp[-1].minor);
        }
#line 863 "CLIParser.c"
        break;
    case 12: /* rule_command ::= KEYWORD_LIST */
    case 13: /* device_command ::= KEYWORD_LIST */
        yytestcase(yyruleno==13);
#line 86 "CLIParser.y"
        {
            yy_destructor(yypParser,10,&yymsp[0].minor);
        }
#line 871 "CLIParser.c"
        break;
    case 14: /* device_command ::= KEYWORD_RULE seqn_value */
#line 96 "CLIParser.y"
        {
            yy_destructor(yypParser,3,&yymsp[-1].minor);
        }
#line 878 "CLIParser.c"
        break;
    case 15: /* device_command ::= KEYWORD_HASH seqn_value */
#line 101 "CLIParser.y"
        {
            yy_destructor(yypParser,11,&yymsp[-1].minor);
        }
#line 885 "CLIParser.c"
        break;
    case 16: /* device_command ::= KEYWORD_SET_POLICY seqn_value target_value device_set_policy_options */
#line 106 "CLIParser.y"
        {
            yy_destructor(yypParser,12,&yymsp[-3].minor);
            yy_destructor(yypParser,29,&yymsp[0].minor);
        }
#line 893 "CLIParser.c"
        break;
    case 17: /* device_set_policy_options ::= device_set_policy_options device_set_policy_option */
#line 107 "CLIParser.y"
        {
            yy_destructor(yypParser,29,&yymsp[-1].minor);
        }
#line 900 "CLIParser.c"
        break;
    case 19: /* device_set_policy_option ::= OPTION_TIMEOUT timeout_value */
#line 109 "CLIParser.y"
        {
            yy_destructor(yypParser,7,&yymsp[-1].minor);
        }
#line 907 "CLIParser.c"
        break;
    case 20: /* device_set_policy_option ::= OPTION_PERMANENT boolean_value */
#line 110 "CLIParser.y"
        {
            yy_destructor(yypParser,8,&yymsp[-1].minor);
        }
#line 914 "CLIParser.c"
        break;
    case 21: /* device_set_policy_option ::= OPTION_PERMANENT */
#line 111 "CLIParser.y"
        {
            yy_destructor(yypParser,8,&yymsp[0].minor);
        }
#line 921 "CLIParser.c"
        break;
    case 22: /* seqn_value ::= NUMBER_UNSIGNED_INTEGER */
#line 116 "CLIParser.y"
        {
            yy_destructor(yypParser,13,&yymsp[0].minor);
        }
#line 928 "CLIParser.c"
        break;
    case 23: /* seqn_value ::= KEYWORD_LAST */
#line 117 "CLIParser.y"
        {
            yy_destructor(yypParser,14,&yymsp[0].minor);
        }
#line 935 "CLIParser.c"
        break;
    case 24: /* seqn_value ::= KEYWORD_ROOT */
#line 118 "CLIParser.y"
        {
            yy_destructor(yypParser,15,&yymsp[0].minor);
        }
#line 942 "CLIParser.c"
        break;
    case 25: /* timeout_value ::= NUMBER_UNSIGNED_INTEGER */
#line 120 "CLIParser.y"
        {
            yygotominor.yy63 = stringToNumber<uint32_t>(*yymsp[0].minor.yy0, 10);
        }
#line 949 "CLIParser.c"
        break;
    case 26: /* timeout_value ::= NUMBER_HOURS */
#line 124 "CLIParser.y"
        {
            yygotominor.yy63 = stringToNumber<uint32_t>(*yymsp[0].minor.yy0, 10);
            yygotominor.yy63 = yygotominor.yy63 * 60 * 60;
        }
#line 957 "CLIParser.c"
        break;
    case 27: /* timeout_value ::= NUMBER_MINUTES */
#line 129 "CLIParser.y"
        {
            yygotominor.yy63 = stringToNumber<uint32_t>(*yymsp[0].minor.yy0, 10);
            yygotominor.yy63 = yygotominor.yy63 * 60;
        }
#line 965 "CLIParser.c"
        break;
    case 28: /* timeout_value ::= NUMBER_DAYS */
#line 134 "CLIParser.y"
        {
            yygotominor.yy63 = stringToNumber<uint32_t>(*yymsp[0].minor.yy0, 10);
            yygotominor.yy63 = yygotominor.yy63 * 60 * 60 * 24;
        }
#line 973 "CLIParser.c"
        break;
    case 29: /* boolean_value ::= KEYWORD_FALSE */
#line 139 "CLIParser.y"
        {
            yygotominor.yy65 = false;
            yy_destructor(yypParser,19,&yymsp[0].minor);
        }
#line 981 "CLIParser.c"
        break;
    case 30: /* boolean_value ::= KEYWORD_TRUE */
#line 143 "CLIParser.y"
        {
            yygotominor.yy65 = true;
            yy_destructor(yypParser,20,&yymsp[0].minor);
        }
#line 989 "CLIParser.c"
        break;
    case 31: /* target_value ::= string */
#line 147 "CLIParser.y"
        {
            yy_destructor(yypParser,33,&yymsp[0].minor);
        }
#line 996 "CLIParser.c"
        break;
    case 32: /* string ::= STRING */
#line 149 "CLIParser.y"
        {
            yygotominor.yy5 = new std::string(*yymsp[0].minor.yy0);
        }
#line 1003 "CLIParser.c"
        break;
    case 33: /* string ::= DQ_STRING_BEGIN STRING DQ_STRING_END */
#line 153 "CLIParser.y"
        {
            yygotominor.yy5 = new std::string(*yymsp[-1].minor.yy0);
            yy_destructor(yypParser,22,&yymsp[-2].minor);
            yy_destructor(yypParser,23,&yymsp[0].minor);
        }
#line 1012 "CLIParser.c"
        break;
    default:
        /* (0) cli ::= commands */
        yytestcase(yyruleno==0);
        /* (2) commands ::= */ yytestcase(yyruleno==2);
        /* (11) rule_remove_args ::= seqn_value */ yytestcase(yyruleno==11);
        /* (18) device_set_policy_options ::= */ yytestcase(yyruleno==18);
        break;
    };
    yygoto = yyRuleInfo[yyruleno].lhs;
    yysize = yyRuleInfo[yyruleno].nrhs;
    yypParser->yyidx -= yysize;
    yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
    if( yyact < YYNSTATE ) {
#ifdef NDEBUG
        /* If we are not debugging and the reduce action popped at least
        ** one element off the stack, then we can push the new element back
        ** onto the stack here, and skip the stack overflow test in yy_shift().
        ** That gives a significant speed improvement. */
        if( yysize ) {
            yypParser->yyidx++;
            yymsp -= yysize-1;
            yymsp->stateno = (YYACTIONTYPE)yyact;
            yymsp->major = (YYCODETYPE)yygoto;
            yymsp->minor = yygotominor;
        } else
#endif
        {
            yy_shift(yypParser,yyact,yygoto,&yygotominor);
        }
    } else {
        assert( yyact == YYNSTATE + YYNRULE + 1 );
        yy_accept(yypParser);
    }
}
Esempio n. 16
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void
yy_reduce (yyParser * yypParser,	/* The parser */
	   int yyruleno		/* Number of the rule by which to reduce */
    )
{
    int yygoto;			/* The next state */
    int yyact;			/* The next action */
    YYMINORTYPE yygotominor;	/* The LHS of the rule reduced */
    yyStackEntry *yymsp;	/* The top of the parser's stack */
    int yysize;			/* Amount to pop the stack */
    ParseARG_FETCH;
    yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
    if (yyTraceFILE && yyruleno >= 0
	&& yyruleno < (int) (sizeof (yyRuleName) / sizeof (yyRuleName[0])))
      {
	  fprintf (yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
		   yyRuleName[yyruleno]);
      }
#endif /* NDEBUG */

    /* Silence complaints from purify about yygotominor being uninitialized
     ** in some cases when it is copied into the stack after the following
     ** switch.  yygotominor is uninitialized when a rule reduces that does
     ** not set the value of its left-hand side nonterminal.  Leaving the
     ** value of the nonterminal uninitialized is utterly harmless as long
     ** as the value is never used.  So really the only thing this code
     ** accomplishes is to quieten purify.  
     **
     ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
     ** without this code, their parser segfaults.  I'm not sure what there
     ** parser is doing to make this happen.  This is the second bug report
     ** from wireshark this week.  Clearly they are stressing Lemon in ways
     ** that it has not been previously stressed...  (SQLite ticket #2172)
     */
    /*memset(&yygotominor, 0, sizeof(yygotominor)); */
    yygotominor = yyzerominor;


    switch (yyruleno)
      {
	  /* Beginning here are the reduction cases.  A typical example
	   ** follows:
	   **   case 0:
	   **  #line <lineno> <grammarfile>
	   **     { ... }           // User supplied code
	   **  #line <lineno> <thisfile>
	   **     break;
	   */
      case 5:			/* gml_tree ::= node */
      case 6:			/* gml_tree ::= node_chain */
	  yytestcase (yyruleno == 6);
	  {
	      p_data->result = yymsp[0].minor.yy0;
	  }
	  break;
      case 7:			/* node ::= open_tag GML_END GML_CLOSE */
	  {
	      yygotominor.yy0 =
		  gml_createSelfClosedNode (p_data,
					    (void *) yymsp[-2].minor.yy0, NULL);
	  }
	  break;
      case 8:			/* node ::= open_tag attr GML_END GML_CLOSE */
      case 9:			/* node ::= open_tag attributes GML_END GML_CLOSE */
	  yytestcase (yyruleno == 9);
	  {
	      yygotominor.yy0 =
		  gml_createSelfClosedNode (p_data,
					    (void *) yymsp[-3].minor.yy0,
					    (void *) yymsp[-2].minor.yy0);
	  }
	  break;
      case 10:			/* node ::= open_tag GML_CLOSE */
	  {
	      yygotominor.yy0 =
		  gml_createNode (p_data, (void *) yymsp[-1].minor.yy0, NULL,
				  NULL);
	  }
	  break;
      case 11:			/* node ::= open_tag attr GML_CLOSE */
      case 12:			/* node ::= open_tag attributes GML_CLOSE */
	  yytestcase (yyruleno == 12);
	  {
	      yygotominor.yy0 =
		  gml_createNode (p_data, (void *) yymsp[-2].minor.yy0,
				  (void *) yymsp[-1].minor.yy0, NULL);
	  }
	  break;
      case 13:			/* node ::= open_tag GML_CLOSE coord */
      case 14:			/* node ::= open_tag GML_CLOSE coord_chain */
	  yytestcase (yyruleno == 14);
	  {
	      yygotominor.yy0 =
		  gml_createNode (p_data, (void *) yymsp[-2].minor.yy0, NULL,
				  (void *) yymsp[0].minor.yy0);
	  }
	  break;
      case 15:			/* node ::= open_tag attr GML_CLOSE coord */
      case 16:			/* node ::= open_tag attr GML_CLOSE coord_chain */
	  yytestcase (yyruleno == 16);
      case 17:			/* node ::= open_tag attributes GML_CLOSE coord */
	  yytestcase (yyruleno == 17);
      case 18:			/* node ::= open_tag attributes GML_CLOSE coord_chain */
	  yytestcase (yyruleno == 18);
	  {
	      yygotominor.yy0 =
		  gml_createNode (p_data, (void *) yymsp[-3].minor.yy0,
				  (void *) yymsp[-2].minor.yy0,
				  (void *) yymsp[0].minor.yy0);
	  }
	  break;
      case 19:			/* node ::= close_tag */
	  {
	      yygotominor.yy0 =
		  gml_closingNode (p_data, (void *) yymsp[0].minor.yy0);
	  }
	  break;
      case 20:			/* open_tag ::= GML_OPEN keyword */
      case 22:			/* keyword ::= GML_KEYWORD */
	  yytestcase (yyruleno == 22);
	  {
	      yygotominor.yy0 = yymsp[0].minor.yy0;
	  }
	  break;
      case 21:			/* close_tag ::= GML_OPEN GML_END keyword GML_CLOSE */
	  {
	      yygotominor.yy0 = yymsp[-1].minor.yy0;
	  }
	  break;
      case 23:			/* extra_nodes ::= */
      case 27:			/* extra_attr ::= */
	  yytestcase (yyruleno == 27);
      case 31:			/* extra_coord ::= */
	  yytestcase (yyruleno == 31);
	  {
	      yygotominor.yy0 = NULL;
	  }
	  break;
      case 24:			/* extra_nodes ::= node extra_nodes */
	  {
	      ((gmlNodePtr) yymsp[-1].minor.yy0)->Next =
		  (gmlNodePtr) yymsp[0].minor.yy0;
	      yygotominor.yy0 = yymsp[-1].minor.yy0;
	  }
	  break;
      case 25:			/* node_chain ::= node node extra_nodes */
	  {
	      ((gmlNodePtr) yymsp[-1].minor.yy0)->Next =
		  (gmlNodePtr) yymsp[0].minor.yy0;
	      ((gmlNodePtr) yymsp[-2].minor.yy0)->Next =
		  (gmlNodePtr) yymsp[-1].minor.yy0;
	      yygotominor.yy0 = yymsp[-2].minor.yy0;
	  }
	  break;
      case 26:			/* attr ::= GML_KEYWORD GML_EQ GML_VALUE */
	  {
	      yygotominor.yy0 =
		  gml_attribute (p_data, (void *) yymsp[-2].minor.yy0,
				 (void *) yymsp[0].minor.yy0);
	  }
	  break;
      case 28:			/* extra_attr ::= attr extra_attr */
	  {
	      ((gmlAttrPtr) yymsp[-1].minor.yy0)->Next =
		  (gmlAttrPtr) yymsp[0].minor.yy0;
	      yygotominor.yy0 = yymsp[-1].minor.yy0;
	  }
	  break;
      case 29:			/* attributes ::= attr attr extra_attr */
	  {
	      ((gmlAttrPtr) yymsp[-1].minor.yy0)->Next =
		  (gmlAttrPtr) yymsp[0].minor.yy0;
	      ((gmlAttrPtr) yymsp[-2].minor.yy0)->Next =
		  (gmlAttrPtr) yymsp[-1].minor.yy0;
	      yygotominor.yy0 = yymsp[-2].minor.yy0;
	  }
	  break;
      case 30:			/* coord ::= GML_COORD */
	  {
	      yygotominor.yy0 = gml_coord (p_data, (void *) yymsp[0].minor.yy0);
	  }
	  break;
      case 32:			/* extra_coord ::= coord extra_coord */
	  {
	      ((gmlCoordPtr) yymsp[-1].minor.yy0)->Next =
		  (gmlCoordPtr) yymsp[0].minor.yy0;
	      yygotominor.yy0 = yymsp[-1].minor.yy0;
	  }
	  break;
      case 33:			/* coord_chain ::= coord coord extra_coord */
	  {
	      ((gmlCoordPtr) yymsp[-1].minor.yy0)->Next =
		  (gmlCoordPtr) yymsp[0].minor.yy0;
	      ((gmlCoordPtr) yymsp[-2].minor.yy0)->Next =
		  (gmlCoordPtr) yymsp[-1].minor.yy0;
	      yygotominor.yy0 = yymsp[-2].minor.yy0;
	  }
	  break;
      default:
	  /* (0) main ::= in */ yytestcase (yyruleno == 0);
	  /* (1) in ::= */ yytestcase (yyruleno == 1);
	  /* (2) in ::= in state GML_NEWLINE */ yytestcase (yyruleno == 2);
	  /* (3) state ::= program */ yytestcase (yyruleno == 3);
	  /* (4) program ::= gml_tree */ yytestcase (yyruleno == 4);
	  break;
      };
    yygoto = yyRuleInfo[yyruleno].lhs;
    yysize = yyRuleInfo[yyruleno].nrhs;
    yypParser->yyidx -= yysize;
    yyact = yy_find_reduce_action (yymsp[-yysize].stateno, (YYCODETYPE) yygoto);
    if (yyact < YYNSTATE)
      {
#ifdef NDEBUG
	  /* If we are not debugging and the reduce action popped at least
	   ** one element off the stack, then we can push the new element back
	   ** onto the stack here, and skip the stack overflow test in yy_shift().
	   ** That gives a significant speed improvement. */
	  if (yysize)
	    {
		yypParser->yyidx++;
		yymsp -= yysize - 1;
		yymsp->stateno = (YYACTIONTYPE) yyact;
		yymsp->major = (YYCODETYPE) yygoto;
		yymsp->minor = yygotominor;
	    }
	  else
#endif
	    {
		yy_shift (yypParser, yyact, yygoto, &yygotominor);
	    }
      }
    else
      {
	  assert (yyact == YYNSTATE + YYNRULE + 1);
	  yy_accept (yypParser);
      }
}
Esempio n. 17
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  ParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  **
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
  ** without this code, their parser segfaults.  I'm not sure what there
  ** parser is doing to make this happen.  This is the second bug report
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
  ** that it has not been previously stressed...  (SQLite ticket #2172)
  */
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  yygotominor = yyzerominor;


  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0: /* config ::= vars */
#line 30 "src/parser.y"
{ state->settings = yymsp[0].minor.yy13; }
#line 754 "src/parser.c"
        break;
      case 1: /* vars ::= vars assignment */
#line 34 "src/parser.y"
{ 
        yygotominor.yy13 = tst_insert(yymsp[-1].minor.yy13, bdata(yymsp[0].minor.yy7->key->data), blength(yymsp[0].minor.yy7->key->data), yymsp[0].minor.yy7);
    }
#line 761 "src/parser.c"
        break;
      case 2: /* vars ::= assignment */
#line 39 "src/parser.y"
{
        yygotominor.yy13 = tst_insert(yygotominor.yy13, bdata(yymsp[0].minor.yy7->key->data), blength(yymsp[0].minor.yy7->key->data), yymsp[0].minor.yy7);
    }
#line 768 "src/parser.c"
        break;
      case 3: /* vars ::= vars EOF */
#line 43 "src/parser.y"
{ yygotominor.yy13 = yymsp[-1].minor.yy13;   yy_destructor(yypParser,1,&yymsp[0].minor);
}
#line 774 "src/parser.c"
        break;
      case 4: /* expr ::= QSTRING */
#line 47 "src/parser.y"
{ yygotominor.yy8 = Value_create(VAL_QSTRING, yymsp[0].minor.yy0); }
#line 779 "src/parser.c"
        break;
      case 5: /* expr ::= NUMBER */
#line 48 "src/parser.y"
{ yygotominor.yy8 = Value_create(VAL_NUMBER, yymsp[0].minor.yy0); }
#line 784 "src/parser.c"
        break;
      case 6: /* expr ::= class */
#line 49 "src/parser.y"
{ yygotominor.yy8 = Value_create(VAL_CLASS, yymsp[0].minor.yy11); }
#line 789 "src/parser.c"
        break;
      case 7: /* expr ::= list */
#line 50 "src/parser.y"
{ yygotominor.yy8 = Value_create(VAL_LIST, yymsp[0].minor.yy46); }
#line 794 "src/parser.c"
        break;
      case 8: /* expr ::= hash */
#line 51 "src/parser.y"
{ yygotominor.yy8 = Value_create(VAL_HASH, yymsp[0].minor.yy13); }
#line 799 "src/parser.c"
        break;
      case 9: /* expr ::= IDENT */
#line 52 "src/parser.y"
{ yygotominor.yy8 = Value_create(VAL_REF, yymsp[0].minor.yy0); }
#line 804 "src/parser.c"
        break;
      case 10: /* assignment ::= IDENT EQ expr */
#line 57 "src/parser.y"
{ 
        yygotominor.yy7 = malloc(sizeof(Pair)); yygotominor.yy7->key = yymsp[-2].minor.yy0; yygotominor.yy7->value = yymsp[0].minor.yy8; 
      yy_destructor(yypParser,5,&yymsp[-1].minor);
}
#line 812 "src/parser.c"
        break;
      case 11: /* class ::= CLASS LPAREN parameters RPAREN */
#line 64 "src/parser.y"
{ yygotominor.yy11 = calloc(sizeof(Class), 1); yygotominor.yy11->id = -1; yygotominor.yy11->ident = yymsp[-3].minor.yy0; yygotominor.yy11->params = yymsp[-1].minor.yy13;   yy_destructor(yypParser,7,&yymsp[-2].minor);
  yy_destructor(yypParser,8,&yymsp[0].minor);
}
#line 819 "src/parser.c"
        break;
      case 12: /* parameters ::= parameters COMMA assignment */
#line 69 "src/parser.y"
{ yygotominor.yy13 = tst_insert(yymsp[-2].minor.yy13, bdata(yymsp[0].minor.yy7->key->data), blength(yymsp[0].minor.yy7->key->data), yymsp[0].minor.yy7);   yy_destructor(yypParser,9,&yymsp[-1].minor);
}
#line 825 "src/parser.c"
        break;
      case 13: /* parameters ::= parameters assignment */
#line 72 "src/parser.y"
{ yygotominor.yy13 = tst_insert(yymsp[-1].minor.yy13, bdata(yymsp[0].minor.yy7->key->data), blength(yymsp[0].minor.yy7->key->data), yymsp[0].minor.yy7); }
#line 830 "src/parser.c"
        break;
      case 14: /* parameters ::= */
      case 22: /* hash_elements ::= */ yytestcase(yyruleno==22);
#line 75 "src/parser.y"
{ yygotominor.yy13 = NULL; }
#line 836 "src/parser.c"
        break;
      case 15: /* list ::= LBRACE list_elements RBRACE */
#line 79 "src/parser.y"
{ yygotominor.yy46 = yymsp[-1].minor.yy46;   yy_destructor(yypParser,10,&yymsp[-2].minor);
  yy_destructor(yypParser,11,&yymsp[0].minor);
}
#line 843 "src/parser.c"
        break;
      case 16: /* list_elements ::= list_elements COMMA expr */
#line 83 "src/parser.y"
{ yygotominor.yy46 = yymsp[-2].minor.yy46; list_append(yygotominor.yy46, lnode_create(yymsp[0].minor.yy8));   yy_destructor(yypParser,9,&yymsp[-1].minor);
}
#line 849 "src/parser.c"
        break;
      case 17: /* list_elements ::= list_elements expr */
#line 86 "src/parser.y"
{ yygotominor.yy46 = yymsp[-1].minor.yy46; list_append(yygotominor.yy46, lnode_create(yymsp[0].minor.yy8)); }
#line 854 "src/parser.c"
        break;
      case 18: /* list_elements ::= */
#line 89 "src/parser.y"
{ yygotominor.yy46 = list_create(LISTCOUNT_T_MAX); }
#line 859 "src/parser.c"
        break;
      case 19: /* hash ::= LBRACKET hash_elements RBRACKET */
#line 93 "src/parser.y"
{ yygotominor.yy13 = yymsp[-1].minor.yy13;   yy_destructor(yypParser,12,&yymsp[-2].minor);
  yy_destructor(yypParser,13,&yymsp[0].minor);
}
#line 866 "src/parser.c"
        break;
      case 20: /* hash_elements ::= hash_elements COMMA hash_pair */
#line 97 "src/parser.y"
{ yygotominor.yy13 = tst_insert(yymsp[-2].minor.yy13, bdata(yymsp[0].minor.yy17->key->data), blength(yymsp[0].minor.yy17->key->data), yymsp[0].minor.yy17);   yy_destructor(yypParser,9,&yymsp[-1].minor);
}
#line 872 "src/parser.c"
        break;
      case 21: /* hash_elements ::= hash_elements hash_pair */
#line 100 "src/parser.y"
{ yygotominor.yy13 = tst_insert(yymsp[-1].minor.yy13, bdata(yymsp[0].minor.yy17->key->data), blength(yymsp[0].minor.yy17->key->data), yymsp[0].minor.yy17); }
#line 877 "src/parser.c"
        break;
      case 23: /* hash_pair ::= QSTRING COLON expr */
#line 108 "src/parser.y"
{ 
        yygotominor.yy17 = malloc(sizeof(Pair)); yygotominor.yy17->key = yymsp[-2].minor.yy0; yygotominor.yy17->value = yymsp[0].minor.yy8; 
      yy_destructor(yypParser,14,&yymsp[-1].minor);
}
#line 885 "src/parser.c"
        break;
      default:
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  if( yyact < YYNSTATE ){
#ifdef NDEBUG
    /* If we are not debugging and the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = (YYACTIONTYPE)yyact;
      yymsp->major = (YYCODETYPE)yygoto;
      yymsp->minor = yygotominor;
    }else
#endif
    {
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YYNSTATE + YYNRULE + 1 );
    yy_accept(yypParser);
  }
}
Esempio n. 18
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  configparserARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0
        && yyruleno<sizeof(yyRuleName)/sizeof(yyRuleName[0]) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 0:
        /* No destructor defined for metalines */
        break;
      case 1:
        /* No destructor defined for metalines */
        /* No destructor defined for metaline */
        break;
      case 2:
        break;
      case 3:
        /* No destructor defined for varline */
        break;
      case 4:
        /* No destructor defined for global */
        break;
      case 5:
#line 115 "./configparser.y"
{ yymsp[-1].minor.yy78 = NULL; }
#line 822 "configparser.c"
  yy_destructor(1,&yymsp[0].minor);
        break;
      case 6:
        /* No destructor defined for include */
        break;
      case 7:
        /* No destructor defined for include_shell */
        break;
      case 8:
  yy_destructor(1,&yymsp[0].minor);
        break;
      case 9:
#line 144 "./configparser.y"
{
  if (ctx->ok) {
    buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43);
    if (strncmp(yymsp[-2].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) {
      fprintf(stderr, "Setting env variable is not supported in conditional %d %s: %s\n",
          ctx->current->context_ndx,
          ctx->current->key->ptr, yymsp[-2].minor.yy43->ptr);
      ctx->ok = 0;
    } else if (NULL == array_get_element(ctx->current->value, yymsp[0].minor.yy41->key->ptr)) {
      array_insert_unique(ctx->current->value, yymsp[0].minor.yy41);
      yymsp[0].minor.yy41 = NULL;
    } else {
      fprintf(stderr, "Duplicate config variable in conditional %d %s: %s\n",
              ctx->current->context_ndx,
              ctx->current->key->ptr, yymsp[0].minor.yy41->key->ptr);
      ctx->ok = 0;
      yymsp[0].minor.yy41->free(yymsp[0].minor.yy41);
      yymsp[0].minor.yy41 = NULL;
    }
  }
  buffer_free(yymsp[-2].minor.yy43);
  yymsp[-2].minor.yy43 = NULL;
}
#line 859 "configparser.c"
  yy_destructor(2,&yymsp[-1].minor);
        break;
      case 10:
#line 168 "./configparser.y"
{
  array *vars = ctx->current->value;
  data_unset *du;

  if (strncmp(yymsp[-2].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) {
    fprintf(stderr, "Appending env variable is not supported in conditional %d %s: %s\n",
        ctx->current->context_ndx,
        ctx->current->key->ptr, yymsp[-2].minor.yy43->ptr);
    ctx->ok = 0;
  } else if (NULL != (du = array_get_element(vars, yymsp[-2].minor.yy43->ptr))) {
    /* exists in current block */
    du = configparser_merge_data(du, yymsp[0].minor.yy41);
    if (NULL == du) {
      ctx->ok = 0;
    }
    else {
      buffer_copy_string_buffer(du->key, yymsp[-2].minor.yy43);
      array_replace(vars, du);
    }
    yymsp[0].minor.yy41->free(yymsp[0].minor.yy41);
  } else if (NULL != (du = configparser_get_variable(ctx, yymsp[-2].minor.yy43))) {
    du = configparser_merge_data(du, yymsp[0].minor.yy41);
    if (NULL == du) {
      ctx->ok = 0;
      du->free(du);
    }
    else {
      buffer_copy_string_buffer(du->key, yymsp[-2].minor.yy43);
      array_insert_unique(ctx->current->value, du);
    }
    yymsp[0].minor.yy41->free(yymsp[0].minor.yy41);
  } else {
    buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43);
    array_insert_unique(ctx->current->value, yymsp[0].minor.yy41);
  }
  buffer_free(yymsp[-2].minor.yy43);
  yymsp[-2].minor.yy43 = NULL;
  yymsp[0].minor.yy41 = NULL;
}
#line 903 "configparser.c"
  yy_destructor(3,&yymsp[-1].minor);
        break;
      case 11:
#line 208 "./configparser.y"
{
  if (strchr(yymsp[0].minor.yy0->ptr, '.') == NULL) {
    yygotominor.yy43 = buffer_init_string("var.");
    buffer_append_string_buffer(yygotominor.yy43, yymsp[0].minor.yy0);
    buffer_free(yymsp[0].minor.yy0);
    yymsp[0].minor.yy0 = NULL;
  } else {
    yygotominor.yy43 = yymsp[0].minor.yy0;
    yymsp[0].minor.yy0 = NULL;
  }
}
#line 919 "configparser.c"
        break;
      case 12:
#line 220 "./configparser.y"
{
  yygotominor.yy41 = configparser_merge_data(yymsp[-2].minor.yy41, yymsp[0].minor.yy41);
  if (NULL == yygotominor.yy41) {
    ctx->ok = 0;
  }
  yymsp[-2].minor.yy41 = NULL;
  yymsp[0].minor.yy41->free(yymsp[0].minor.yy41);
  yymsp[0].minor.yy41 = NULL;
}
#line 932 "configparser.c"
  yy_destructor(5,&yymsp[-1].minor);
        break;
      case 13:
#line 230 "./configparser.y"
{
  yygotominor.yy41 = yymsp[0].minor.yy41;
  yymsp[0].minor.yy41 = NULL;
}
#line 941 "configparser.c"
        break;
      case 14:
#line 235 "./configparser.y"
{
  yygotominor.yy41 = NULL;
  if (strncmp(yymsp[0].minor.yy43->ptr, "env.", sizeof("env.") - 1) == 0) {
    char *env;

    if (NULL != (env = getenv(yymsp[0].minor.yy43->ptr + 4))) {
      data_string *ds;
      ds = data_string_init();
      buffer_append_string(ds->value, env);
      yygotominor.yy41 = (data_unset *)ds;
    }
    else {
      fprintf(stderr, "Undefined env variable: %s\n", yymsp[0].minor.yy43->ptr + 4);
      ctx->ok = 0;
    }
  } else if (NULL == (yygotominor.yy41 = configparser_get_variable(ctx, yymsp[0].minor.yy43))) {
    fprintf(stderr, "Undefined config variable: %s\n", yymsp[0].minor.yy43->ptr);
    ctx->ok = 0;
  }
  if (!yygotominor.yy41) {
    /* make a dummy so it won't crash */
    yygotominor.yy41 = (data_unset *)data_string_init();
  }
  buffer_free(yymsp[0].minor.yy43);
  yymsp[0].minor.yy43 = NULL;
}
#line 971 "configparser.c"
        break;
      case 15:
#line 262 "./configparser.y"
{
  yygotominor.yy41 = (data_unset *)data_string_init();
  buffer_copy_string_buffer(((data_string *)(yygotominor.yy41))->value, yymsp[0].minor.yy0);
  buffer_free(yymsp[0].minor.yy0);
  yymsp[0].minor.yy0 = NULL;
}
#line 981 "configparser.c"
        break;
      case 16:
#line 269 "./configparser.y"
{
  yygotominor.yy41 = (data_unset *)data_integer_init();
  ((data_integer *)(yygotominor.yy41))->value = strtol(yymsp[0].minor.yy0->ptr, NULL, 10);
  buffer_free(yymsp[0].minor.yy0);
  yymsp[0].minor.yy0 = NULL;
}
#line 991 "configparser.c"
        break;
      case 17:
#line 275 "./configparser.y"
{
  yygotominor.yy41 = (data_unset *)data_array_init();
  array_free(((data_array *)(yygotominor.yy41))->value);
  ((data_array *)(yygotominor.yy41))->value = yymsp[0].minor.yy40;
  yymsp[0].minor.yy40 = NULL;
}
#line 1001 "configparser.c"
        break;
      case 18:
#line 281 "./configparser.y"
{
  yygotominor.yy40 = array_init();
}
#line 1008 "configparser.c"
  yy_destructor(8,&yymsp[-1].minor);
  yy_destructor(9,&yymsp[0].minor);
        break;
      case 19:
#line 284 "./configparser.y"
{
  yygotominor.yy40 = yymsp[-1].minor.yy40;
  yymsp[-1].minor.yy40 = NULL;
}
#line 1018 "configparser.c"
  yy_destructor(8,&yymsp[-2].minor);
  yy_destructor(9,&yymsp[0].minor);
        break;
      case 20:
#line 289 "./configparser.y"
{
  if (buffer_is_empty(yymsp[0].minor.yy41->key) ||
      NULL == array_get_element(yymsp[-2].minor.yy40, yymsp[0].minor.yy41->key->ptr)) {
    array_insert_unique(yymsp[-2].minor.yy40, yymsp[0].minor.yy41);
    yymsp[0].minor.yy41 = NULL;
  } else {
    fprintf(stderr, "Duplicate array-key: %s\n",
            yymsp[0].minor.yy41->key->ptr);
    ctx->ok = 0;
    yymsp[0].minor.yy41->free(yymsp[0].minor.yy41);
    yymsp[0].minor.yy41 = NULL;
  }

  yygotominor.yy40 = yymsp[-2].minor.yy40;
  yymsp[-2].minor.yy40 = NULL;
}
#line 1040 "configparser.c"
  yy_destructor(10,&yymsp[-1].minor);
        break;
      case 21:
#line 306 "./configparser.y"
{
  yygotominor.yy40 = yymsp[-1].minor.yy40;
  yymsp[-1].minor.yy40 = NULL;
}
#line 1049 "configparser.c"
  yy_destructor(10,&yymsp[0].minor);
        break;
      case 22:
#line 311 "./configparser.y"
{
  yygotominor.yy40 = array_init();
  array_insert_unique(yygotominor.yy40, yymsp[0].minor.yy41);
  yymsp[0].minor.yy41 = NULL;
}
#line 1059 "configparser.c"
        break;
      case 23:
#line 317 "./configparser.y"
{
  yygotominor.yy41 = yymsp[0].minor.yy41;
  yymsp[0].minor.yy41 = NULL;
}
#line 1067 "configparser.c"
        break;
      case 24:
#line 321 "./configparser.y"
{
  buffer_copy_string_buffer(yymsp[0].minor.yy41->key, yymsp[-2].minor.yy43);
  buffer_free(yymsp[-2].minor.yy43);
  yymsp[-2].minor.yy43 = NULL;

  yygotominor.yy41 = yymsp[0].minor.yy41;
  yymsp[0].minor.yy41 = NULL;
}
#line 1079 "configparser.c"
  yy_destructor(11,&yymsp[-1].minor);
        break;
      case 25:
  yy_destructor(1,&yymsp[0].minor);
        break;
      case 26:
        break;
      case 27:
#line 333 "./configparser.y"
{
  data_config *dc;
  dc = (data_config *)array_get_element(ctx->srv->config_context, "global");
  assert(dc);
  configparser_push(ctx, dc, 0);
}
#line 1095 "configparser.c"
  yy_destructor(12,&yymsp[0].minor);
        break;
      case 28:
#line 340 "./configparser.y"
{
  data_config *cur;

  cur = ctx->current;
  configparser_pop(ctx);

  assert(cur && ctx->current);

  yygotominor.yy78 = cur;
}
#line 1110 "configparser.c"
        /* No destructor defined for globalstart */
  yy_destructor(13,&yymsp[-2].minor);
        /* No destructor defined for metalines */
  yy_destructor(14,&yymsp[0].minor);
        break;
      case 29:
#line 351 "./configparser.y"
{
  assert(yymsp[-3].minor.yy78->context_ndx < yymsp[0].minor.yy78->context_ndx);
  yymsp[0].minor.yy78->prev = yymsp[-3].minor.yy78;
  yymsp[-3].minor.yy78->next = yymsp[0].minor.yy78;
  yygotominor.yy78 = yymsp[0].minor.yy78;
  yymsp[-3].minor.yy78 = NULL;
  yymsp[0].minor.yy78 = NULL;
}
#line 1126 "configparser.c"
        /* No destructor defined for eols */
  yy_destructor(15,&yymsp[-1].minor);
        break;
      case 30:
#line 360 "./configparser.y"
{
  yygotominor.yy78 = yymsp[0].minor.yy78;
  yymsp[0].minor.yy78 = NULL;
}
#line 1136 "configparser.c"
        break;
      case 31:
#line 365 "./configparser.y"
{
  data_config *cur;

  cur = ctx->current;
  configparser_pop(ctx);

  assert(cur && ctx->current);

  yygotominor.yy78 = cur;
}
#line 1150 "configparser.c"
        /* No destructor defined for context */
  yy_destructor(13,&yymsp[-2].minor);
        /* No destructor defined for metalines */
  yy_destructor(14,&yymsp[0].minor);
        break;
      case 32:
#line 376 "./configparser.y"
{
  data_config *dc;
  buffer *b, *rvalue, *op;

  if (ctx->ok && yymsp[0].minor.yy41->type != TYPE_STRING) {
    fprintf(stderr, "rvalue must be string");
    ctx->ok = 0;
  }

  switch(yymsp[-1].minor.yy27) {
  case CONFIG_COND_NE:
    op = buffer_init_string("!=");
    break;
  case CONFIG_COND_EQ:
    op = buffer_init_string("==");
    break;
  case CONFIG_COND_NOMATCH:
    op = buffer_init_string("!~");
    break;
  case CONFIG_COND_MATCH:
    op = buffer_init_string("=~");
    break;
  default:
    assert(0);
    return;
  }

  b = buffer_init();
  buffer_copy_string_buffer(b, ctx->current->key);
  buffer_append_string(b, "/");
  buffer_append_string_buffer(b, yymsp[-5].minor.yy0);
  buffer_append_string_buffer(b, yymsp[-3].minor.yy43);
  buffer_append_string_buffer(b, op);
  rvalue = ((data_string*)yymsp[0].minor.yy41)->value;
  buffer_append_string_buffer(b, rvalue);

  if (NULL != (dc = (data_config *)array_get_element(ctx->all_configs, b->ptr))) {
    configparser_push(ctx, dc, 0);
  } else {
    struct {
      comp_key_t comp;
      char *comp_key;
      size_t len;
    } comps[] = {
      { COMP_SERVER_SOCKET,      CONST_STR_LEN("SERVER[\"socket\"]"   ) },
      { COMP_HTTP_URL,           CONST_STR_LEN("HTTP[\"url\"]"        ) },
      { COMP_HTTP_HOST,          CONST_STR_LEN("HTTP[\"host\"]"       ) },
      { COMP_HTTP_REFERER,       CONST_STR_LEN("HTTP[\"referer\"]"    ) },
      { COMP_HTTP_USER_AGENT,    CONST_STR_LEN("HTTP[\"useragent\"]"  ) },
      { COMP_HTTP_USER_AGENT,    CONST_STR_LEN("HTTP[\"user-agent\"]"  ) },
      { COMP_HTTP_COOKIE,        CONST_STR_LEN("HTTP[\"cookie\"]"     ) },
      { COMP_HTTP_REMOTE_IP,     CONST_STR_LEN("HTTP[\"remoteip\"]"   ) },
      { COMP_HTTP_REMOTE_IP,     CONST_STR_LEN("HTTP[\"remote-ip\"]"   ) },
      { COMP_HTTP_QUERY_STRING,  CONST_STR_LEN("HTTP[\"querystring\"]") },
      { COMP_HTTP_QUERY_STRING,  CONST_STR_LEN("HTTP[\"query-string\"]") },
      { COMP_HTTP_REQUEST_METHOD, CONST_STR_LEN("HTTP[\"request-method\"]") },
      { COMP_HTTP_SCHEME,        CONST_STR_LEN("HTTP[\"scheme\"]"     ) },
      { COMP_UNSET, NULL, 0 },
    };
    size_t i;

    dc = data_config_init();

    buffer_copy_string_buffer(dc->key, b);
    buffer_copy_string_buffer(dc->op, op);
    buffer_copy_string_buffer(dc->comp_key, yymsp[-5].minor.yy0);
    buffer_append_string_len(dc->comp_key, CONST_STR_LEN("[\""));
    buffer_append_string_buffer(dc->comp_key, yymsp[-3].minor.yy43);
    buffer_append_string_len(dc->comp_key, CONST_STR_LEN("\"]"));
    dc->cond = yymsp[-1].minor.yy27;

    for (i = 0; comps[i].comp_key; i ++) {
      if (buffer_is_equal_string(
            dc->comp_key, comps[i].comp_key, comps[i].len)) {
        dc->comp = comps[i].comp;
        break;
      }
    }
    if (COMP_UNSET == dc->comp) {
      fprintf(stderr, "error comp_key %s", dc->comp_key->ptr);
      ctx->ok = 0;
    }

    switch(yymsp[-1].minor.yy27) {
    case CONFIG_COND_NE:
    case CONFIG_COND_EQ:
      dc->string = buffer_init_buffer(rvalue);
      break;
    case CONFIG_COND_NOMATCH:
    case CONFIG_COND_MATCH: {
#ifdef HAVE_PCRE_H
      const char *errptr;
      int erroff;

      if (NULL == (dc->regex =
          pcre_compile(rvalue->ptr, 0, &errptr, &erroff, NULL))) {
        dc->string = buffer_init_string(errptr);
        dc->cond = CONFIG_COND_UNSET;

        fprintf(stderr, "parsing regex failed: %s -> %s at offset %d\n",
            rvalue->ptr, errptr, erroff);

        ctx->ok = 0;
      } else if (NULL == (dc->regex_study =
          pcre_study(dc->regex, 0, &errptr)) &&
                 errptr != NULL) {
        fprintf(stderr, "studying regex failed: %s -> %s\n",
            rvalue->ptr, errptr);
        ctx->ok = 0;
      } else {
        dc->string = buffer_init_buffer(rvalue);
      }
#else
      fprintf(stderr, "can't handle '$%s[%s] =~ ...' as you compiled without pcre support. \n"
		      "(perhaps just a missing pcre-devel package ?) \n",
                      yymsp[-5].minor.yy0->ptr, yymsp[-3].minor.yy43->ptr);
      ctx->ok = 0;
#endif
      break;
    }

    default:
      fprintf(stderr, "unknown condition for $%s[%s]\n",
                      yymsp[-5].minor.yy0->ptr, yymsp[-3].minor.yy43->ptr);
      ctx->ok = 0;
      break;
    }

    configparser_push(ctx, dc, 1);
  }

  buffer_free(b);
  buffer_free(op);
  buffer_free(yymsp[-5].minor.yy0);
  yymsp[-5].minor.yy0 = NULL;
  buffer_free(yymsp[-3].minor.yy43);
  yymsp[-3].minor.yy43 = NULL;
  yymsp[0].minor.yy41->free(yymsp[0].minor.yy41);
  yymsp[0].minor.yy41 = NULL;
}
#line 1298 "configparser.c"
  yy_destructor(16,&yymsp[-6].minor);
  yy_destructor(18,&yymsp[-4].minor);
  yy_destructor(19,&yymsp[-2].minor);
        break;
      case 33:
#line 516 "./configparser.y"
{
  yygotominor.yy27 = CONFIG_COND_EQ;
}
#line 1308 "configparser.c"
  yy_destructor(20,&yymsp[0].minor);
        break;
      case 34:
#line 519 "./configparser.y"
{
  yygotominor.yy27 = CONFIG_COND_MATCH;
}
#line 1316 "configparser.c"
  yy_destructor(21,&yymsp[0].minor);
        break;
      case 35:
#line 522 "./configparser.y"
{
  yygotominor.yy27 = CONFIG_COND_NE;
}
#line 1324 "configparser.c"
  yy_destructor(22,&yymsp[0].minor);
        break;
      case 36:
#line 525 "./configparser.y"
{
  yygotominor.yy27 = CONFIG_COND_NOMATCH;
}
#line 1332 "configparser.c"
  yy_destructor(23,&yymsp[0].minor);
        break;
      case 37:
#line 529 "./configparser.y"
{
  yygotominor.yy43 = NULL;
  if (ctx->ok) {
    if (yymsp[0].minor.yy41->type == TYPE_STRING) {
      yygotominor.yy43 = buffer_init_buffer(((data_string*)yymsp[0].minor.yy41)->value);
    } else if (yymsp[0].minor.yy41->type == TYPE_INTEGER) {
      yygotominor.yy43 = buffer_init();
      buffer_copy_long(yygotominor.yy43, ((data_integer *)yymsp[0].minor.yy41)->value);
    } else {
      fprintf(stderr, "operand must be string");
      ctx->ok = 0;
    }
  }
  yymsp[0].minor.yy41->free(yymsp[0].minor.yy41);
  yymsp[0].minor.yy41 = NULL;
}
#line 1353 "configparser.c"
        break;
      case 38:
#line 546 "./configparser.y"
{
  if (ctx->ok) {
    if (0 != config_parse_file(ctx->srv, ctx, yymsp[0].minor.yy43->ptr)) {
      ctx->ok = 0;
    }
    buffer_free(yymsp[0].minor.yy43);
    yymsp[0].minor.yy43 = NULL;
  }
}
#line 1366 "configparser.c"
  yy_destructor(24,&yymsp[-1].minor);
        break;
      case 39:
#line 556 "./configparser.y"
{
  if (ctx->ok) {
    if (0 != config_parse_cmd(ctx->srv, ctx, yymsp[0].minor.yy43->ptr)) {
      ctx->ok = 0;
    }
    buffer_free(yymsp[0].minor.yy43);
    yymsp[0].minor.yy43 = NULL;
  }
}
#line 1380 "configparser.c"
  yy_destructor(25,&yymsp[-1].minor);
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yypParser,yygoto);
  if( yyact < YYNSTATE ){
    yy_shift(yypParser,yyact,yygoto,&yygotominor);
  }else if( yyact == YYNSTATE + YYNRULE + 1 ){
    yy_accept(yypParser);
  }
}
Esempio n. 19
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  int yyruleno                 /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  YYMINORTYPE yygotominor;        /* The LHS of the rule reduced */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  yogoc_ParseARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && yyruleno>=0 
        && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
    fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt,
      yyRuleName[yyruleno]);
  }
#endif /* NDEBUG */

  /* Silence complaints from purify about yygotominor being uninitialized
  ** in some cases when it is copied into the stack after the following
  ** switch.  yygotominor is uninitialized when a rule reduces that does
  ** not set the value of its left-hand side nonterminal.  Leaving the
  ** value of the nonterminal uninitialized is utterly harmless as long
  ** as the value is never used.  So really the only thing this code
  ** accomplishes is to quieten purify.  
  **
  ** 2007-01-16:  The wireshark project (www.wireshark.org) reports that
  ** without this code, their parser segfaults.  I'm not sure what there
  ** parser is doing to make this happen.  This is the second bug report
  ** from wireshark this week.  Clearly they are stressing Lemon in ways
  ** that it has not been previously stressed...  (SQLite ticket #2172)
  */
  /*memset(&yygotominor, 0, sizeof(yygotominor));*/
  yygotominor = yyzerominor;


  switch( yyruleno ){
  /* Beginning here are the reduction cases.  A typical example
  ** follows:
  **   case 0:
  **  #line <lineno> <grammarfile>
  **     { ... }           // User supplied code
  **  #line <lineno> <thisfile>
  **     break;
  */
      case 8: /* package ::= PACKAGE PKGNAME SEMI */
      case 9: /* package ::= PACKAGE IDENTIFIER SEMI */ yytestcase(yyruleno==9);
#line 37 "lib/grammar.y"
{ yogoc_set_package(emit, yymsp[-1].minor.yy0->value); }
#line 714 "lib/grammar.c"
        break;
      case 10: /* named_sub ::= SUB IDENTIFIER block */
#line 41 "lib/grammar.y"
{ yogoc_set_sub(emit, yymsp[-1].minor.yy0->value); }
#line 719 "lib/grammar.c"
        break;
      case 11: /* anon_sub ::= SUB block */
#line 42 "lib/grammar.y"
{ yogoc_set_sub(emit, NULL); }
#line 724 "lib/grammar.c"
        break;
      case 12: /* block ::= OPEN_CURLY stmtlist CLOSE_CURLY */
#line 44 "lib/grammar.y"
{ fprintf(stderr, "Found block\n"); }
#line 729 "lib/grammar.c"
        break;
      case 13: /* do ::= DO block */
#line 47 "lib/grammar.y"
{ fprintf(stderr, "Found do\n"); }
#line 734 "lib/grammar.c"
        break;
      case 14: /* var_decl ::= MY type var SEMI */
#line 50 "lib/grammar.y"
{ fprintf(stderr, "Found my decl\n"); }
#line 739 "lib/grammar.c"
        break;
      default:
      /* (0) input ::= stmtlist */ yytestcase(yyruleno==0);
      /* (1) stmtlist ::= stmtlist stmt */ yytestcase(yyruleno==1);
      /* (2) stmtlist ::= */ yytestcase(yyruleno==2);
      /* (3) stmt ::= package */ yytestcase(yyruleno==3);
      /* (4) stmt ::= named_sub */ yytestcase(yyruleno==4);
      /* (5) stmt ::= anon_sub */ yytestcase(yyruleno==5);
      /* (6) stmt ::= var_decl */ yytestcase(yyruleno==6);
      /* (7) stmt ::= do */ yytestcase(yyruleno==7);
      /* (15) var ::= SCALAR_VAR */ yytestcase(yyruleno==15);
      /* (16) var ::= HASH_VAR */ yytestcase(yyruleno==16);
      /* (17) var ::= ARRAY_VAR */ yytestcase(yyruleno==17);
      /* (18) type ::= INTEGER */ yytestcase(yyruleno==18);
      /* (19) type ::= DOUBLE */ yytestcase(yyruleno==19);
      /* (20) type ::= STRING */ yytestcase(yyruleno==20);
      /* (21) type ::= HASH */ yytestcase(yyruleno==21);
      /* (22) type ::= ARRAY */ yytestcase(yyruleno==22);
      /* (23) type ::= ANY */ yytestcase(yyruleno==23);
      /* (24) type ::= OBJECT */ yytestcase(yyruleno==24);
      /* (25) type ::= */ yytestcase(yyruleno==25);
        break;
  };
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  yypParser->yyidx -= yysize;
  yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
  if( yyact < YYNSTATE ){
#ifdef NDEBUG
    /* If we are not debugging and the reduce action popped at least
    ** one element off the stack, then we can push the new element back
    ** onto the stack here, and skip the stack overflow test in yy_shift().
    ** That gives a significant speed improvement. */
    if( yysize ){
      yypParser->yyidx++;
      yymsp -= yysize-1;
      yymsp->stateno = (YYACTIONTYPE)yyact;
      yymsp->major = (YYCODETYPE)yygoto;
      yymsp->minor = yygotominor;
    }else
#endif
    {
      yy_shift(yypParser,yyact,yygoto,&yygotominor);
    }
  }else{
    assert( yyact == YYNSTATE + YYNRULE + 1 );
    yy_accept(yypParser);
  }
}