Ignore:
Timestamp:
Jun 18, 2012, 2:31:26 PM (7 years ago)
Author:
sam
Message:

orbital: allow 6- and 8-component hex colour values.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/orbital/generated/mesh-parser.cpp

    r1442 r1495  
    1 /* A Bison parser, made by GNU Bison 2.4.2.  */
     1/* A Bison parser, made by GNU Bison 2.5.  */
    22
    33/* Skeleton implementation for Bison LALR(1) parsers in C++
    44   
    5       Copyright (C) 2002-2010 Free Software Foundation, Inc.
     5      Copyright (C) 2002-2011 Free Software Foundation, Inc.
    66   
    77   This program is free software: you can redistribute it and/or modify
     
    3636/* First part of user declarations.  */
    3737
    38 /* Line 310 of lalr1.cc  */
     38/* Line 293 of lalr1.cc  */
    3939#line 1 "mesh-parser.y"
    4040
     
    6161
    6262
    63 /* Line 310 of lalr1.cc  */
     63/* Line 293 of lalr1.cc  */
    6464#line 65 "generated/mesh-parser.cpp"
    6565
     
    6969/* User implementation prologue.  */
    7070
    71 /* Line 316 of lalr1.cc  */
     71/* Line 299 of lalr1.cc  */
    7272#line 63 "mesh-parser.y"
    7373
     
    7878
    7979
    80 /* Line 316 of lalr1.cc  */
     80/* Line 299 of lalr1.cc  */
    8181#line 82 "generated/mesh-parser.cpp"
    8282
     
    9393#endif
    9494
     95/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
     96   If N is 0, then set CURRENT to the empty location which ends
     97   the previous symbol: RHS[0] (always defined).  */
     98
     99#define YYRHSLOC(Rhs, K) ((Rhs)[K])
     100#ifndef YYLLOC_DEFAULT
     101# define YYLLOC_DEFAULT(Current, Rhs, N)                               \
     102 do                                                                    \
     103   if (N)                                                              \
     104     {                                                                 \
     105       (Current).begin = YYRHSLOC (Rhs, 1).begin;                      \
     106       (Current).end   = YYRHSLOC (Rhs, N).end;                        \
     107     }                                                                 \
     108   else                                                                \
     109     {                                                                 \
     110       (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end;        \
     111     }                                                                 \
     112 while (false)
     113#endif
     114
    95115/* Suppress unused-variable warnings by "using" E.  */
    96116#define YYUSE(e) ((void) (e))
     
    144164namespace orbital {
    145165
    146 /* Line 379 of lalr1.cc  */
    147 #line 148 "generated/mesh-parser.cpp"
    148 #if YYERROR_VERBOSE
     166/* Line 382 of lalr1.cc  */
     167#line 168 "generated/mesh-parser.cpp"
    149168
    150169  /* Return YYSTR after stripping away unnecessary quotes and
     
    185204  }
    186205
    187 #endif
    188206
    189207  /// Build a parser object.
     
    286304#endif
    287305
     306  inline bool
     307  MeshParser::yy_pact_value_is_default_ (int yyvalue)
     308  {
     309    return yyvalue == yypact_ninf_;
     310  }
     311
     312  inline bool
     313  MeshParser::yy_table_value_is_error_ (int yyvalue)
     314  {
     315    return yyvalue == yytable_ninf_;
     316  }
     317
    288318  int
    289319  MeshParser::parse ()
     
    307337    location_type yylloc;
    308338    /// The locations where the error started and ended.
    309     location_type yyerror_range[2];
     339    location_type yyerror_range[3];
    310340
    311341    /// $$.
     
    345375    /* Try to take a decision without lookahead.  */
    346376    yyn = yypact_[yystate];
    347     if (yyn == yypact_ninf_)
     377    if (yy_pact_value_is_default_ (yyn))
    348378      goto yydefault;
    349379
     
    378408    if (yyn <= 0)
    379409      {
    380         if (yyn == 0 || yyn == yytable_ninf_)
    381         goto yyerrlab;
     410        if (yy_table_value_is_error_ (yyn))
     411          goto yyerrlab;
    382412        yyn = -yyn;
    383413        goto yyreduce;
     
    435465          case 7:
    436466
    437 /* Line 677 of lalr1.cc  */
     467/* Line 690 of lalr1.cc  */
    438468#line 87 "mesh-parser.y"
    439469    { mc.m_mesh.OpenBrace(); }
     
    442472  case 8:
    443473
    444 /* Line 677 of lalr1.cc  */
     474/* Line 690 of lalr1.cc  */
    445475#line 91 "mesh-parser.y"
    446476    { mc.m_mesh.CloseBrace(); }
     
    449479  case 14:
    450480
    451 /* Line 677 of lalr1.cc  */
     481/* Line 690 of lalr1.cc  */
    452482#line 106 "mesh-parser.y"
    453483    { mc.m_mesh.SetCurColor(vec4((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); }
     
    456486  case 15:
    457487
    458 /* Line 677 of lalr1.cc  */
     488/* Line 690 of lalr1.cc  */
    459489#line 107 "mesh-parser.y"
    460     { uint16_t x = (uint16_t)(yysemantic_stack_[(2) - (2)].u32val);
    461                       vec4 v(x >> 12, (x >> 8) & 0xf, (x >> 4) & 0xf, x & 0xf);
    462                       mc.m_mesh.SetCurColor(vec4(v) * (1. / 15)); }
     490    { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val);
     491                      vec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
     492                      mc.m_mesh.SetCurColor(vec4(v) * (1. / 255)); }
    463493    break;
    464494
    465495  case 16:
    466496
    467 /* Line 677 of lalr1.cc  */
     497/* Line 690 of lalr1.cc  */
    468498#line 110 "mesh-parser.y"
    469499    { mc.m_mesh.SetCurColor2(vec4((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3)); }
     
    472502  case 17:
    473503
    474 /* Line 677 of lalr1.cc  */
     504/* Line 690 of lalr1.cc  */
    475505#line 111 "mesh-parser.y"
    476     { uint16_t x = (uint16_t)(yysemantic_stack_[(2) - (2)].u32val);
    477                       vec4 v(x >> 12, (x >> 8) & 0xf, (x >> 4) & 0xf, x & 0xf);
    478                       mc.m_mesh.SetCurColor2(vec4(v) * (1. / 15)); }
     506    { uint32_t x = (yysemantic_stack_[(2) - (2)].u32val);
     507                      vec4 v(x >> 24, (x >> 16) & 0xff, (x >> 8) & 0xff, x & 0xff);
     508                      mc.m_mesh.SetCurColor2(vec4(v) * (1. / 255)); }
    479509    break;
    480510
    481511  case 18:
    482512
    483 /* Line 677 of lalr1.cc  */
     513/* Line 690 of lalr1.cc  */
    484514#line 117 "mesh-parser.y"
    485515    { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, 0, 0)); }
     
    488518  case 19:
    489519
    490 /* Line 677 of lalr1.cc  */
     520/* Line 690 of lalr1.cc  */
    491521#line 118 "mesh-parser.y"
    492522    { mc.m_mesh.Translate(vec3(0, (yysemantic_stack_[(2) - (2)].args).f0, 0)); }
     
    495525  case 20:
    496526
    497 /* Line 677 of lalr1.cc  */
     527/* Line 690 of lalr1.cc  */
    498528#line 119 "mesh-parser.y"
    499529    { mc.m_mesh.Translate(vec3(0, 0, (yysemantic_stack_[(2) - (2)].args).f0)); }
     
    502532  case 21:
    503533
    504 /* Line 677 of lalr1.cc  */
     534/* Line 690 of lalr1.cc  */
    505535#line 120 "mesh-parser.y"
    506536    { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
     
    509539  case 22:
    510540
    511 /* Line 677 of lalr1.cc  */
     541/* Line 690 of lalr1.cc  */
    512542#line 121 "mesh-parser.y"
    513543    { mc.m_mesh.RotateX((yysemantic_stack_[(2) - (2)].args).f0); }
     
    516546  case 23:
    517547
    518 /* Line 677 of lalr1.cc  */
     548/* Line 690 of lalr1.cc  */
    519549#line 122 "mesh-parser.y"
    520550    { mc.m_mesh.RotateY((yysemantic_stack_[(2) - (2)].args).f0); }
     
    523553  case 24:
    524554
    525 /* Line 677 of lalr1.cc  */
     555/* Line 690 of lalr1.cc  */
    526556#line 123 "mesh-parser.y"
    527557    { mc.m_mesh.RotateZ((yysemantic_stack_[(2) - (2)].args).f0); }
     
    530560  case 25:
    531561
    532 /* Line 677 of lalr1.cc  */
     562/* Line 690 of lalr1.cc  */
    533563#line 124 "mesh-parser.y"
    534564    { mc.m_mesh.TaperX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
     
    537567  case 26:
    538568
    539 /* Line 677 of lalr1.cc  */
     569/* Line 690 of lalr1.cc  */
    540570#line 125 "mesh-parser.y"
    541571    { mc.m_mesh.TaperY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
     
    544574  case 27:
    545575
    546 /* Line 677 of lalr1.cc  */
     576/* Line 690 of lalr1.cc  */
    547577#line 126 "mesh-parser.y"
    548578    { mc.m_mesh.TaperZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
     
    551581  case 28:
    552582
    553 /* Line 677 of lalr1.cc  */
     583/* Line 690 of lalr1.cc  */
    554584#line 127 "mesh-parser.y"
    555585    { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, 0, 0)); }
     
    558588  case 29:
    559589
    560 /* Line 677 of lalr1.cc  */
     590/* Line 690 of lalr1.cc  */
    561591#line 128 "mesh-parser.y"
    562592    { mc.m_mesh.Scale(vec3(0, (yysemantic_stack_[(2) - (2)].args).f0, 0)); }
     
    565595  case 30:
    566596
    567 /* Line 677 of lalr1.cc  */
     597/* Line 690 of lalr1.cc  */
    568598#line 129 "mesh-parser.y"
    569599    { mc.m_mesh.Scale(vec3(0, 0, (yysemantic_stack_[(2) - (2)].args).f0)); }
     
    572602  case 31:
    573603
    574 /* Line 677 of lalr1.cc  */
     604/* Line 690 of lalr1.cc  */
    575605#line 130 "mesh-parser.y"
    576606    { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
     
    579609  case 32:
    580610
    581 /* Line 677 of lalr1.cc  */
     611/* Line 690 of lalr1.cc  */
    582612#line 131 "mesh-parser.y"
    583613    { mc.m_mesh.MirrorX(); }
     
    586616  case 33:
    587617
    588 /* Line 677 of lalr1.cc  */
     618/* Line 690 of lalr1.cc  */
    589619#line 132 "mesh-parser.y"
    590620    { mc.m_mesh.MirrorY(); }
     
    593623  case 34:
    594624
    595 /* Line 677 of lalr1.cc  */
     625/* Line 690 of lalr1.cc  */
    596626#line 133 "mesh-parser.y"
    597627    { mc.m_mesh.MirrorZ(); }
     
    600630  case 35:
    601631
    602 /* Line 677 of lalr1.cc  */
     632/* Line 690 of lalr1.cc  */
    603633#line 137 "mesh-parser.y"
    604634    { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
     
    609639  case 36:
    610640
    611 /* Line 677 of lalr1.cc  */
     641/* Line 690 of lalr1.cc  */
    612642#line 140 "mesh-parser.y"
    613643    { mc.m_mesh.AppendBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
     
    616646  case 37:
    617647
    618 /* Line 677 of lalr1.cc  */
     648/* Line 690 of lalr1.cc  */
    619649#line 141 "mesh-parser.y"
    620650    { mc.m_mesh.AppendSmoothChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
     
    624654  case 38:
    625655
    626 /* Line 677 of lalr1.cc  */
     656/* Line 690 of lalr1.cc  */
    627657#line 143 "mesh-parser.y"
    628658    { mc.m_mesh.AppendFlatChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
     
    632662  case 39:
    633663
    634 /* Line 677 of lalr1.cc  */
     664/* Line 690 of lalr1.cc  */
    635665#line 145 "mesh-parser.y"
    636666    { mc.m_mesh.AppendSphere((yysemantic_stack_[(2) - (2)].args).f0,
     
    640670  case 40:
    641671
    642 /* Line 677 of lalr1.cc  */
     672/* Line 690 of lalr1.cc  */
    643673#line 147 "mesh-parser.y"
    644674    { mc.m_mesh.AppendStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2,
     
    648678  case 41:
    649679
    650 /* Line 677 of lalr1.cc  */
     680/* Line 690 of lalr1.cc  */
    651681#line 149 "mesh-parser.y"
    652682    { mc.m_mesh.AppendExpandedStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
     
    656686  case 42:
    657687
    658 /* Line 677 of lalr1.cc  */
     688/* Line 690 of lalr1.cc  */
    659689#line 151 "mesh-parser.y"
    660690    { mc.m_mesh.AppendDisc((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (int)(yysemantic_stack_[(2) - (2)].args).f2); }
     
    663693  case 43:
    664694
    665 /* Line 677 of lalr1.cc  */
     695/* Line 690 of lalr1.cc  */
    666696#line 152 "mesh-parser.y"
    667697    { mc.m_mesh.AppendSimpleTriangle((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); }
     
    670700  case 44:
    671701
    672 /* Line 677 of lalr1.cc  */
     702/* Line 690 of lalr1.cc  */
    673703#line 153 "mesh-parser.y"
    674704    { mc.m_mesh.AppendSimpleQuad((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); }
     
    677707  case 45:
    678708
    679 /* Line 677 of lalr1.cc  */
     709/* Line 690 of lalr1.cc  */
    680710#line 154 "mesh-parser.y"
    681711    { mc.m_mesh.AppendCog((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2, (yysemantic_stack_[(2) - (2)].args).f3,
     
    685715  case 46:
    686716
    687 /* Line 677 of lalr1.cc  */
     717/* Line 690 of lalr1.cc  */
    688718#line 158 "mesh-parser.y"
    689719    { (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); }
     
    692722  case 47:
    693723
    694 /* Line 677 of lalr1.cc  */
     724/* Line 690 of lalr1.cc  */
    695725#line 159 "mesh-parser.y"
    696726    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f1 = (yysemantic_stack_[(2) - (2)].fval); }
     
    699729  case 48:
    700730
    701 /* Line 677 of lalr1.cc  */
     731/* Line 690 of lalr1.cc  */
    702732#line 160 "mesh-parser.y"
    703733    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f2 = (yysemantic_stack_[(2) - (2)].fval); }
     
    706736  case 49:
    707737
    708 /* Line 677 of lalr1.cc  */
     738/* Line 690 of lalr1.cc  */
    709739#line 161 "mesh-parser.y"
    710740    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f3 = (yysemantic_stack_[(2) - (2)].fval); }
     
    713743  case 50:
    714744
    715 /* Line 677 of lalr1.cc  */
     745/* Line 690 of lalr1.cc  */
    716746#line 162 "mesh-parser.y"
    717747    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f4 = (yysemantic_stack_[(2) - (2)].fval); }
     
    720750  case 51:
    721751
    722 /* Line 677 of lalr1.cc  */
     752/* Line 690 of lalr1.cc  */
    723753#line 163 "mesh-parser.y"
    724754    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f5 = (yysemantic_stack_[(2) - (2)].fval); }
     
    727757  case 52:
    728758
    729 /* Line 677 of lalr1.cc  */
     759/* Line 690 of lalr1.cc  */
    730760#line 164 "mesh-parser.y"
    731761    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f6 = (yysemantic_stack_[(2) - (2)].fval); }
     
    734764  case 53:
    735765
    736 /* Line 677 of lalr1.cc  */
     766/* Line 690 of lalr1.cc  */
    737767#line 165 "mesh-parser.y"
    738768    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f7 = (yysemantic_stack_[(2) - (2)].fval); }
     
    741771  case 54:
    742772
    743 /* Line 677 of lalr1.cc  */
     773/* Line 690 of lalr1.cc  */
    744774#line 168 "mesh-parser.y"
    745775    { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); }
     
    748778  case 55:
    749779
    750 /* Line 677 of lalr1.cc  */
     780/* Line 690 of lalr1.cc  */
    751781#line 169 "mesh-parser.y"
    752782    { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); }
     
    755785
    756786
    757 /* Line 677 of lalr1.cc  */
    758 #line 759 "generated/mesh-parser.cpp"
     787/* Line 690 of lalr1.cc  */
     788#line 789 "generated/mesh-parser.cpp"
    759789        default:
    760790          break;
    761791      }
     792    /* User semantic actions sometimes alter yychar, and that requires
     793       that yytoken be updated with the new translation.  We take the
     794       approach of translating immediately before every use of yytoken.
     795       One alternative is translating here after every semantic action,
     796       but that translation would be missed if the semantic action
     797       invokes YYABORT, YYACCEPT, or YYERROR immediately after altering
     798       yychar.  In the case of YYABORT or YYACCEPT, an incorrect
     799       destructor might then be invoked immediately.  In the case of
     800       YYERROR, subsequent parser actions might lead to an incorrect
     801       destructor call or verbose syntax error message before the
     802       lookahead is translated.  */
    762803    YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
    763804
     
    783824  `------------------------------------*/
    784825  yyerrlab:
     826    /* Make sure we have latest lookahead translation.  See comments at
     827       user semantic actions for why this is necessary.  */
     828    yytoken = yytranslate_ (yychar);
     829
    785830    /* If not already recovering from an error, report this error.  */
    786831    if (!yyerrstatus_)
    787832      {
    788833        ++yynerrs_;
     834        if (yychar == yyempty_)
     835          yytoken = yyempty_;
    789836        error (yylloc, yysyntax_error_ (yystate, yytoken));
    790837      }
    791838
    792     yyerror_range[0] = yylloc;
     839    yyerror_range[1] = yylloc;
    793840    if (yyerrstatus_ == 3)
    794841      {
     
    825872      goto yyerrorlab;
    826873
    827     yyerror_range[0] = yylocation_stack_[yylen - 1];
     874    yyerror_range[1] = yylocation_stack_[yylen - 1];
    828875    /* Do not reclaim the symbols of the rule which action triggered
    829876       this YYERROR.  */
     
    842889      {
    843890        yyn = yypact_[yystate];
    844         if (yyn != yypact_ninf_)
     891        if (!yy_pact_value_is_default_ (yyn))
    845892        {
    846893          yyn += yyterror_;
     
    857904        YYABORT;
    858905
    859         yyerror_range[0] = yylocation_stack_[0];
     906        yyerror_range[1] = yylocation_stack_[0];
    860907        yydestruct_ ("Error: popping",
    861908                     yystos_[yystate],
     
    866913      }
    867914
    868     yyerror_range[1] = yylloc;
     915    yyerror_range[2] = yylloc;
    869916    // Using YYLLOC is tempting, but would change the location of
    870917    // the lookahead.  YYLOC is available though.
    871     YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
     918    YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
    872919    yysemantic_stack_.push (yylval);
    873920    yylocation_stack_.push (yyloc);
     
    892939  yyreturn:
    893940    if (yychar != yyempty_)
    894       yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
     941      {
     942        /* Make sure we have latest lookahead translation.  See comments
     943           at user semantic actions for why this is necessary.  */
     944        yytoken = yytranslate_ (yychar);
     945        yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval,
     946                     &yylloc);
     947      }
    895948
    896949    /* Do not reclaim the symbols of the rule which action triggered
     
    911964  // Generate an error message.
    912965  std::string
    913   MeshParser::yysyntax_error_ (int yystate, int tok)
    914   {
    915     std::string res;
    916     YYUSE (yystate);
    917 #if YYERROR_VERBOSE
    918     int yyn = yypact_[yystate];
    919     if (yypact_ninf_ < yyn && yyn <= yylast_)
    920       {
    921         /* Start YYX at -YYN if negative to avoid negative indexes in
    922            YYCHECK.  */
    923         int yyxbegin = yyn < 0 ? -yyn : 0;
    924 
    925         /* Stay within bounds of both yycheck and yytname.  */
    926         int yychecklim = yylast_ - yyn + 1;
    927         int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
    928         int count = 0;
    929         for (int x = yyxbegin; x < yyxend; ++x)
    930           if (yycheck_[x + yyn] == x && x != yyterror_)
    931             ++count;
    932 
    933         // FIXME: This method of building the message is not compatible
    934         // with internationalization.  It should work like yacc.c does it.
    935         // That is, first build a string that looks like this:
    936         // "syntax error, unexpected %s or %s or %s"
    937         // Then, invoke YY_ on this string.
    938         // Finally, use the string as a format to output
    939         // yytname_[tok], etc.
    940         // Until this gets fixed, this message appears in English only.
    941         res = "syntax error, unexpected ";
    942         res += yytnamerr_ (yytname_[tok]);
    943         if (count < 5)
    944           {
    945             count = 0;
    946             for (int x = yyxbegin; x < yyxend; ++x)
    947               if (yycheck_[x + yyn] == x && x != yyterror_)
    948                 {
    949                   res += (!count++) ? ", expecting " : " or ";
    950                   res += yytnamerr_ (yytname_[x]);
    951                 }
    952           }
    953       }
    954     else
    955 #endif
    956       res = YY_("syntax error");
    957     return res;
     966  MeshParser::yysyntax_error_ (int yystate, int yytoken)
     967  {
     968    std::string yyres;
     969    // Number of reported tokens (one for the "unexpected", one per
     970    // "expected").
     971    size_t yycount = 0;
     972    // Its maximum.
     973    enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
     974    // Arguments of yyformat.
     975    char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
     976
     977    /* There are many possibilities here to consider:
     978       - If this state is a consistent state with a default action, then
     979         the only way this function was invoked is if the default action
     980         is an error action.  In that case, don't check for expected
     981         tokens because there are none.
     982       - The only way there can be no lookahead present (in yytoken) is
     983         if this state is a consistent state with a default action.
     984         Thus, detecting the absence of a lookahead is sufficient to
     985         determine that there is no unexpected or expected token to
     986         report.  In that case, just report a simple "syntax error".
     987       - Don't assume there isn't a lookahead just because this state is
     988         a consistent state with a default action.  There might have
     989         been a previous inconsistent state, consistent state with a
     990         non-default action, or user semantic action that manipulated
     991         yychar.
     992       - Of course, the expected token list depends on states to have
     993         correct lookahead information, and it depends on the parser not
     994         to perform extra reductions after fetching a lookahead from the
     995         scanner and before detecting a syntax error.  Thus, state
     996         merging (from LALR or IELR) and default reductions corrupt the
     997         expected token list.  However, the list is correct for
     998         canonical LR with one exception: it will still contain any
     999         token that will not be accepted due to an error action in a
     1000         later state.
     1001    */
     1002    if (yytoken != yyempty_)
     1003      {
     1004        yyarg[yycount++] = yytname_[yytoken];
     1005        int yyn = yypact_[yystate];
     1006        if (!yy_pact_value_is_default_ (yyn))
     1007          {
     1008            /* Start YYX at -YYN if negative to avoid negative indexes in
     1009               YYCHECK.  In other words, skip the first -YYN actions for
     1010               this state because they are default actions.  */
     1011            int yyxbegin = yyn < 0 ? -yyn : 0;
     1012            /* Stay within bounds of both yycheck and yytname.  */
     1013            int yychecklim = yylast_ - yyn + 1;
     1014            int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
     1015            for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
     1016              if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
     1017                  && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
     1018                {
     1019                  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
     1020                    {
     1021                      yycount = 1;
     1022                      break;
     1023                    }
     1024                  else
     1025                    yyarg[yycount++] = yytname_[yyx];
     1026                }
     1027          }
     1028      }
     1029
     1030    char const* yyformat = 0;
     1031    switch (yycount)
     1032      {
     1033#define YYCASE_(N, S)                         \
     1034        case N:                               \
     1035          yyformat = S;                       \
     1036        break
     1037        YYCASE_(0, YY_("syntax error"));
     1038        YYCASE_(1, YY_("syntax error, unexpected %s"));
     1039        YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
     1040        YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
     1041        YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
     1042        YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
     1043#undef YYCASE_
     1044      }
     1045
     1046    // Argument number.
     1047    size_t yyi = 0;
     1048    for (char const* yyp = yyformat; *yyp; ++yyp)
     1049      if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
     1050        {
     1051          yyres += yytnamerr_ (yyarg[yyi++]);
     1052          ++yyp;
     1053        }
     1054      else
     1055        yyres += *yyp;
     1056    return yyres;
    9581057  }
    9591058
     
    9771076  };
    9781077
    979   /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
    980      doesn't specify something else to do.  Zero means the default is an
    981      error.  */
     1078  /* YYDEFACT[S] -- default reduction number in state S.  Performed when
     1079     YYTABLE doesn't specify something else to do.  Zero means the
     1080     default is an error.  */
    9821081  const unsigned char
    9831082  MeshParser::yydefact_[] =
     
    10131112  /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    10141113     positive, shift that token.  If negative, reduce the rule which
    1015      number is the opposite.  If zero, do what YYDEFACT says.  */
     1114     number is the opposite.  If YYTABLE_NINF_, syntax error.  */
    10161115  const signed char MeshParser::yytable_ninf_ = -1;
    10171116  const unsigned char
     
    12631362} // orbital
    12641363
    1265 /* Line 1053 of lalr1.cc  */
    1266 #line 1267 "generated/mesh-parser.cpp"
    1267 
    1268 
    1269 /* Line 1055 of lalr1.cc  */
     1364/* Line 1136 of lalr1.cc  */
     1365#line 1366 "generated/mesh-parser.cpp"
     1366
     1367
     1368/* Line 1138 of lalr1.cc  */
    12701369#line 172 "mesh-parser.y"
    12711370
Note: See TracChangeset for help on using the changeset viewer.