Changeset 1437


Ignore:
Timestamp:
Jun 3, 2012, 3:58:04 PM (7 years ago)
Author:
sam
Message:

orbital: build the scanners and parsers with more recent flex/bison.

Location:
trunk/orbital/generated
Files:
7 edited

Legend:

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

    r1434 r1437  
    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 "gun-parser.y"
    4040
     
    6161
    6262
    63 /* Line 310 of lalr1.cc  */
     63/* Line 293 of lalr1.cc  */
    6464#line 65 "generated/gun-parser.cpp"
    6565
     
    6969/* User implementation prologue.  */
    7070
    71 /* Line 316 of lalr1.cc  */
     71/* Line 299 of lalr1.cc  */
    7272#line 66 "gun-parser.y"
    7373
     
    7878
    7979
    80 /* Line 316 of lalr1.cc  */
     80/* Line 299 of lalr1.cc  */
    8181#line 82 "generated/gun-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/gun-parser.cpp"
    148 #if YYERROR_VERBOSE
     166/* Line 382 of lalr1.cc  */
     167#line 168 "generated/gun-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  GunParser::yy_pact_value_is_default_ (int yyvalue)
     308  {
     309    return yyvalue == yypact_ninf_;
     310  }
     311
     312  inline bool
     313  GunParser::yy_table_value_is_error_ (int yyvalue)
     314  {
     315    return yyvalue == yytable_ninf_;
     316  }
     317
    288318  int
    289319  GunParser::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 5:
    436466
    437 /* Line 677 of lalr1.cc  */
     467/* Line 690 of lalr1.cc  */
    438468#line 85 "gun-parser.y"
    439469    { gc.m_gun.m_angle = gc.m_gun.AimActor(); }
     
    442472  case 6:
    443473
    444 /* Line 677 of lalr1.cc  */
     474/* Line 690 of lalr1.cc  */
    445475#line 86 "gun-parser.y"
    446476    { gc.m_gun.PreAimActor((yysemantic_stack_[(2) - (2)].args).f0); }
     
    449479  case 7:
    450480
    451 /* Line 677 of lalr1.cc  */
     481/* Line 690 of lalr1.cc  */
    452482#line 87 "gun-parser.y"
    453483    { gc.m_gun.m_pre_aim = (yysemantic_stack_[(2) - (2)].args).f0; }
     
    456486  case 8:
    457487
    458 /* Line 677 of lalr1.cc  */
     488/* Line 690 of lalr1.cc  */
    459489#line 88 "gun-parser.y"
    460490    { gc.m_gun.m_angle = (yysemantic_stack_[(2) - (2)].args).f0; }
     
    463493  case 9:
    464494
    465 /* Line 677 of lalr1.cc  */
     495/* Line 690 of lalr1.cc  */
    466496#line 89 "gun-parser.y"
    467497    { gc.m_gun.m_round_duration = (yysemantic_stack_[(2) - (2)].args).f0; }
     
    470500  case 10:
    471501
    472 /* Line 677 of lalr1.cc  */
     502/* Line 690 of lalr1.cc  */
    473503#line 90 "gun-parser.y"
    474504    { gc.m_gun.m_angle_offset = (yysemantic_stack_[(2) - (2)].args).f0; }
     
    477507  case 11:
    478508
    479 /* Line 677 of lalr1.cc  */
     509/* Line 690 of lalr1.cc  */
    480510#line 91 "gun-parser.y"
    481511    { gc.m_gun.m_radius = (yysemantic_stack_[(2) - (2)].args).f0; }
     
    484514  case 12:
    485515
    486 /* Line 677 of lalr1.cc  */
     516/* Line 690 of lalr1.cc  */
    487517#line 92 "gun-parser.y"
    488518    { gc.m_gun.m_shoot_speed = (yysemantic_stack_[(2) - (2)].args).f0; }
     
    491521  case 13:
    492522
    493 /* Line 677 of lalr1.cc  */
     523/* Line 690 of lalr1.cc  */
    494524#line 93 "gun-parser.y"
    495525    { /* FIXME: 1st modifier */ }
     
    498528  case 14:
    499529
    500 /* Line 677 of lalr1.cc  */
     530/* Line 690 of lalr1.cc  */
    501531#line 94 "gun-parser.y"
    502532    { /* FIXME: 2nd modifier */ }
     
    505535  case 15:
    506536
    507 /* Line 677 of lalr1.cc  */
     537/* Line 690 of lalr1.cc  */
    508538#line 95 "gun-parser.y"
    509539    { for (int i = 0; i < (int)(yysemantic_stack_[(2) - (2)].args).f0; i++) gc.m_gun.Shoot(1);
     
    514544  case 16:
    515545
    516 /* Line 677 of lalr1.cc  */
     546/* Line 690 of lalr1.cc  */
    517547#line 98 "gun-parser.y"
    518548    { for (int i = 0; i < (int)(yysemantic_stack_[(2) - (2)].args).f0; i++) gc.m_gun.Shoot(0);
     
    523553  case 17:
    524554
    525 /* Line 677 of lalr1.cc  */
     555/* Line 690 of lalr1.cc  */
    526556#line 101 "gun-parser.y"
    527557    { gc.m_gun.Shoot(1); gc.m_gun.m_nbshoots = (int)(yysemantic_stack_[(2) - (2)].args).f0 - 1;
     
    532562  case 18:
    533563
    534 /* Line 677 of lalr1.cc  */
     564/* Line 690 of lalr1.cc  */
    535565#line 104 "gun-parser.y"
    536566    { gc.m_gun.Shoot(0); gc.m_gun.m_nbshoots = (int)(yysemantic_stack_[(2) - (2)].args).f0 - 1;
     
    541571  case 19:
    542572
    543 /* Line 677 of lalr1.cc  */
     573/* Line 690 of lalr1.cc  */
    544574#line 107 "gun-parser.y"
    545575    { gc.m_gun.m_round_timer = gc.m_gun.m_round_duration * (yysemantic_stack_[(2) - (2)].args).f0;
     
    549579  case 20:
    550580
    551 /* Line 677 of lalr1.cc  */
     581/* Line 690 of lalr1.cc  */
    552582#line 109 "gun-parser.y"
    553583    { /* FIXME: loops */ }
     
    556586  case 21:
    557587
    558 /* Line 677 of lalr1.cc  */
     588/* Line 690 of lalr1.cc  */
    559589#line 112 "gun-parser.y"
    560590    { (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); }
     
    563593  case 22:
    564594
    565 /* Line 677 of lalr1.cc  */
     595/* Line 690 of lalr1.cc  */
    566596#line 113 "gun-parser.y"
    567597    { (yyval.args) = (yysemantic_stack_[(3) - (1)].args); (yyval.args).f1 = (yysemantic_stack_[(3) - (3)].fval); }
     
    570600  case 23:
    571601
    572 /* Line 677 of lalr1.cc  */
     602/* Line 690 of lalr1.cc  */
    573603#line 114 "gun-parser.y"
    574604    { (yyval.args) = (yysemantic_stack_[(3) - (1)].args); (yyval.args).f2 = (yysemantic_stack_[(3) - (3)].fval); }
     
    577607  case 24:
    578608
    579 /* Line 677 of lalr1.cc  */
     609/* Line 690 of lalr1.cc  */
    580610#line 117 "gun-parser.y"
    581611    { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); }
     
    584614  case 25:
    585615
    586 /* Line 677 of lalr1.cc  */
     616/* Line 690 of lalr1.cc  */
    587617#line 118 "gun-parser.y"
    588618    { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); }
     
    591621
    592622
    593 /* Line 677 of lalr1.cc  */
    594 #line 595 "generated/gun-parser.cpp"
     623/* Line 690 of lalr1.cc  */
     624#line 625 "generated/gun-parser.cpp"
    595625        default:
    596626          break;
    597627      }
     628    /* User semantic actions sometimes alter yychar, and that requires
     629       that yytoken be updated with the new translation.  We take the
     630       approach of translating immediately before every use of yytoken.
     631       One alternative is translating here after every semantic action,
     632       but that translation would be missed if the semantic action
     633       invokes YYABORT, YYACCEPT, or YYERROR immediately after altering
     634       yychar.  In the case of YYABORT or YYACCEPT, an incorrect
     635       destructor might then be invoked immediately.  In the case of
     636       YYERROR, subsequent parser actions might lead to an incorrect
     637       destructor call or verbose syntax error message before the
     638       lookahead is translated.  */
    598639    YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
    599640
     
    619660  `------------------------------------*/
    620661  yyerrlab:
     662    /* Make sure we have latest lookahead translation.  See comments at
     663       user semantic actions for why this is necessary.  */
     664    yytoken = yytranslate_ (yychar);
     665
    621666    /* If not already recovering from an error, report this error.  */
    622667    if (!yyerrstatus_)
    623668      {
    624669        ++yynerrs_;
     670        if (yychar == yyempty_)
     671          yytoken = yyempty_;
    625672        error (yylloc, yysyntax_error_ (yystate, yytoken));
    626673      }
    627674
    628     yyerror_range[0] = yylloc;
     675    yyerror_range[1] = yylloc;
    629676    if (yyerrstatus_ == 3)
    630677      {
     
    661708      goto yyerrorlab;
    662709
    663     yyerror_range[0] = yylocation_stack_[yylen - 1];
     710    yyerror_range[1] = yylocation_stack_[yylen - 1];
    664711    /* Do not reclaim the symbols of the rule which action triggered
    665712       this YYERROR.  */
     
    678725      {
    679726        yyn = yypact_[yystate];
    680         if (yyn != yypact_ninf_)
     727        if (!yy_pact_value_is_default_ (yyn))
    681728        {
    682729          yyn += yyterror_;
     
    693740        YYABORT;
    694741
    695         yyerror_range[0] = yylocation_stack_[0];
     742        yyerror_range[1] = yylocation_stack_[0];
    696743        yydestruct_ ("Error: popping",
    697744                     yystos_[yystate],
     
    702749      }
    703750
    704     yyerror_range[1] = yylloc;
     751    yyerror_range[2] = yylloc;
    705752    // Using YYLLOC is tempting, but would change the location of
    706753    // the lookahead.  YYLOC is available though.
    707     YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
     754    YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
    708755    yysemantic_stack_.push (yylval);
    709756    yylocation_stack_.push (yyloc);
     
    728775  yyreturn:
    729776    if (yychar != yyempty_)
    730       yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
     777      {
     778        /* Make sure we have latest lookahead translation.  See comments
     779           at user semantic actions for why this is necessary.  */
     780        yytoken = yytranslate_ (yychar);
     781        yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval,
     782                     &yylloc);
     783      }
    731784
    732785    /* Do not reclaim the symbols of the rule which action triggered
     
    747800  // Generate an error message.
    748801  std::string
    749   GunParser::yysyntax_error_ (int yystate, int tok)
    750   {
    751     std::string res;
    752     YYUSE (yystate);
    753 #if YYERROR_VERBOSE
    754     int yyn = yypact_[yystate];
    755     if (yypact_ninf_ < yyn && yyn <= yylast_)
    756       {
    757         /* Start YYX at -YYN if negative to avoid negative indexes in
    758            YYCHECK.  */
    759         int yyxbegin = yyn < 0 ? -yyn : 0;
    760 
    761         /* Stay within bounds of both yycheck and yytname.  */
    762         int yychecklim = yylast_ - yyn + 1;
    763         int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
    764         int count = 0;
    765         for (int x = yyxbegin; x < yyxend; ++x)
    766           if (yycheck_[x + yyn] == x && x != yyterror_)
    767             ++count;
    768 
    769         // FIXME: This method of building the message is not compatible
    770         // with internationalization.  It should work like yacc.c does it.
    771         // That is, first build a string that looks like this:
    772         // "syntax error, unexpected %s or %s or %s"
    773         // Then, invoke YY_ on this string.
    774         // Finally, use the string as a format to output
    775         // yytname_[tok], etc.
    776         // Until this gets fixed, this message appears in English only.
    777         res = "syntax error, unexpected ";
    778         res += yytnamerr_ (yytname_[tok]);
    779         if (count < 5)
    780           {
    781             count = 0;
    782             for (int x = yyxbegin; x < yyxend; ++x)
    783               if (yycheck_[x + yyn] == x && x != yyterror_)
    784                 {
    785                   res += (!count++) ? ", expecting " : " or ";
    786                   res += yytnamerr_ (yytname_[x]);
    787                 }
    788           }
    789       }
    790     else
    791 #endif
    792       res = YY_("syntax error");
    793     return res;
     802  GunParser::yysyntax_error_ (int yystate, int yytoken)
     803  {
     804    std::string yyres;
     805    // Number of reported tokens (one for the "unexpected", one per
     806    // "expected").
     807    size_t yycount = 0;
     808    // Its maximum.
     809    enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
     810    // Arguments of yyformat.
     811    char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
     812
     813    /* There are many possibilities here to consider:
     814       - If this state is a consistent state with a default action, then
     815         the only way this function was invoked is if the default action
     816         is an error action.  In that case, don't check for expected
     817         tokens because there are none.
     818       - The only way there can be no lookahead present (in yytoken) is
     819         if this state is a consistent state with a default action.
     820         Thus, detecting the absence of a lookahead is sufficient to
     821         determine that there is no unexpected or expected token to
     822         report.  In that case, just report a simple "syntax error".
     823       - Don't assume there isn't a lookahead just because this state is
     824         a consistent state with a default action.  There might have
     825         been a previous inconsistent state, consistent state with a
     826         non-default action, or user semantic action that manipulated
     827         yychar.
     828       - Of course, the expected token list depends on states to have
     829         correct lookahead information, and it depends on the parser not
     830         to perform extra reductions after fetching a lookahead from the
     831         scanner and before detecting a syntax error.  Thus, state
     832         merging (from LALR or IELR) and default reductions corrupt the
     833         expected token list.  However, the list is correct for
     834         canonical LR with one exception: it will still contain any
     835         token that will not be accepted due to an error action in a
     836         later state.
     837    */
     838    if (yytoken != yyempty_)
     839      {
     840        yyarg[yycount++] = yytname_[yytoken];
     841        int yyn = yypact_[yystate];
     842        if (!yy_pact_value_is_default_ (yyn))
     843          {
     844            /* Start YYX at -YYN if negative to avoid negative indexes in
     845               YYCHECK.  In other words, skip the first -YYN actions for
     846               this state because they are default actions.  */
     847            int yyxbegin = yyn < 0 ? -yyn : 0;
     848            /* Stay within bounds of both yycheck and yytname.  */
     849            int yychecklim = yylast_ - yyn + 1;
     850            int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
     851            for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
     852              if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
     853                  && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
     854                {
     855                  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
     856                    {
     857                      yycount = 1;
     858                      break;
     859                    }
     860                  else
     861                    yyarg[yycount++] = yytname_[yyx];
     862                }
     863          }
     864      }
     865
     866    char const* yyformat = 0;
     867    switch (yycount)
     868      {
     869#define YYCASE_(N, S)                         \
     870        case N:                               \
     871          yyformat = S;                       \
     872        break
     873        YYCASE_(0, YY_("syntax error"));
     874        YYCASE_(1, YY_("syntax error, unexpected %s"));
     875        YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
     876        YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
     877        YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
     878        YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
     879#undef YYCASE_
     880      }
     881
     882    // Argument number.
     883    size_t yyi = 0;
     884    for (char const* yyp = yyformat; *yyp; ++yyp)
     885      if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
     886        {
     887          yyres += yytnamerr_ (yyarg[yyi++]);
     888          ++yyp;
     889        }
     890      else
     891        yyres += *yyp;
     892    return yyres;
    794893  }
    795894
     
    808907  };
    809908
    810   /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
    811      doesn't specify something else to do.  Zero means the default is an
    812      error.  */
     909  /* YYDEFACT[S] -- default reduction number in state S.  Performed when
     910     YYTABLE doesn't specify something else to do.  Zero means the
     911     default is an error.  */
    813912  const unsigned char
    814913  GunParser::yydefact_[] =
     
    837936  /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    838937     positive, shift that token.  If negative, reduce the rule which
    839      number is the opposite.  If zero, do what YYDEFACT says.  */
     938     number is the opposite.  If YYTABLE_NINF_, syntax error.  */
    840939  const signed char GunParser::yytable_ninf_ = -1;
    841940  const unsigned char
     
    10371136} // orbital
    10381137
    1039 /* Line 1053 of lalr1.cc  */
    1040 #line 1041 "generated/gun-parser.cpp"
    1041 
    1042 
    1043 /* Line 1055 of lalr1.cc  */
     1138/* Line 1136 of lalr1.cc  */
     1139#line 1140 "generated/gun-parser.cpp"
     1140
     1141
     1142/* Line 1138 of lalr1.cc  */
    10441143#line 121 "gun-parser.y"
    10451144
  • trunk/orbital/generated/gun-parser.h

    r1434 r1437  
    1 /* A Bison parser, made by GNU Bison 2.4.2.  */
     1/* A Bison parser, made by GNU Bison 2.5.  */
    22
    33/* Skeleton interface 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
     
    4141#include <iostream>
    4242#include "stack.hh"
    43 
    44 
    45 namespace orbital {
    46 
    47 /* Line 34 of lalr1.cc  */
    48 #line 49 "generated/gun-parser.h"
    49   class position;
    50   class location;
    51 
    52 } // orbital
    53 
    54 /* Line 34 of lalr1.cc  */
    55 #line 56 "generated/gun-parser.h"
    56 
    5743#include "location.hh"
    5844
     
    7561#endif
    7662
    77 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
    78    If N is 0, then set CURRENT to the empty location which ends
    79    the previous symbol: RHS[0] (always defined).  */
    80 
    81 #ifndef YYLLOC_DEFAULT
    82 # define YYLLOC_DEFAULT(Current, Rhs, N)                \
    83 do {                                                    \
    84   if (N)                                                \
    85     {                                                   \
    86       (Current).begin = (Rhs)[1].begin;                 \
    87       (Current).end   = (Rhs)[N].end;                   \
    88     }                                                   \
    89   else                                                  \
    90     {                                                   \
    91       (Current).begin = (Current).end = (Rhs)[0].end;   \
    92     }                                                   \
    93 } while (false)
    94 #endif
    95 
    9663
    9764namespace orbital {
    9865
    99 /* Line 34 of lalr1.cc  */
    100 #line 101 "generated/gun-parser.h"
     66/* Line 35 of lalr1.cc  */
     67#line 68 "generated/gun-parser.h"
    10168
    10269  /// A Bison parser.
     
    10976    {
    11077
    111 /* Line 34 of lalr1.cc  */
     78/* Line 35 of lalr1.cc  */
    11279#line 35 "gun-parser.y"
    11380
     
    11784
    11885
    119 /* Line 34 of lalr1.cc  */
    120 #line 121 "generated/gun-parser.h"
     86/* Line 35 of lalr1.cc  */
     87#line 88 "generated/gun-parser.h"
    12188    };
    12289#else
     
    221188    location_stack_type yylocation_stack_;
    222189
     190    /// Whether the given \c yypact_ value indicates a defaulted state.
     191    /// \param yyvalue   the value to check
     192    static bool yy_pact_value_is_default_ (int yyvalue);
     193
     194    /// Whether the given \c yytable_ value indicates a syntax error.
     195    /// \param yyvalue   the value to check
     196    static bool yy_table_value_is_error_ (int yyvalue);
     197
    223198    /// Internal symbol numbers.
    224199    typedef unsigned char token_number_type;
     
    228203    static const signed char yypact_ninf_;
    229204
    230     /// For a state, default rule to reduce.
     205    /// For a state, default reduction number.
    231206    /// Unless\a  yytable_ specifies something else to do.
    232207    /// Zero means the default is an error.
     
    259234#endif
    260235
    261 #if YYERROR_VERBOSE
    262236    /// Convert the symbol name \a n to a form suitable for a diagnostic.
    263     virtual std::string yytnamerr_ (const char *n);
    264 #endif
     237    static std::string yytnamerr_ (const char *n);
    265238
    266239#if YYDEBUG
     
    320293} // orbital
    321294
    322 /* Line 34 of lalr1.cc  */
    323 #line 324 "generated/gun-parser.h"
     295/* Line 35 of lalr1.cc  */
     296#line 297 "generated/gun-parser.h"
    324297
    325298
  • trunk/orbital/generated/location.hh

    r1434 r1437  
    1 /* A Bison parser, made by GNU Bison 2.4.2.  */
     1/* A Bison parser, made by GNU Bison 2.5.  */
    22
    33/* Locations for Bison parsers in C++
    44   
    5       Copyright (C) 2002-2007, 2009-2010 Free Software Foundation, Inc.
     5      Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc.
    66   
    77   This program is free software: you can redistribute it and/or modify
  • trunk/orbital/generated/mesh-parser.cpp

    r1434 r1437  
    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 64 "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 88 "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 92 "mesh-parser.y"
    446476    { mc.m_mesh.CloseBrace(); }
     
    449479  case 15:
    450480
    451 /* Line 677 of lalr1.cc  */
     481/* Line 690 of lalr1.cc  */
    452482#line 108 "mesh-parser.y"
    453483    { mc.m_mesh.MeshConvert(); }
     
    456486  case 16:
    457487
    458 /* Line 677 of lalr1.cc  */
     488/* Line 690 of lalr1.cc  */
    459489#line 109 "mesh-parser.y"
    460490    { /* TODO */ }
     
    463493  case 17:
    464494
    465 /* Line 677 of lalr1.cc  */
     495/* Line 690 of lalr1.cc  */
    466496#line 113 "mesh-parser.y"
    467497    { 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)); }
     
    470500  case 18:
    471501
    472 /* Line 677 of lalr1.cc  */
     502/* Line 690 of lalr1.cc  */
    473503#line 114 "mesh-parser.y"
    474504    { uint16_t x = (uint16_t)(yysemantic_stack_[(2) - (2)].u32val);
     
    479509  case 19:
    480510
    481 /* Line 677 of lalr1.cc  */
     511/* Line 690 of lalr1.cc  */
    482512#line 117 "mesh-parser.y"
    483513    { 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)); }
     
    486516  case 20:
    487517
    488 /* Line 677 of lalr1.cc  */
     518/* Line 690 of lalr1.cc  */
    489519#line 118 "mesh-parser.y"
    490520    { uint16_t x = (uint16_t)(yysemantic_stack_[(2) - (2)].u32val);
     
    495525  case 21:
    496526
    497 /* Line 677 of lalr1.cc  */
     527/* Line 690 of lalr1.cc  */
    498528#line 124 "mesh-parser.y"
    499529    { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, 0, 0)); }
     
    502532  case 22:
    503533
    504 /* Line 677 of lalr1.cc  */
     534/* Line 690 of lalr1.cc  */
    505535#line 125 "mesh-parser.y"
    506536    { mc.m_mesh.Translate(vec3(0, (yysemantic_stack_[(2) - (2)].args).f0, 0)); }
     
    509539  case 23:
    510540
    511 /* Line 677 of lalr1.cc  */
     541/* Line 690 of lalr1.cc  */
    512542#line 126 "mesh-parser.y"
    513543    { mc.m_mesh.Translate(vec3(0, 0, (yysemantic_stack_[(2) - (2)].args).f0)); }
     
    516546  case 24:
    517547
    518 /* Line 677 of lalr1.cc  */
     548/* Line 690 of lalr1.cc  */
    519549#line 127 "mesh-parser.y"
    520550    { mc.m_mesh.Translate(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
     
    523553  case 25:
    524554
    525 /* Line 677 of lalr1.cc  */
     555/* Line 690 of lalr1.cc  */
    526556#line 128 "mesh-parser.y"
    527557    { mc.m_mesh.RotateX((yysemantic_stack_[(2) - (2)].args).f0); }
     
    530560  case 26:
    531561
    532 /* Line 677 of lalr1.cc  */
     562/* Line 690 of lalr1.cc  */
    533563#line 129 "mesh-parser.y"
    534564    { mc.m_mesh.RotateY((yysemantic_stack_[(2) - (2)].args).f0); }
     
    537567  case 27:
    538568
    539 /* Line 677 of lalr1.cc  */
     569/* Line 690 of lalr1.cc  */
    540570#line 130 "mesh-parser.y"
    541571    { mc.m_mesh.RotateZ((yysemantic_stack_[(2) - (2)].args).f0); }
     
    544574  case 28:
    545575
    546 /* Line 677 of lalr1.cc  */
     576/* Line 690 of lalr1.cc  */
    547577#line 131 "mesh-parser.y"
    548578    { mc.m_mesh.TaperX((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
     
    551581  case 29:
    552582
    553 /* Line 677 of lalr1.cc  */
     583/* Line 690 of lalr1.cc  */
    554584#line 132 "mesh-parser.y"
    555585    { mc.m_mesh.TaperY((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
     
    558588  case 30:
    559589
    560 /* Line 677 of lalr1.cc  */
     590/* Line 690 of lalr1.cc  */
    561591#line 133 "mesh-parser.y"
    562592    { mc.m_mesh.TaperZ((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2); }
     
    565595  case 31:
    566596
    567 /* Line 677 of lalr1.cc  */
     597/* Line 690 of lalr1.cc  */
    568598#line 134 "mesh-parser.y"
    569599    { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, 0, 0)); }
     
    572602  case 32:
    573603
    574 /* Line 677 of lalr1.cc  */
     604/* Line 690 of lalr1.cc  */
    575605#line 135 "mesh-parser.y"
    576606    { mc.m_mesh.Scale(vec3(0, (yysemantic_stack_[(2) - (2)].args).f0, 0)); }
     
    579609  case 33:
    580610
    581 /* Line 677 of lalr1.cc  */
     611/* Line 690 of lalr1.cc  */
    582612#line 136 "mesh-parser.y"
    583613    { mc.m_mesh.Scale(vec3(0, 0, (yysemantic_stack_[(2) - (2)].args).f0)); }
     
    586616  case 34:
    587617
    588 /* Line 677 of lalr1.cc  */
     618/* Line 690 of lalr1.cc  */
    589619#line 137 "mesh-parser.y"
    590620    { mc.m_mesh.Scale(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
     
    593623  case 35:
    594624
    595 /* Line 677 of lalr1.cc  */
     625/* Line 690 of lalr1.cc  */
    596626#line 138 "mesh-parser.y"
    597627    { mc.m_mesh.MirrorX(); }
     
    600630  case 36:
    601631
    602 /* Line 677 of lalr1.cc  */
     632/* Line 690 of lalr1.cc  */
    603633#line 139 "mesh-parser.y"
    604634    { mc.m_mesh.MirrorY(); }
     
    607637  case 37:
    608638
    609 /* Line 677 of lalr1.cc  */
     639/* Line 690 of lalr1.cc  */
    610640#line 140 "mesh-parser.y"
    611641    { mc.m_mesh.MirrorZ(); }
     
    614644  case 38:
    615645
    616 /* Line 677 of lalr1.cc  */
     646/* Line 690 of lalr1.cc  */
    617647#line 144 "mesh-parser.y"
    618648    { mc.m_mesh.AppendCylinder((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
     
    623653  case 39:
    624654
    625 /* Line 677 of lalr1.cc  */
     655/* Line 690 of lalr1.cc  */
    626656#line 147 "mesh-parser.y"
    627657    { mc.m_mesh.AppendBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2)); }
     
    630660  case 40:
    631661
    632 /* Line 677 of lalr1.cc  */
     662/* Line 690 of lalr1.cc  */
    633663#line 148 "mesh-parser.y"
    634664    { mc.m_mesh.AppendSmoothChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
     
    638668  case 41:
    639669
    640 /* Line 677 of lalr1.cc  */
     670/* Line 690 of lalr1.cc  */
    641671#line 150 "mesh-parser.y"
    642672    { mc.m_mesh.AppendFlatChamfBox(vec3((yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
     
    646676  case 42:
    647677
    648 /* Line 677 of lalr1.cc  */
     678/* Line 690 of lalr1.cc  */
    649679#line 152 "mesh-parser.y"
    650680    { mc.m_mesh.AppendSphere((yysemantic_stack_[(2) - (2)].args).f0,
     
    654684  case 43:
    655685
    656 /* Line 677 of lalr1.cc  */
     686/* Line 690 of lalr1.cc  */
    657687#line 154 "mesh-parser.y"
    658688    { mc.m_mesh.AppendStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (yysemantic_stack_[(2) - (2)].args).f2,
     
    662692  case 44:
    663693
    664 /* Line 677 of lalr1.cc  */
     694/* Line 690 of lalr1.cc  */
    665695#line 156 "mesh-parser.y"
    666696    { mc.m_mesh.AppendExpandedStar((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1,
     
    670700  case 45:
    671701
    672 /* Line 677 of lalr1.cc  */
     702/* Line 690 of lalr1.cc  */
    673703#line 158 "mesh-parser.y"
    674704    { mc.m_mesh.AppendDisc((int)(yysemantic_stack_[(2) - (2)].args).f0, (yysemantic_stack_[(2) - (2)].args).f1, (int)(yysemantic_stack_[(2) - (2)].args).f2); }
     
    677707  case 46:
    678708
    679 /* Line 677 of lalr1.cc  */
     709/* Line 690 of lalr1.cc  */
    680710#line 159 "mesh-parser.y"
    681711    { mc.m_mesh.AppendSimpleTriangle((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); }
     
    684714  case 47:
    685715
    686 /* Line 677 of lalr1.cc  */
     716/* Line 690 of lalr1.cc  */
    687717#line 160 "mesh-parser.y"
    688718    { mc.m_mesh.AppendSimpleQuad((yysemantic_stack_[(2) - (2)].args).f0, (int)(yysemantic_stack_[(2) - (2)].args).f1); }
     
    691721  case 48:
    692722
    693 /* Line 677 of lalr1.cc  */
     723/* Line 690 of lalr1.cc  */
    694724#line 161 "mesh-parser.y"
    695725    { 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,
     
    699729  case 49:
    700730
    701 /* Line 677 of lalr1.cc  */
     731/* Line 690 of lalr1.cc  */
    702732#line 165 "mesh-parser.y"
    703733    { (yyval.args).f0 = (yysemantic_stack_[(1) - (1)].fval); }
     
    706736  case 50:
    707737
    708 /* Line 677 of lalr1.cc  */
     738/* Line 690 of lalr1.cc  */
    709739#line 166 "mesh-parser.y"
    710740    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f1 = (yysemantic_stack_[(2) - (2)].fval); }
     
    713743  case 51:
    714744
    715 /* Line 677 of lalr1.cc  */
     745/* Line 690 of lalr1.cc  */
    716746#line 167 "mesh-parser.y"
    717747    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f2 = (yysemantic_stack_[(2) - (2)].fval); }
     
    720750  case 52:
    721751
    722 /* Line 677 of lalr1.cc  */
     752/* Line 690 of lalr1.cc  */
    723753#line 168 "mesh-parser.y"
    724754    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f3 = (yysemantic_stack_[(2) - (2)].fval); }
     
    727757  case 53:
    728758
    729 /* Line 677 of lalr1.cc  */
     759/* Line 690 of lalr1.cc  */
    730760#line 169 "mesh-parser.y"
    731761    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f4 = (yysemantic_stack_[(2) - (2)].fval); }
     
    734764  case 54:
    735765
    736 /* Line 677 of lalr1.cc  */
     766/* Line 690 of lalr1.cc  */
    737767#line 170 "mesh-parser.y"
    738768    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f5 = (yysemantic_stack_[(2) - (2)].fval); }
     
    741771  case 55:
    742772
    743 /* Line 677 of lalr1.cc  */
     773/* Line 690 of lalr1.cc  */
    744774#line 171 "mesh-parser.y"
    745775    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f6 = (yysemantic_stack_[(2) - (2)].fval); }
     
    748778  case 56:
    749779
    750 /* Line 677 of lalr1.cc  */
     780/* Line 690 of lalr1.cc  */
    751781#line 172 "mesh-parser.y"
    752782    { (yyval.args) = (yysemantic_stack_[(2) - (1)].args); (yyval.args).f7 = (yysemantic_stack_[(2) - (2)].fval); }
     
    755785  case 57:
    756786
    757 /* Line 677 of lalr1.cc  */
     787/* Line 690 of lalr1.cc  */
    758788#line 175 "mesh-parser.y"
    759789    { (yyval.fval) = (yysemantic_stack_[(1) - (1)].fval); }
     
    762792  case 58:
    763793
    764 /* Line 677 of lalr1.cc  */
     794/* Line 690 of lalr1.cc  */
    765795#line 176 "mesh-parser.y"
    766796    { (yyval.fval) = -(yysemantic_stack_[(2) - (2)].fval); }
     
    769799
    770800
    771 /* Line 677 of lalr1.cc  */
    772 #line 773 "generated/mesh-parser.cpp"
     801/* Line 690 of lalr1.cc  */
     802#line 803 "generated/mesh-parser.cpp"
    773803        default:
    774804          break;
    775805      }
     806    /* User semantic actions sometimes alter yychar, and that requires
     807       that yytoken be updated with the new translation.  We take the
     808       approach of translating immediately before every use of yytoken.
     809       One alternative is translating here after every semantic action,
     810       but that translation would be missed if the semantic action
     811       invokes YYABORT, YYACCEPT, or YYERROR immediately after altering
     812       yychar.  In the case of YYABORT or YYACCEPT, an incorrect
     813       destructor might then be invoked immediately.  In the case of
     814       YYERROR, subsequent parser actions might lead to an incorrect
     815       destructor call or verbose syntax error message before the
     816       lookahead is translated.  */
    776817    YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
    777818
     
    797838  `------------------------------------*/
    798839  yyerrlab:
     840    /* Make sure we have latest lookahead translation.  See comments at
     841       user semantic actions for why this is necessary.  */
     842    yytoken = yytranslate_ (yychar);
     843
    799844    /* If not already recovering from an error, report this error.  */
    800845    if (!yyerrstatus_)
    801846      {
    802847        ++yynerrs_;
     848        if (yychar == yyempty_)
     849          yytoken = yyempty_;
    803850        error (yylloc, yysyntax_error_ (yystate, yytoken));
    804851      }
    805852
    806     yyerror_range[0] = yylloc;
     853    yyerror_range[1] = yylloc;
    807854    if (yyerrstatus_ == 3)
    808855      {
     
    839886      goto yyerrorlab;
    840887
    841     yyerror_range[0] = yylocation_stack_[yylen - 1];
     888    yyerror_range[1] = yylocation_stack_[yylen - 1];
    842889    /* Do not reclaim the symbols of the rule which action triggered
    843890       this YYERROR.  */
     
    856903      {
    857904        yyn = yypact_[yystate];
    858         if (yyn != yypact_ninf_)
     905        if (!yy_pact_value_is_default_ (yyn))
    859906        {
    860907          yyn += yyterror_;
     
    871918        YYABORT;
    872919
    873         yyerror_range[0] = yylocation_stack_[0];
     920        yyerror_range[1] = yylocation_stack_[0];
    874921        yydestruct_ ("Error: popping",
    875922                     yystos_[yystate],
     
    880927      }
    881928
    882     yyerror_range[1] = yylloc;
     929    yyerror_range[2] = yylloc;
    883930    // Using YYLLOC is tempting, but would change the location of
    884931    // the lookahead.  YYLOC is available though.
    885     YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
     932    YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
    886933    yysemantic_stack_.push (yylval);
    887934    yylocation_stack_.push (yyloc);
     
    906953  yyreturn:
    907954    if (yychar != yyempty_)
    908       yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
     955      {
     956        /* Make sure we have latest lookahead translation.  See comments
     957           at user semantic actions for why this is necessary.  */
     958        yytoken = yytranslate_ (yychar);
     959        yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval,
     960                     &yylloc);
     961      }
    909962
    910963    /* Do not reclaim the symbols of the rule which action triggered
     
    925978  // Generate an error message.
    926979  std::string
    927   MeshParser::yysyntax_error_ (int yystate, int tok)
    928   {
    929     std::string res;
    930     YYUSE (yystate);
    931 #if YYERROR_VERBOSE
    932     int yyn = yypact_[yystate];
    933     if (yypact_ninf_ < yyn && yyn <= yylast_)
    934       {
    935         /* Start YYX at -YYN if negative to avoid negative indexes in
    936            YYCHECK.  */
    937         int yyxbegin = yyn < 0 ? -yyn : 0;
    938 
    939         /* Stay within bounds of both yycheck and yytname.  */
    940         int yychecklim = yylast_ - yyn + 1;
    941         int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
    942         int count = 0;
    943         for (int x = yyxbegin; x < yyxend; ++x)
    944           if (yycheck_[x + yyn] == x && x != yyterror_)
    945             ++count;
    946 
    947         // FIXME: This method of building the message is not compatible
    948         // with internationalization.  It should work like yacc.c does it.
    949         // That is, first build a string that looks like this:
    950         // "syntax error, unexpected %s or %s or %s"
    951         // Then, invoke YY_ on this string.
    952         // Finally, use the string as a format to output
    953         // yytname_[tok], etc.
    954         // Until this gets fixed, this message appears in English only.
    955         res = "syntax error, unexpected ";
    956         res += yytnamerr_ (yytname_[tok]);
    957         if (count < 5)
    958           {
    959             count = 0;
    960             for (int x = yyxbegin; x < yyxend; ++x)
    961               if (yycheck_[x + yyn] == x && x != yyterror_)
    962                 {
    963                   res += (!count++) ? ", expecting " : " or ";
    964                   res += yytnamerr_ (yytname_[x]);
    965                 }
    966           }
    967       }
    968     else
    969 #endif
    970       res = YY_("syntax error");
    971     return res;
     980  MeshParser::yysyntax_error_ (int yystate, int yytoken)
     981  {
     982    std::string yyres;
     983    // Number of reported tokens (one for the "unexpected", one per
     984    // "expected").
     985    size_t yycount = 0;
     986    // Its maximum.
     987    enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
     988    // Arguments of yyformat.
     989    char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
     990
     991    /* There are many possibilities here to consider:
     992       - If this state is a consistent state with a default action, then
     993         the only way this function was invoked is if the default action
     994         is an error action.  In that case, don't check for expected
     995         tokens because there are none.
     996       - The only way there can be no lookahead present (in yytoken) is
     997         if this state is a consistent state with a default action.
     998         Thus, detecting the absence of a lookahead is sufficient to
     999         determine that there is no unexpected or expected token to
     1000         report.  In that case, just report a simple "syntax error".
     1001       - Don't assume there isn't a lookahead just because this state is
     1002         a consistent state with a default action.  There might have
     1003         been a previous inconsistent state, consistent state with a
     1004         non-default action, or user semantic action that manipulated
     1005         yychar.
     1006       - Of course, the expected token list depends on states to have
     1007         correct lookahead information, and it depends on the parser not
     1008         to perform extra reductions after fetching a lookahead from the
     1009         scanner and before detecting a syntax error.  Thus, state
     1010         merging (from LALR or IELR) and default reductions corrupt the
     1011         expected token list.  However, the list is correct for
     1012         canonical LR with one exception: it will still contain any
     1013         token that will not be accepted due to an error action in a
     1014         later state.
     1015    */
     1016    if (yytoken != yyempty_)
     1017      {
     1018        yyarg[yycount++] = yytname_[yytoken];
     1019        int yyn = yypact_[yystate];
     1020        if (!yy_pact_value_is_default_ (yyn))
     1021          {
     1022            /* Start YYX at -YYN if negative to avoid negative indexes in
     1023               YYCHECK.  In other words, skip the first -YYN actions for
     1024               this state because they are default actions.  */
     1025            int yyxbegin = yyn < 0 ? -yyn : 0;
     1026            /* Stay within bounds of both yycheck and yytname.  */
     1027            int yychecklim = yylast_ - yyn + 1;
     1028            int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
     1029            for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
     1030              if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
     1031                  && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
     1032                {
     1033                  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
     1034                    {
     1035                      yycount = 1;
     1036                      break;
     1037                    }
     1038                  else
     1039                    yyarg[yycount++] = yytname_[yyx];
     1040                }
     1041          }
     1042      }
     1043
     1044    char const* yyformat = 0;
     1045    switch (yycount)
     1046      {
     1047#define YYCASE_(N, S)                         \
     1048        case N:                               \
     1049          yyformat = S;                       \
     1050        break
     1051        YYCASE_(0, YY_("syntax error"));
     1052        YYCASE_(1, YY_("syntax error, unexpected %s"));
     1053        YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
     1054        YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
     1055        YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
     1056        YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
     1057#undef YYCASE_
     1058      }
     1059
     1060    // Argument number.
     1061    size_t yyi = 0;
     1062    for (char const* yyp = yyformat; *yyp; ++yyp)
     1063      if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
     1064        {
     1065          yyres += yytnamerr_ (yyarg[yyi++]);
     1066          ++yyp;
     1067        }
     1068      else
     1069        yyres += *yyp;
     1070    return yyres;
    9721071  }
    9731072
     
    9911090  };
    9921091
    993   /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
    994      doesn't specify something else to do.  Zero means the default is an
    995      error.  */
     1092  /* YYDEFACT[S] -- default reduction number in state S.  Performed when
     1093     YYTABLE doesn't specify something else to do.  Zero means the
     1094     default is an error.  */
    9961095  const unsigned char
    9971096  MeshParser::yydefact_[] =
     
    10291128  /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
    10301129     positive, shift that token.  If negative, reduce the rule which
    1031      number is the opposite.  If zero, do what YYDEFACT says.  */
     1130     number is the opposite.  If YYTABLE_NINF_, syntax error.  */
    10321131  const signed char MeshParser::yytable_ninf_ = -1;
    10331132  const unsigned char
     
    12801379} // orbital
    12811380
    1282 /* Line 1053 of lalr1.cc  */
    1283 #line 1284 "generated/mesh-parser.cpp"
    1284 
    1285 
    1286 /* Line 1055 of lalr1.cc  */
     1381/* Line 1136 of lalr1.cc  */
     1382#line 1383 "generated/mesh-parser.cpp"
     1383
     1384
     1385/* Line 1138 of lalr1.cc  */
    12871386#line 179 "mesh-parser.y"
    12881387
  • trunk/orbital/generated/mesh-parser.h

    r1434 r1437  
    1 /* A Bison parser, made by GNU Bison 2.4.2.  */
     1/* A Bison parser, made by GNU Bison 2.5.  */
    22
    33/* Skeleton interface 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
     
    4141#include <iostream>
    4242#include "stack.hh"
    43 
    44 
    45 namespace orbital {
    46 
    47 /* Line 34 of lalr1.cc  */
    48 #line 49 "generated/mesh-parser.h"
    49   class position;
    50   class location;
    51 
    52 } // orbital
    53 
    54 /* Line 34 of lalr1.cc  */
    55 #line 56 "generated/mesh-parser.h"
    56 
    5743#include "location.hh"
    5844
     
    7561#endif
    7662
    77 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
    78    If N is 0, then set CURRENT to the empty location which ends
    79    the previous symbol: RHS[0] (always defined).  */
    80 
    81 #ifndef YYLLOC_DEFAULT
    82 # define YYLLOC_DEFAULT(Current, Rhs, N)                \
    83 do {                                                    \
    84   if (N)                                                \
    85     {                                                   \
    86       (Current).begin = (Rhs)[1].begin;                 \
    87       (Current).end   = (Rhs)[N].end;                   \
    88     }                                                   \
    89   else                                                  \
    90     {                                                   \
    91       (Current).begin = (Current).end = (Rhs)[0].end;   \
    92     }                                                   \
    93 } while (false)
    94 #endif
    95 
    9663
    9764namespace orbital {
    9865
    99 /* Line 34 of lalr1.cc  */
    100 #line 101 "generated/mesh-parser.h"
     66/* Line 35 of lalr1.cc  */
     67#line 68 "generated/mesh-parser.h"
    10168
    10269  /// A Bison parser.
     
    10976    {
    11077
    111 /* Line 34 of lalr1.cc  */
     78/* Line 35 of lalr1.cc  */
    11279#line 35 "mesh-parser.y"
    11380
     
    11986
    12087
    121 /* Line 34 of lalr1.cc  */
    122 #line 123 "generated/mesh-parser.h"
     88/* Line 35 of lalr1.cc  */
     89#line 90 "generated/mesh-parser.h"
    12390    };
    12491#else
     
    240207    location_stack_type yylocation_stack_;
    241208
     209    /// Whether the given \c yypact_ value indicates a defaulted state.
     210    /// \param yyvalue   the value to check
     211    static bool yy_pact_value_is_default_ (int yyvalue);
     212
     213    /// Whether the given \c yytable_ value indicates a syntax error.
     214    /// \param yyvalue   the value to check
     215    static bool yy_table_value_is_error_ (int yyvalue);
     216
    242217    /// Internal symbol numbers.
    243218    typedef unsigned char token_number_type;
     
    247222    static const signed char yypact_ninf_;
    248223
    249     /// For a state, default rule to reduce.
     224    /// For a state, default reduction number.
    250225    /// Unless\a  yytable_ specifies something else to do.
    251226    /// Zero means the default is an error.
     
    278253#endif
    279254
    280 #if YYERROR_VERBOSE
    281255    /// Convert the symbol name \a n to a form suitable for a diagnostic.
    282     virtual std::string yytnamerr_ (const char *n);
    283 #endif
     256    static std::string yytnamerr_ (const char *n);
    284257
    285258#if YYDEBUG
     
    339312} // orbital
    340313
    341 /* Line 34 of lalr1.cc  */
    342 #line 343 "generated/mesh-parser.h"
     314/* Line 35 of lalr1.cc  */
     315#line 316 "generated/mesh-parser.h"
    343316
    344317
  • trunk/orbital/generated/position.hh

    r1434 r1437  
    1 /* A Bison parser, made by GNU Bison 2.4.2.  */
     1/* A Bison parser, made by GNU Bison 2.5.  */
    22
    33/* Positions for Bison parsers in C++
    44   
    5       Copyright (C) 2002-2007, 2009-2010 Free Software Foundation, Inc.
     5      Copyright (C) 2002-2007, 2009-2011 Free Software Foundation, Inc.
    66   
    77   This program is free software: you can redistribute it and/or modify
  • trunk/orbital/generated/stack.hh

    r1434 r1437  
    1 /* A Bison parser, made by GNU Bison 2.4.2.  */
     1/* A Bison parser, made by GNU Bison 2.5.  */
    22
    33/* Stack handling for Bison 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
     
    3939namespace orbital {
    4040
    41 /* Line 1066 of lalr1.cc  */
     41/* Line 1149 of lalr1.cc  */
    4242#line 43 "generated/stack.hh"
    4343  template <class T, class S = std::deque<T> >
     
    129129} // orbital
    130130
    131 /* Line 1152 of lalr1.cc  */
     131/* Line 1235 of lalr1.cc  */
    132132#line 133 "generated/stack.hh"
    133133
Note: See TracChangeset for help on using the changeset viewer.