/*
** 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. 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: /* 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);
  }
}
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 5:			/* kml_tree ::= node */
      case 6:			/* kml_tree ::= node_chain */
	  yytestcase (yyruleno == 6);
	  {
	      p_data->result = yymsp[0].minor.yy0;
	  }
	  break;
      case 7:			/* node ::= open_tag KML_END KML_CLOSE */
	  {
	      yygotominor.yy0 =
		  kml_createSelfClosedNode (p_data,
					    (void *) yymsp[-2].minor.yy0, NULL);
	  }
	  break;
      case 8:			/* node ::= open_tag attr KML_END KML_CLOSE */
      case 9:			/* node ::= open_tag attributes KML_END KML_CLOSE */
	  yytestcase (yyruleno == 9);
	  {
	      yygotominor.yy0 =
		  kml_createSelfClosedNode (p_data,
					    (void *) yymsp[-3].minor.yy0,
					    (void *) yymsp[-2].minor.yy0);
	  }
	  break;
      case 10:			/* node ::= open_tag KML_CLOSE */
	  {
	      yygotominor.yy0 =
		  kml_createNode (p_data, (void *) yymsp[-1].minor.yy0, NULL,
				  NULL);
	  }
	  break;
      case 11:			/* node ::= open_tag attr KML_CLOSE */
      case 12:			/* node ::= open_tag attributes KML_CLOSE */
	  yytestcase (yyruleno == 12);
	  {
	      yygotominor.yy0 =
		  kml_createNode (p_data, (void *) yymsp[-2].minor.yy0,
				  (void *) yymsp[-1].minor.yy0, NULL);
	  }
	  break;
      case 13:			/* node ::= open_tag KML_CLOSE coord */
      case 14:			/* node ::= open_tag KML_CLOSE coord_chain */
	  yytestcase (yyruleno == 14);
	  {
	      yygotominor.yy0 =
		  kml_createNode (p_data, (void *) yymsp[-2].minor.yy0, NULL,
				  (void *) yymsp[0].minor.yy0);
	  }
	  break;
      case 15:			/* node ::= open_tag attr KML_CLOSE coord */
      case 16:			/* node ::= open_tag attr KML_CLOSE coord_chain */
	  yytestcase (yyruleno == 16);
      case 17:			/* node ::= open_tag attributes KML_CLOSE coord */
	  yytestcase (yyruleno == 17);
      case 18:			/* node ::= open_tag attributes KML_CLOSE coord_chain */
	  yytestcase (yyruleno == 18);
	  {
	      yygotominor.yy0 =
		  kml_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 =
		  kml_closingNode (p_data, (void *) yymsp[0].minor.yy0);
	  }
	  break;
      case 20:			/* open_tag ::= KML_OPEN keyword */
      case 22:			/* keyword ::= KML_KEYWORD */
	  yytestcase (yyruleno == 22);
	  {
	      yygotominor.yy0 = yymsp[0].minor.yy0;
	  }
	  break;
      case 21:			/* close_tag ::= KML_OPEN KML_END keyword KML_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 */
	  {
	      ((kmlNodePtr) yymsp[-1].minor.yy0)->Next =
		  (kmlNodePtr) yymsp[0].minor.yy0;
	      yygotominor.yy0 = yymsp[-1].minor.yy0;
	  }
	  break;
      case 25:			/* node_chain ::= node node extra_nodes */
	  {
	      ((kmlNodePtr) yymsp[-1].minor.yy0)->Next =
		  (kmlNodePtr) yymsp[0].minor.yy0;
	      ((kmlNodePtr) yymsp[-2].minor.yy0)->Next =
		  (kmlNodePtr) yymsp[-1].minor.yy0;
	      yygotominor.yy0 = yymsp[-2].minor.yy0;
	  }
	  break;
      case 26:			/* attr ::= KML_KEYWORD KML_EQ KML_VALUE */
	  {
	      yygotominor.yy0 =
		  kml_attribute (p_data, (void *) yymsp[-2].minor.yy0,
				 (void *) yymsp[0].minor.yy0);
	  }
	  break;
      case 28:			/* extra_attr ::= attr extra_attr */
	  {
	      ((kmlAttrPtr) yymsp[-1].minor.yy0)->Next =
		  (kmlAttrPtr) yymsp[0].minor.yy0;
	      yygotominor.yy0 = yymsp[-1].minor.yy0;
	  }
	  break;
      case 29:			/* attributes ::= attr attr extra_attr */
	  {
	      ((kmlAttrPtr) yymsp[-1].minor.yy0)->Next =
		  (kmlAttrPtr) yymsp[0].minor.yy0;
	      ((kmlAttrPtr) yymsp[-2].minor.yy0)->Next =
		  (kmlAttrPtr) yymsp[-1].minor.yy0;
	      yygotominor.yy0 = yymsp[-2].minor.yy0;
	  }
	  break;
      case 30:			/* coord ::= KML_COORD */
	  {
	      yygotominor.yy0 = kml_coord (p_data, (void *) yymsp[0].minor.yy0);
	  }
	  break;
      case 32:			/* extra_coord ::= coord extra_coord */
	  {
	      ((kmlCoordPtr) yymsp[-1].minor.yy0)->Next =
		  (kmlCoordPtr) yymsp[0].minor.yy0;
	      yygotominor.yy0 = yymsp[-1].minor.yy0;
	  }
	  break;
      case 33:			/* coord_chain ::= coord coord extra_coord */
	  {
	      ((kmlCoordPtr) yymsp[-1].minor.yy0)->Next =
		  (kmlCoordPtr) yymsp[0].minor.yy0;
	      ((kmlCoordPtr) yymsp[-2].minor.yy0)->Next =
		  (kmlCoordPtr) 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 KML_NEWLINE */ yytestcase (yyruleno == 2);
	  /* (3) state ::= program */ yytestcase (yyruleno == 3);
	  /* (4) program ::= kml_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. 4
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);
  }
}
Esempio n. 5
0
/* The main parser program.
** The first argument is a pointer to a structure obtained from
** "lcn_query_parser_Alloc" 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 lcn_query_parser_(
  void *yyp,                   /* The parser */
  int yymajor,                 /* The major token code number */
  lcn_query_parser_TOKENTYPE yyminor       /* The value for the token */
  lcn_query_parser_ARG_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);
  lcn_query_parser_ARG_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. 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 */
    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. 7
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);
  }
}
/*
** 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. 9
0
/*
** Perform a reduce action and the shift that must immediately
** follow the reduce.
*/
static void yy_reduce(
  yyParser *yypParser,         /* The parser */
  unsigned int yyruleno        /* Number of the rule by which to reduce */
){
  int yygoto;                     /* The next state */
  int yyact;                      /* The next action */
  yyStackEntry *yymsp;            /* The top of the parser's stack */
  int yysize;                     /* Amount to pop the stack */
  Parser_v0_1_ARG_FETCH;
  yymsp = &yypParser->yystack[yypParser->yyidx];
#ifndef NDEBUG
  if( yyTraceFILE && 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 */

  /* Check that the stack is large enough to grow by a single entry
  ** if the RHS of the rule is empty.  This ensures that there is room
  ** enough on the stack to push the LHS value */
  if( yyRuleInfo[yyruleno].nrhs==0 ){
#ifdef YYTRACKMAXSTACKDEPTH
    if( yypParser->yyidx>yypParser->yyidxMax ){
      yypParser->yyidxMax = yypParser->yyidx;
    }
#endif
#if YYSTACKDEPTH>0 
    if( yypParser->yyidx>=YYSTACKDEPTH-1 ){
      yyStackOverflow(yypParser);
      return;
    }
#else
    if( yypParser->yyidx>=yypParser->yystksz-1 ){
      yyGrowStack(yypParser);
      if( yypParser->yyidx>=yypParser->yystksz-1 ){
        yyStackOverflow(yypParser);
        return;
      }
    }
#endif
  }

  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 **********************************************/
        YYMINORTYPE yylhsminor;
      case 0: /* program ::= IDENTIFIER NUMBER types */
{ *arg = yymsp[0].minor.yy11; }
        break;
      case 1: /* types ::= types type */
{ yylhsminor.yy11 = yymsp[-1].minor.yy11; Add(yylhsminor.yy11, yymsp[0].minor.yy33); }
  yymsp[-1].minor.yy11 = yylhsminor.yy11;
        break;
      case 2: /* types ::= type */
{ yylhsminor.yy11 = CreateProgramNode(); Add(yylhsminor.yy11, yymsp[0].minor.yy33); }
  yymsp[0].minor.yy11 = yylhsminor.yy11;
        break;
      case 3: /* type ::= IDENTIFIER LBRACE values RBRACE SEMICOLON */
{ yylhsminor.yy33 = yymsp[-2].minor.yy33; SetIden(yylhsminor.yy33, yymsp[-4].minor.yy0); }
  yymsp[-4].minor.yy33 = yylhsminor.yy33;
        break;
      case 4: /* values ::= values value */
{ yylhsminor.yy33 = yymsp[-1].minor.yy33; Add(yylhsminor.yy33, yymsp[0].minor.yy30); }
  yymsp[-1].minor.yy33 = yylhsminor.yy33;
        break;
      case 5: /* values ::= value */
{ yylhsminor.yy33 = CreateTypeNode(); Add(yylhsminor.yy33, yymsp[0].minor.yy30); }
  yymsp[0].minor.yy33 = yylhsminor.yy33;
        break;
      case 6: /* value ::= IDENTIFIER COLON expression SEMICOLON */
{ yylhsminor.yy30 = CreateAssignNode(yymsp[-3].minor.yy0, yymsp[-1].minor.yy37); }
  yymsp[-3].minor.yy30 = yylhsminor.yy30;
        break;
      case 7: /* expression ::= number */
{ yylhsminor.yy37 = CreateExpressionNode(yymsp[0].minor.yy10); }
  yymsp[0].minor.yy37 = yylhsminor.yy37;
        break;
      case 8: /* expression ::= IDENTIFIER */
{ yylhsminor.yy37 = CreateExpressionNode(yymsp[0].minor.yy0); }
  yymsp[0].minor.yy37 = yylhsminor.yy37;
        break;
      case 9: /* expression ::= IDENTIFIER vector */
{ yylhsminor.yy37 = CreateColourNode(yymsp[-1].minor.yy0, yymsp[0].minor.yy6); }
  yymsp[-1].minor.yy37 = yylhsminor.yy37;
        break;
      case 10: /* expression ::= number IDENTIFIER */
{ yylhsminor.yy37 = CreateUnitValueNode(yymsp[-1].minor.yy10, yymsp[0].minor.yy0); }
  yymsp[-1].minor.yy37 = yylhsminor.yy37;
        break;
      case 11: /* expression ::= vector */
{ yylhsminor.yy37 = CreateVecExprNode(yymsp[0].minor.yy6); }
  yymsp[0].minor.yy37 = yylhsminor.yy37;
        break;
      case 12: /* vector ::= LESSER vector_vals GREATER */
{ yymsp[-2].minor.yy6 = yymsp[-1].minor.yy6; }
        break;
      case 13: /* vector_vals ::= vector_vals COMMA number */
{ yylhsminor.yy6 = yymsp[-2].minor.yy6; Add(yylhsminor.yy6, CreateExpressionNode(yymsp[0].minor.yy10)); }
  yymsp[-2].minor.yy6 = yylhsminor.yy6;
        break;
      case 14: /* vector_vals ::= number */
{ yylhsminor.yy6 = CreateVectorNode(); Add(yylhsminor.yy6, CreateExpressionNode(yymsp[0].minor.yy10)); }
  yymsp[0].minor.yy6 = yylhsminor.yy6;
        break;
      case 15: /* number ::= HEXVAL */
      case 16: /* number ::= NUMBER */ yytestcase(yyruleno==16);
{ yylhsminor.yy10 = yymsp[0].minor.yy0; }
  yymsp[0].minor.yy10 = yylhsminor.yy10;
        break;
      default:
        break;
/********** End reduce actions ************************************************/
  };
  assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
  yygoto = yyRuleInfo[yyruleno].lhs;
  yysize = yyRuleInfo[yyruleno].nrhs;
  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;
    yypParser->yyidx -= yysize - 1;
    yymsp -= yysize-1;
    yymsp->stateno = (YYACTIONTYPE)yyact;
    yymsp->major = (YYCODETYPE)yygoto;
    yyTraceShift(yypParser, yyact);
  }else{
    assert( yyact == YY_ACCEPT_ACTION );
    yypParser->yyidx -= yysize;
    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 */
  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. 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 */
  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. 12
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. 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 */
  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. 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 */
  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);
  }
}