smf/smfservermodule/util/qjson/src/json_parser.cc
changeset 7 be09cf1f39dd
equal deleted inserted replaced
6:c39a6cfd1fb9 7:be09cf1f39dd
       
     1 /* A Bison parser, made by GNU Bison 2.3.  */
       
     2 
       
     3 /* Skeleton implementation for Bison LALR(1) parsers in C++
       
     4 
       
     5    Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
       
     6 
       
     7    This program is free software; you can redistribute it and/or modify
       
     8    it under the terms of the GNU General Public License as published by
       
     9    the Free Software Foundation; either version 2, or (at your option)
       
    10    any later version.
       
    11 
       
    12    This program is distributed in the hope that it will be useful,
       
    13    but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    15    GNU General Public License for more details.
       
    16 
       
    17    You should have received a copy of the GNU General Public License
       
    18    along with this program; if not, write to the Free Software
       
    19    Foundation, Inc., 51 Franklin Street, Fifth Floor,
       
    20    Boston, MA 02110-1301, USA.  */
       
    21 
       
    22 /* As a special exception, you may create a larger work that contains
       
    23    part or all of the Bison parser skeleton and distribute that work
       
    24    under terms of your choice, so long as that work isn't itself a
       
    25    parser generator using the skeleton or a modified version thereof
       
    26    as a parser skeleton.  Alternatively, if you modify or redistribute
       
    27    the parser skeleton itself, you may (at your option) remove this
       
    28    special exception, which will cause the skeleton and the resulting
       
    29    Bison output files to be licensed under the GNU General Public
       
    30    License without this special exception.
       
    31 
       
    32    This special exception was added by the Free Software Foundation in
       
    33    version 2.2 of Bison.  */
       
    34 
       
    35 
       
    36 #include "json_parser.hh"
       
    37 
       
    38 /* User implementation prologue.  */
       
    39 
       
    40 
       
    41 /* Line 317 of lalr1.cc.  */
       
    42 #line 43 "json_parser.cc"
       
    43 
       
    44 #ifndef YY_
       
    45 # if defined YYENABLE_NLS && YYENABLE_NLS
       
    46 #  if ENABLE_NLS
       
    47 #   include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */
       
    48 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
       
    49 #  endif
       
    50 # endif
       
    51 # ifndef YY_
       
    52 #  define YY_(msgid) msgid
       
    53 # endif
       
    54 #endif
       
    55 
       
    56 /* Suppress unused-variable warnings by "using" E.  */
       
    57 #define YYUSE(e) ((void) (e))
       
    58 
       
    59 /* A pseudo ostream that takes yydebug_ into account.  */
       
    60 # define YYCDEBUG							\
       
    61   for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false)	\
       
    62     (*yycdebug_)
       
    63 
       
    64 /* Enable debugging if requested.  */
       
    65 #if YYDEBUG
       
    66 
       
    67 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)	\
       
    68 do {							\
       
    69   if (yydebug_)						\
       
    70     {							\
       
    71       *yycdebug_ << Title << ' ';			\
       
    72       yy_symbol_print_ ((Type), (Value), (Location));	\
       
    73       *yycdebug_ << std::endl;				\
       
    74     }							\
       
    75 } while (false)
       
    76 
       
    77 # define YY_REDUCE_PRINT(Rule)		\
       
    78 do {					\
       
    79   if (yydebug_)				\
       
    80     yy_reduce_print_ (Rule);		\
       
    81 } while (false)
       
    82 
       
    83 # define YY_STACK_PRINT()		\
       
    84 do {					\
       
    85   if (yydebug_)				\
       
    86     yystack_print_ ();			\
       
    87 } while (false)
       
    88 
       
    89 #else /* !YYDEBUG */
       
    90 
       
    91 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
       
    92 # define YY_REDUCE_PRINT(Rule)
       
    93 # define YY_STACK_PRINT()
       
    94 
       
    95 #endif /* !YYDEBUG */
       
    96 
       
    97 #define YYACCEPT	goto yyacceptlab
       
    98 #define YYABORT		goto yyabortlab
       
    99 #define YYERROR		goto yyerrorlab
       
   100 
       
   101 namespace yy
       
   102 {
       
   103 #if YYERROR_VERBOSE
       
   104 
       
   105   /* Return YYSTR after stripping away unnecessary quotes and
       
   106      backslashes, so that it's suitable for yyerror.  The heuristic is
       
   107      that double-quoting is unnecessary unless the string contains an
       
   108      apostrophe, a comma, or backslash (other than backslash-backslash).
       
   109      YYSTR is taken from yytname.  */
       
   110   std::string
       
   111   json_parser::yytnamerr_ (const char *yystr)
       
   112   {
       
   113     if (*yystr == '"')
       
   114       {
       
   115         std::string yyr = "";
       
   116         char const *yyp = yystr;
       
   117 
       
   118         for (;;)
       
   119           switch (*++yyp)
       
   120             {
       
   121             case '\'':
       
   122             case ',':
       
   123               goto do_not_strip_quotes;
       
   124 
       
   125             case '\\':
       
   126               if (*++yyp != '\\')
       
   127                 goto do_not_strip_quotes;
       
   128               /* Fall through.  */
       
   129             default:
       
   130               yyr += *yyp;
       
   131               break;
       
   132 
       
   133             case '"':
       
   134               return yyr;
       
   135             }
       
   136       do_not_strip_quotes: ;
       
   137       }
       
   138 
       
   139     return yystr;
       
   140   }
       
   141 
       
   142 #endif
       
   143 
       
   144   /// Build a parser object.
       
   145   json_parser::json_parser (QJson::ParserPrivate* driver_yyarg)
       
   146     : yydebug_ (false),
       
   147       yycdebug_ (&std::cerr),
       
   148       driver (driver_yyarg)
       
   149   {
       
   150   }
       
   151 
       
   152   json_parser::~json_parser ()
       
   153   {
       
   154   }
       
   155 
       
   156 #if YYDEBUG
       
   157   /*--------------------------------.
       
   158   | Print this symbol on YYOUTPUT.  |
       
   159   `--------------------------------*/
       
   160 
       
   161   inline void
       
   162   json_parser::yy_symbol_value_print_ (int yytype,
       
   163 			   const semantic_type* yyvaluep, const location_type* yylocationp)
       
   164   {
       
   165     YYUSE (yylocationp);
       
   166     YYUSE (yyvaluep);
       
   167     switch (yytype)
       
   168       {
       
   169          default:
       
   170 	  break;
       
   171       }
       
   172   }
       
   173 
       
   174 
       
   175   void
       
   176   json_parser::yy_symbol_print_ (int yytype,
       
   177 			   const semantic_type* yyvaluep, const location_type* yylocationp)
       
   178   {
       
   179     *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
       
   180 	       << ' ' << yytname_[yytype] << " ("
       
   181 	       << *yylocationp << ": ";
       
   182     yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
       
   183     *yycdebug_ << ')';
       
   184   }
       
   185 #endif /* ! YYDEBUG */
       
   186 
       
   187   void
       
   188   json_parser::yydestruct_ (const char* yymsg,
       
   189 			   int yytype, semantic_type* yyvaluep, location_type* yylocationp)
       
   190   {
       
   191     YYUSE (yylocationp);
       
   192     YYUSE (yymsg);
       
   193     YYUSE (yyvaluep);
       
   194 
       
   195     YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
       
   196 
       
   197     switch (yytype)
       
   198       {
       
   199   
       
   200 	default:
       
   201 	  break;
       
   202       }
       
   203   }
       
   204 
       
   205   void
       
   206   json_parser::yypop_ (unsigned int n)
       
   207   {
       
   208     yystate_stack_.pop (n);
       
   209     yysemantic_stack_.pop (n);
       
   210     yylocation_stack_.pop (n);
       
   211   }
       
   212 
       
   213   std::ostream&
       
   214   json_parser::debug_stream () const
       
   215   {
       
   216     return *yycdebug_;
       
   217   }
       
   218 
       
   219   void
       
   220   json_parser::set_debug_stream (std::ostream& o)
       
   221   {
       
   222     yycdebug_ = &o;
       
   223   }
       
   224 
       
   225 
       
   226   json_parser::debug_level_type
       
   227   json_parser::debug_level () const
       
   228   {
       
   229     return yydebug_;
       
   230   }
       
   231 
       
   232   void
       
   233   json_parser::set_debug_level (debug_level_type l)
       
   234   {
       
   235     yydebug_ = l;
       
   236   }
       
   237 
       
   238 
       
   239   int
       
   240   json_parser::parse ()
       
   241   {
       
   242     /// Look-ahead and look-ahead in internal form.
       
   243     int yychar = yyempty_;
       
   244     int yytoken = 0;
       
   245 
       
   246     /* State.  */
       
   247     int yyn;
       
   248     int yylen = 0;
       
   249     int yystate = 0;
       
   250 
       
   251     /* Error handling.  */
       
   252     int yynerrs_ = 0;
       
   253     int yyerrstatus_ = 0;
       
   254 
       
   255     /// Semantic value of the look-ahead.
       
   256     semantic_type yylval;
       
   257     /// Location of the look-ahead.
       
   258     location_type yylloc;
       
   259     /// The locations where the error started and ended.
       
   260     location yyerror_range[2];
       
   261 
       
   262     /// $$.
       
   263     semantic_type yyval;
       
   264     /// @$.
       
   265     location_type yyloc;
       
   266 
       
   267     int yyresult;
       
   268 
       
   269     YYCDEBUG << "Starting parse" << std::endl;
       
   270 
       
   271 
       
   272     /* Initialize the stacks.  The initial state will be pushed in
       
   273        yynewstate, since the latter expects the semantical and the
       
   274        location values to have been already stored, initialize these
       
   275        stacks with a primary value.  */
       
   276     yystate_stack_ = state_stack_type (0);
       
   277     yysemantic_stack_ = semantic_stack_type (0);
       
   278     yylocation_stack_ = location_stack_type (0);
       
   279     yysemantic_stack_.push (yylval);
       
   280     yylocation_stack_.push (yylloc);
       
   281 
       
   282     /* New state.  */
       
   283   yynewstate:
       
   284     yystate_stack_.push (yystate);
       
   285     YYCDEBUG << "Entering state " << yystate << std::endl;
       
   286     goto yybackup;
       
   287 
       
   288     /* Backup.  */
       
   289   yybackup:
       
   290 
       
   291     /* Try to take a decision without look-ahead.  */
       
   292     yyn = yypact_[yystate];
       
   293     if (yyn == yypact_ninf_)
       
   294       goto yydefault;
       
   295 
       
   296     /* Read a look-ahead token.  */
       
   297     if (yychar == yyempty_)
       
   298       {
       
   299 	YYCDEBUG << "Reading a token: ";
       
   300 	yychar = yylex (&yylval, &yylloc, driver);
       
   301       }
       
   302 
       
   303 
       
   304     /* Convert token to internal form.  */
       
   305     if (yychar <= yyeof_)
       
   306       {
       
   307 	yychar = yytoken = yyeof_;
       
   308 	YYCDEBUG << "Now at end of input." << std::endl;
       
   309       }
       
   310     else
       
   311       {
       
   312 	yytoken = yytranslate_ (yychar);
       
   313 	YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
       
   314       }
       
   315 
       
   316     /* If the proper action on seeing token YYTOKEN is to reduce or to
       
   317        detect an error, take that action.  */
       
   318     yyn += yytoken;
       
   319     if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
       
   320       goto yydefault;
       
   321 
       
   322     /* Reduce or error.  */
       
   323     yyn = yytable_[yyn];
       
   324     if (yyn <= 0)
       
   325       {
       
   326 	if (yyn == 0 || yyn == yytable_ninf_)
       
   327 	goto yyerrlab;
       
   328 	yyn = -yyn;
       
   329 	goto yyreduce;
       
   330       }
       
   331 
       
   332     /* Accept?  */
       
   333     if (yyn == yyfinal_)
       
   334       goto yyacceptlab;
       
   335 
       
   336     /* Shift the look-ahead token.  */
       
   337     YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
       
   338 
       
   339     /* Discard the token being shifted unless it is eof.  */
       
   340     if (yychar != yyeof_)
       
   341       yychar = yyempty_;
       
   342 
       
   343     yysemantic_stack_.push (yylval);
       
   344     yylocation_stack_.push (yylloc);
       
   345 
       
   346     /* Count tokens shifted since error; after three, turn off error
       
   347        status.  */
       
   348     if (yyerrstatus_)
       
   349       --yyerrstatus_;
       
   350 
       
   351     yystate = yyn;
       
   352     goto yynewstate;
       
   353 
       
   354   /*-----------------------------------------------------------.
       
   355   | yydefault -- do the default action for the current state.  |
       
   356   `-----------------------------------------------------------*/
       
   357   yydefault:
       
   358     yyn = yydefact_[yystate];
       
   359     if (yyn == 0)
       
   360       goto yyerrlab;
       
   361     goto yyreduce;
       
   362 
       
   363   /*-----------------------------.
       
   364   | yyreduce -- Do a reduction.  |
       
   365   `-----------------------------*/
       
   366   yyreduce:
       
   367     yylen = yyr2_[yyn];
       
   368     /* If YYLEN is nonzero, implement the default value of the action:
       
   369        `$$ = $1'.  Otherwise, use the top of the stack.
       
   370 
       
   371        Otherwise, the following line sets YYVAL to garbage.
       
   372        This behavior is undocumented and Bison
       
   373        users should not rely upon it.  */
       
   374     if (yylen)
       
   375       yyval = yysemantic_stack_[yylen - 1];
       
   376     else
       
   377       yyval = yysemantic_stack_[0];
       
   378 
       
   379     {
       
   380       slice<location_type, location_stack_type> slice (yylocation_stack_, yylen);
       
   381       YYLLOC_DEFAULT (yyloc, slice, yylen);
       
   382     }
       
   383     YY_REDUCE_PRINT (yyn);
       
   384     switch (yyn)
       
   385       {
       
   386 	  case 2:
       
   387 #line 80 "json_parser.yy"
       
   388     {
       
   389               driver->m_result = (yysemantic_stack_[(1) - (1)]);
       
   390               qjsonDebug() << "json_parser - parsing finished";
       
   391             ;}
       
   392     break;
       
   393 
       
   394   case 3:
       
   395 #line 85 "json_parser.yy"
       
   396     {(yyval) = (yysemantic_stack_[(1) - (1)]); ;}
       
   397     break;
       
   398 
       
   399   case 4:
       
   400 #line 86 "json_parser.yy"
       
   401     {(yyval) = (yysemantic_stack_[(1) - (1)]); ;}
       
   402     break;
       
   403 
       
   404   case 5:
       
   405 #line 88 "json_parser.yy"
       
   406     {
       
   407             qCritical()<< "json_parser - syntax error found, "
       
   408                     << "forcing abort";
       
   409             YYABORT;
       
   410           ;}
       
   411     break;
       
   412 
       
   413   case 7:
       
   414 #line 95 "json_parser.yy"
       
   415     { (yyval) = (yysemantic_stack_[(3) - (2)]); ;}
       
   416     break;
       
   417 
       
   418   case 8:
       
   419 #line 97 "json_parser.yy"
       
   420     { (yyval) = QVariant (QVariantMap()); ;}
       
   421     break;
       
   422 
       
   423   case 9:
       
   424 #line 98 "json_parser.yy"
       
   425     {
       
   426             QVariantMap members = (yysemantic_stack_[(2) - (2)]).toMap();
       
   427             (yysemantic_stack_[(2) - (2)]) = QVariant(); // Allow reuse of map
       
   428             (yyval) = QVariant(members.unite ((yysemantic_stack_[(2) - (1)]).toMap()));
       
   429           ;}
       
   430     break;
       
   431 
       
   432   case 10:
       
   433 #line 104 "json_parser.yy"
       
   434     { (yyval) = QVariant (QVariantMap()); ;}
       
   435     break;
       
   436 
       
   437   case 11:
       
   438 #line 105 "json_parser.yy"
       
   439     {
       
   440           QVariantMap members = (yysemantic_stack_[(3) - (3)]).toMap();
       
   441           (yysemantic_stack_[(3) - (3)]) = QVariant(); // Allow reuse of map
       
   442           (yyval) = QVariant(members.unite ((yysemantic_stack_[(3) - (2)]).toMap()));
       
   443           ;}
       
   444     break;
       
   445 
       
   446   case 12:
       
   447 #line 111 "json_parser.yy"
       
   448     {
       
   449             QVariantMap pair;
       
   450             pair.insert ((yysemantic_stack_[(3) - (1)]).toString(), QVariant((yysemantic_stack_[(3) - (3)])));
       
   451             (yyval) = QVariant (pair);
       
   452           ;}
       
   453     break;
       
   454 
       
   455   case 13:
       
   456 #line 117 "json_parser.yy"
       
   457     { (yyval) = (yysemantic_stack_[(3) - (2)]); ;}
       
   458     break;
       
   459 
       
   460   case 14:
       
   461 #line 119 "json_parser.yy"
       
   462     { (yyval) = QVariant (QVariantList()); ;}
       
   463     break;
       
   464 
       
   465   case 15:
       
   466 #line 120 "json_parser.yy"
       
   467     {
       
   468           QVariantList members = (yysemantic_stack_[(2) - (2)]).toList();
       
   469           (yysemantic_stack_[(2) - (2)]) = QVariant(); // Allow reuse of list
       
   470           members.prepend ((yysemantic_stack_[(2) - (1)]));
       
   471           (yyval) = QVariant(members);
       
   472         ;}
       
   473     break;
       
   474 
       
   475   case 16:
       
   476 #line 127 "json_parser.yy"
       
   477     { (yyval) = QVariant (QVariantList()); ;}
       
   478     break;
       
   479 
       
   480   case 17:
       
   481 #line 128 "json_parser.yy"
       
   482     {
       
   483             QVariantList members = (yysemantic_stack_[(3) - (3)]).toList();
       
   484             (yysemantic_stack_[(3) - (3)]) = QVariant(); // Allow reuse of list
       
   485             members.prepend ((yysemantic_stack_[(3) - (2)]));
       
   486             (yyval) = QVariant(members);
       
   487           ;}
       
   488     break;
       
   489 
       
   490   case 18:
       
   491 #line 135 "json_parser.yy"
       
   492     { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
       
   493     break;
       
   494 
       
   495   case 19:
       
   496 #line 136 "json_parser.yy"
       
   497     { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
       
   498     break;
       
   499 
       
   500   case 20:
       
   501 #line 137 "json_parser.yy"
       
   502     { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
       
   503     break;
       
   504 
       
   505   case 21:
       
   506 #line 138 "json_parser.yy"
       
   507     { (yyval) = (yysemantic_stack_[(1) - (1)]); ;}
       
   508     break;
       
   509 
       
   510   case 22:
       
   511 #line 139 "json_parser.yy"
       
   512     { (yyval) = QVariant (true); ;}
       
   513     break;
       
   514 
       
   515   case 23:
       
   516 #line 140 "json_parser.yy"
       
   517     { (yyval) = QVariant (false); ;}
       
   518     break;
       
   519 
       
   520   case 24:
       
   521 #line 141 "json_parser.yy"
       
   522     {
       
   523           QVariant null_variant;
       
   524           (yyval) = null_variant;
       
   525         ;}
       
   526     break;
       
   527 
       
   528   case 25:
       
   529 #line 146 "json_parser.yy"
       
   530     {
       
   531             if ((yysemantic_stack_[(1) - (1)]).toByteArray().startsWith('-')) {
       
   532               (yyval) = QVariant (QVariant::LongLong);
       
   533               (yyval).setValue((yysemantic_stack_[(1) - (1)]).toLongLong());
       
   534             }
       
   535             else {
       
   536               (yyval) = QVariant (QVariant::ULongLong);
       
   537               (yyval).setValue((yysemantic_stack_[(1) - (1)]).toULongLong());
       
   538             }
       
   539           ;}
       
   540     break;
       
   541 
       
   542   case 26:
       
   543 #line 156 "json_parser.yy"
       
   544     {
       
   545             const QByteArray value = (yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray();
       
   546             (yyval) = QVariant(QVariant::Double);
       
   547             (yyval).setValue(value.toDouble());
       
   548           ;}
       
   549     break;
       
   550 
       
   551   case 27:
       
   552 #line 161 "json_parser.yy"
       
   553     { (yyval) = QVariant ((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;}
       
   554     break;
       
   555 
       
   556   case 28:
       
   557 #line 162 "json_parser.yy"
       
   558     {
       
   559             const QByteArray value = (yysemantic_stack_[(3) - (1)]).toByteArray() + (yysemantic_stack_[(3) - (2)]).toByteArray() + (yysemantic_stack_[(3) - (3)]).toByteArray();
       
   560             (yyval) = QVariant (value);
       
   561           ;}
       
   562     break;
       
   563 
       
   564   case 29:
       
   565 #line 167 "json_parser.yy"
       
   566     { (yyval) = QVariant ((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;}
       
   567     break;
       
   568 
       
   569   case 30:
       
   570 #line 168 "json_parser.yy"
       
   571     { (yyval) = QVariant (QByteArray("-") + (yysemantic_stack_[(3) - (2)]).toByteArray() + (yysemantic_stack_[(3) - (3)]).toByteArray()); ;}
       
   572     break;
       
   573 
       
   574   case 31:
       
   575 #line 170 "json_parser.yy"
       
   576     { (yyval) = QVariant (QByteArray("")); ;}
       
   577     break;
       
   578 
       
   579   case 32:
       
   580 #line 171 "json_parser.yy"
       
   581     {
       
   582           (yyval) = QVariant((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray());
       
   583         ;}
       
   584     break;
       
   585 
       
   586   case 33:
       
   587 #line 175 "json_parser.yy"
       
   588     {
       
   589           (yyval) = QVariant(QByteArray(".") + (yysemantic_stack_[(2) - (2)]).toByteArray());
       
   590         ;}
       
   591     break;
       
   592 
       
   593   case 34:
       
   594 #line 179 "json_parser.yy"
       
   595     { (yyval) = QVariant((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;}
       
   596     break;
       
   597 
       
   598   case 35:
       
   599 #line 181 "json_parser.yy"
       
   600     { (yyval) = (yysemantic_stack_[(3) - (2)]); ;}
       
   601     break;
       
   602 
       
   603   case 36:
       
   604 #line 183 "json_parser.yy"
       
   605     { (yyval) = QVariant (QString(QLatin1String(""))); ;}
       
   606     break;
       
   607 
       
   608   case 37:
       
   609 #line 184 "json_parser.yy"
       
   610     {
       
   611                 (yyval) = (yysemantic_stack_[(1) - (1)]);
       
   612               ;}
       
   613     break;
       
   614 
       
   615 
       
   616     /* Line 675 of lalr1.cc.  */
       
   617 #line 618 "json_parser.cc"
       
   618 	default: break;
       
   619       }
       
   620     YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc);
       
   621 
       
   622     yypop_ (yylen);
       
   623     yylen = 0;
       
   624     YY_STACK_PRINT ();
       
   625 
       
   626     yysemantic_stack_.push (yyval);
       
   627     yylocation_stack_.push (yyloc);
       
   628 
       
   629     /* Shift the result of the reduction.  */
       
   630     yyn = yyr1_[yyn];
       
   631     yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
       
   632     if (0 <= yystate && yystate <= yylast_
       
   633 	&& yycheck_[yystate] == yystate_stack_[0])
       
   634       yystate = yytable_[yystate];
       
   635     else
       
   636       yystate = yydefgoto_[yyn - yyntokens_];
       
   637     goto yynewstate;
       
   638 
       
   639   /*------------------------------------.
       
   640   | yyerrlab -- here on detecting error |
       
   641   `------------------------------------*/
       
   642   yyerrlab:
       
   643     /* If not already recovering from an error, report this error.  */
       
   644     if (!yyerrstatus_)
       
   645       {
       
   646 	++yynerrs_;
       
   647 	error (yylloc, yysyntax_error_ (yystate, yytoken));
       
   648       }
       
   649 
       
   650     yyerror_range[0] = yylloc;
       
   651     if (yyerrstatus_ == 3)
       
   652       {
       
   653 	/* If just tried and failed to reuse look-ahead token after an
       
   654 	 error, discard it.  */
       
   655 
       
   656 	if (yychar <= yyeof_)
       
   657 	  {
       
   658 	  /* Return failure if at end of input.  */
       
   659 	  if (yychar == yyeof_)
       
   660 	    YYABORT;
       
   661 	  }
       
   662 	else
       
   663 	  {
       
   664 	    yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc);
       
   665 	    yychar = yyempty_;
       
   666 	  }
       
   667       }
       
   668 
       
   669     /* Else will try to reuse look-ahead token after shifting the error
       
   670        token.  */
       
   671     goto yyerrlab1;
       
   672 
       
   673 
       
   674   /*---------------------------------------------------.
       
   675   | yyerrorlab -- error raised explicitly by YYERROR.  |
       
   676   `---------------------------------------------------*/
       
   677   yyerrorlab:
       
   678 
       
   679     /* Pacify compilers like GCC when the user code never invokes
       
   680        YYERROR and the label yyerrorlab therefore never appears in user
       
   681        code.  */
       
   682     if (false)
       
   683       goto yyerrorlab;
       
   684 
       
   685     yyerror_range[0] = yylocation_stack_[yylen - 1];
       
   686     /* Do not reclaim the symbols of the rule which action triggered
       
   687        this YYERROR.  */
       
   688     yypop_ (yylen);
       
   689     yylen = 0;
       
   690     yystate = yystate_stack_[0];
       
   691     goto yyerrlab1;
       
   692 
       
   693   /*-------------------------------------------------------------.
       
   694   | yyerrlab1 -- common code for both syntax error and YYERROR.  |
       
   695   `-------------------------------------------------------------*/
       
   696   yyerrlab1:
       
   697     yyerrstatus_ = 3;	/* Each real token shifted decrements this.  */
       
   698 
       
   699     for (;;)
       
   700       {
       
   701 	yyn = yypact_[yystate];
       
   702 	if (yyn != yypact_ninf_)
       
   703 	{
       
   704 	  yyn += yyterror_;
       
   705 	  if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
       
   706 	    {
       
   707 	      yyn = yytable_[yyn];
       
   708 	      if (0 < yyn)
       
   709 		break;
       
   710 	    }
       
   711 	}
       
   712 
       
   713 	/* Pop the current state because it cannot handle the error token.  */
       
   714 	if (yystate_stack_.height () == 1)
       
   715 	YYABORT;
       
   716 
       
   717 	yyerror_range[0] = yylocation_stack_[0];
       
   718 	yydestruct_ ("Error: popping",
       
   719 		     yystos_[yystate],
       
   720 		     &yysemantic_stack_[0], &yylocation_stack_[0]);
       
   721 	yypop_ ();
       
   722 	yystate = yystate_stack_[0];
       
   723 	YY_STACK_PRINT ();
       
   724       }
       
   725 
       
   726     if (yyn == yyfinal_)
       
   727       goto yyacceptlab;
       
   728 
       
   729     yyerror_range[1] = yylloc;
       
   730     // Using YYLLOC is tempting, but would change the location of
       
   731     // the look-ahead.  YYLOC is available though.
       
   732     YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
       
   733     yysemantic_stack_.push (yylval);
       
   734     yylocation_stack_.push (yyloc);
       
   735 
       
   736     /* Shift the error token.  */
       
   737     YY_SYMBOL_PRINT ("Shifting", yystos_[yyn],
       
   738 		   &yysemantic_stack_[0], &yylocation_stack_[0]);
       
   739 
       
   740     yystate = yyn;
       
   741     goto yynewstate;
       
   742 
       
   743     /* Accept.  */
       
   744   yyacceptlab:
       
   745     yyresult = 0;
       
   746     goto yyreturn;
       
   747 
       
   748     /* Abort.  */
       
   749   yyabortlab:
       
   750     yyresult = 1;
       
   751     goto yyreturn;
       
   752 
       
   753   yyreturn:
       
   754     if (yychar != yyeof_ && yychar != yyempty_)
       
   755       yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc);
       
   756 
       
   757     /* Do not reclaim the symbols of the rule which action triggered
       
   758        this YYABORT or YYACCEPT.  */
       
   759     yypop_ (yylen);
       
   760     while (yystate_stack_.height () != 1)
       
   761       {
       
   762 	yydestruct_ ("Cleanup: popping",
       
   763 		   yystos_[yystate_stack_[0]],
       
   764 		   &yysemantic_stack_[0],
       
   765 		   &yylocation_stack_[0]);
       
   766 	yypop_ ();
       
   767       }
       
   768 
       
   769     return yyresult;
       
   770   }
       
   771 
       
   772   // Generate an error message.
       
   773   std::string
       
   774   json_parser::yysyntax_error_ (int yystate, int tok)
       
   775   {
       
   776     std::string res;
       
   777     YYUSE (yystate);
       
   778 #if YYERROR_VERBOSE
       
   779     int yyn = yypact_[yystate];
       
   780     if (yypact_ninf_ < yyn && yyn <= yylast_)
       
   781       {
       
   782 	/* Start YYX at -YYN if negative to avoid negative indexes in
       
   783 	   YYCHECK.  */
       
   784 	int yyxbegin = yyn < 0 ? -yyn : 0;
       
   785 
       
   786 	/* Stay within bounds of both yycheck and yytname.  */
       
   787 	int yychecklim = yylast_ - yyn + 1;
       
   788 	int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
       
   789 	int count = 0;
       
   790 	for (int x = yyxbegin; x < yyxend; ++x)
       
   791 	  if (yycheck_[x + yyn] == x && x != yyterror_)
       
   792 	    ++count;
       
   793 
       
   794 	// FIXME: This method of building the message is not compatible
       
   795 	// with internationalization.  It should work like yacc.c does it.
       
   796 	// That is, first build a string that looks like this:
       
   797 	// "syntax error, unexpected %s or %s or %s"
       
   798 	// Then, invoke YY_ on this string.
       
   799 	// Finally, use the string as a format to output
       
   800 	// yytname_[tok], etc.
       
   801 	// Until this gets fixed, this message appears in English only.
       
   802 	res = "syntax error, unexpected ";
       
   803 	res += yytnamerr_ (yytname_[tok]);
       
   804 	if (count < 5)
       
   805 	  {
       
   806 	    count = 0;
       
   807 	    for (int x = yyxbegin; x < yyxend; ++x)
       
   808 	      if (yycheck_[x + yyn] == x && x != yyterror_)
       
   809 		{
       
   810 		  res += (!count++) ? ", expecting " : " or ";
       
   811 		  res += yytnamerr_ (yytname_[x]);
       
   812 		}
       
   813 	  }
       
   814       }
       
   815     else
       
   816 #endif
       
   817       res = YY_("syntax error");
       
   818     return res;
       
   819   }
       
   820 
       
   821 
       
   822   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
       
   823      STATE-NUM.  */
       
   824   const signed char json_parser::yypact_ninf_ = -18;
       
   825   const signed char
       
   826   json_parser::yypact_[] =
       
   827   {
       
   828          5,   -18,   -18,     1,    -2,    19,   -18,   -18,   -18,     2,
       
   829       20,    17,    21,    16,    18,   -18,   -18,   -18,   -18,   -18,
       
   830       24,    23,   -18,    -8,   -18,   -18,   -18,    15,   -18,     1,
       
   831      -18,    -2,    18,    18,   -18,   -18,    -2,   -18,    18,    18,
       
   832       22,   -18,   -18,    17,   -18,   -18,   -18,    23,   -18,   -18,
       
   833      -18,   -18,   -18
       
   834   };
       
   835 
       
   836   /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
       
   837      doesn't specify something else to do.  Zero means the default is an
       
   838      error.  */
       
   839   const unsigned char
       
   840   json_parser::yydefact_[] =
       
   841   {
       
   842          0,     6,     5,     8,    14,     0,     2,     3,     4,    36,
       
   843        0,    10,     0,     0,    31,    22,    23,    24,    20,    21,
       
   844        0,    16,    19,    25,    18,     1,    37,     0,     7,     0,
       
   845        9,     0,    31,    31,    29,    13,     0,    15,    31,    31,
       
   846       26,    27,    35,    10,    12,    30,    32,    16,    33,    34,
       
   847       28,    11,    17
       
   848   };
       
   849 
       
   850   /* YYPGOTO[NTERM-NUM].  */
       
   851   const signed char
       
   852   json_parser::yypgoto_[] =
       
   853   {
       
   854        -18,   -18,   -18,    33,   -18,    -7,     6,    37,   -18,    -9,
       
   855      -13,   -18,   -18,   -17,   -18,    -1,    -3,   -18
       
   856   };
       
   857 
       
   858   /* YYDEFGOTO[NTERM-NUM].  */
       
   859   const signed char
       
   860   json_parser::yydefgoto_[] =
       
   861   {
       
   862         -1,     5,     6,    18,    10,    30,    11,    19,    20,    37,
       
   863       21,    22,    23,    34,    40,    41,    24,    27
       
   864   };
       
   865 
       
   866   /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
       
   867      positive, shift that token.  If negative, reduce the rule which
       
   868      number is the opposite.  If zero, do what YYDEFACT says.  */
       
   869   const signed char json_parser::yytable_ninf_ = -1;
       
   870   const unsigned char
       
   871   json_parser::yytable_[] =
       
   872   {
       
   873         12,     3,    38,     4,    39,     1,     2,    13,     3,    14,
       
   874        4,    15,    16,    17,     9,    45,    46,     9,    44,    25,
       
   875       26,    48,    49,    47,    28,    29,    12,    32,    31,    33,
       
   876       35,    36,    42,     7,    39,    43,    51,     8,    52,    50
       
   877   };
       
   878 
       
   879   /* YYCHECK.  */
       
   880   const unsigned char
       
   881   json_parser::yycheck_[] =
       
   882   {
       
   883          3,     3,    10,     5,    12,     0,     1,     9,     3,    11,
       
   884        5,    13,    14,    15,    16,    32,    33,    16,    31,     0,
       
   885       18,    38,    39,    36,     4,     8,    29,    11,     7,    11,
       
   886        6,     8,    17,     0,    12,    29,    43,     0,    47,    40
       
   887   };
       
   888 
       
   889   /* STOS_[STATE-NUM] -- The (internal number of the) accessing
       
   890      symbol of state STATE-NUM.  */
       
   891   const unsigned char
       
   892   json_parser::yystos_[] =
       
   893   {
       
   894          0,     0,     1,     3,     5,    20,    21,    22,    26,    16,
       
   895       23,    25,    35,     9,    11,    13,    14,    15,    22,    26,
       
   896       27,    29,    30,    31,    35,     0,    18,    36,     4,     8,
       
   897       24,     7,    11,    11,    32,     6,     8,    28,    10,    12,
       
   898       33,    34,    17,    25,    29,    32,    32,    29,    32,    32,
       
   899       34,    24,    28
       
   900   };
       
   901 
       
   902 #if YYDEBUG
       
   903   /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding
       
   904      to YYLEX-NUM.  */
       
   905   const unsigned short int
       
   906   json_parser::yytoken_number_[] =
       
   907   {
       
   908          0,   256,   257,     1,     2,     3,     4,     5,     6,     7,
       
   909        8,     9,    10,    11,    12,    13,    14,    15,    16
       
   910   };
       
   911 #endif
       
   912 
       
   913   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
       
   914   const unsigned char
       
   915   json_parser::yyr1_[] =
       
   916   {
       
   917          0,    19,    20,    21,    21,    21,    21,    22,    23,    23,
       
   918       24,    24,    25,    26,    27,    27,    28,    28,    29,    29,
       
   919       29,    29,    29,    29,    29,    30,    30,    30,    30,    31,
       
   920       31,    32,    32,    33,    34,    35,    36,    36
       
   921   };
       
   922 
       
   923   /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
       
   924   const unsigned char
       
   925   json_parser::yyr2_[] =
       
   926   {
       
   927          0,     2,     1,     1,     1,     1,     1,     3,     0,     2,
       
   928        0,     3,     3,     3,     0,     2,     0,     3,     1,     1,
       
   929        1,     1,     1,     1,     1,     1,     2,     2,     3,     2,
       
   930        3,     0,     2,     2,     2,     3,     0,     1
       
   931   };
       
   932 
       
   933 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
       
   934   /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
       
   935      First, the terminals, then, starting at \a yyntokens_, nonterminals.  */
       
   936   const char*
       
   937   const json_parser::yytname_[] =
       
   938   {
       
   939     "\"end of file\"", "error", "$undefined", "\"{\"", "\"}\"", "\"[\"",
       
   940   "\"]\"", "\":\"", "\",\"", "\"-\"", "\".\"", "\"digit\"",
       
   941   "\"exponential\"", "\"true\"", "\"false\"", "\"null\"",
       
   942   "\"open quotation mark\"", "\"close quotation mark\"", "\"string\"",
       
   943   "$accept", "start", "data", "object", "members", "r_members", "pair",
       
   944   "array", "values", "r_values", "value", "number", "int", "digits",
       
   945   "fract", "exp", "string", "string_arg", 0
       
   946   };
       
   947 #endif
       
   948 
       
   949 #if YYDEBUG
       
   950   /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
       
   951   const json_parser::rhs_number_type
       
   952   json_parser::yyrhs_[] =
       
   953   {
       
   954         20,     0,    -1,    21,    -1,    22,    -1,    26,    -1,     1,
       
   955       -1,     0,    -1,     3,    23,     4,    -1,    -1,    25,    24,
       
   956       -1,    -1,     8,    25,    24,    -1,    35,     7,    29,    -1,
       
   957        5,    27,     6,    -1,    -1,    29,    28,    -1,    -1,     8,
       
   958       29,    28,    -1,    35,    -1,    30,    -1,    22,    -1,    26,
       
   959       -1,    13,    -1,    14,    -1,    15,    -1,    31,    -1,    31,
       
   960       33,    -1,    31,    34,    -1,    31,    33,    34,    -1,    11,
       
   961       32,    -1,     9,    11,    32,    -1,    -1,    11,    32,    -1,
       
   962       10,    32,    -1,    12,    32,    -1,    16,    36,    17,    -1,
       
   963       -1,    18,    -1
       
   964   };
       
   965 
       
   966   /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
       
   967      YYRHS.  */
       
   968   const unsigned char
       
   969   json_parser::yyprhs_[] =
       
   970   {
       
   971          0,     0,     3,     5,     7,     9,    11,    13,    17,    18,
       
   972       21,    22,    26,    30,    34,    35,    38,    39,    43,    45,
       
   973       47,    49,    51,    53,    55,    57,    59,    62,    65,    69,
       
   974       72,    76,    77,    80,    83,    86,    90,    91
       
   975   };
       
   976 
       
   977   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
       
   978   const unsigned char
       
   979   json_parser::yyrline_[] =
       
   980   {
       
   981          0,    80,    80,    85,    86,    87,    93,    95,    97,    98,
       
   982      104,   105,   111,   117,   119,   120,   127,   128,   135,   136,
       
   983      137,   138,   139,   140,   141,   146,   156,   161,   162,   167,
       
   984      168,   170,   171,   175,   179,   181,   183,   184
       
   985   };
       
   986 
       
   987   // Print the state stack on the debug stream.
       
   988   void
       
   989   json_parser::yystack_print_ ()
       
   990   {
       
   991     *yycdebug_ << "Stack now";
       
   992     for (state_stack_type::const_iterator i = yystate_stack_.begin ();
       
   993 	 i != yystate_stack_.end (); ++i)
       
   994       *yycdebug_ << ' ' << *i;
       
   995     *yycdebug_ << std::endl;
       
   996   }
       
   997 
       
   998   // Report on the debug stream that the rule \a yyrule is going to be reduced.
       
   999   void
       
  1000   json_parser::yy_reduce_print_ (int yyrule)
       
  1001   {
       
  1002     unsigned int yylno = yyrline_[yyrule];
       
  1003     int yynrhs = yyr2_[yyrule];
       
  1004     /* Print the symbols being reduced, and their result.  */
       
  1005     *yycdebug_ << "Reducing stack by rule " << yyrule - 1
       
  1006 	       << " (line " << yylno << "), ";
       
  1007     /* The symbols being reduced.  */
       
  1008     for (int yyi = 0; yyi < yynrhs; yyi++)
       
  1009       YY_SYMBOL_PRINT ("   $" << yyi + 1 << " =",
       
  1010 		       yyrhs_[yyprhs_[yyrule] + yyi],
       
  1011 		       &(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
       
  1012 		       &(yylocation_stack_[(yynrhs) - (yyi + 1)]));
       
  1013   }
       
  1014 #endif // YYDEBUG
       
  1015 
       
  1016   /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
       
  1017   json_parser::token_number_type
       
  1018   json_parser::yytranslate_ (int t)
       
  1019   {
       
  1020     static
       
  1021     const token_number_type
       
  1022     translate_table[] =
       
  1023     {
       
  1024            0,     3,     4,     5,     6,     7,     8,     9,    10,    11,
       
  1025       12,    13,    14,    15,    16,    17,    18,     2,     2,     2,
       
  1026        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1027        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1028        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1029        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1030        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1031        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1032        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1033        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1034        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1035        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1036        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1037        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1038        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1039        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1040        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1041        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1042        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1043        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1044        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1045        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1046        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1047        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1048        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       
  1049        2,     2,     2,     2,     2,     2,     1,     2
       
  1050     };
       
  1051     if ((unsigned int) t <= yyuser_token_number_max_)
       
  1052       return translate_table[t];
       
  1053     else
       
  1054       return yyundef_token_;
       
  1055   }
       
  1056 
       
  1057   const int json_parser::yyeof_ = 0;
       
  1058   const int json_parser::yylast_ = 39;
       
  1059   const int json_parser::yynnts_ = 18;
       
  1060   const int json_parser::yyempty_ = -2;
       
  1061   const int json_parser::yyfinal_ = 25;
       
  1062   const int json_parser::yyterror_ = 1;
       
  1063   const int json_parser::yyerrcode_ = 256;
       
  1064   const int json_parser::yyntokens_ = 19;
       
  1065 
       
  1066   const unsigned int json_parser::yyuser_token_number_max_ = 257;
       
  1067   const json_parser::token_number_type json_parser::yyundef_token_ = 2;
       
  1068 
       
  1069 } // namespace yy
       
  1070 
       
  1071 #line 188 "json_parser.yy"
       
  1072 
       
  1073 
       
  1074 int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver)
       
  1075 {
       
  1076   JSonScanner* scanner = driver->m_scanner;
       
  1077   yylval->clear();
       
  1078   int ret = scanner->yylex(yylval, yylloc);
       
  1079 
       
  1080   qjsonDebug() << "json_parser::yylex - calling scanner yylval==|"
       
  1081            << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|";
       
  1082   
       
  1083   return ret;
       
  1084 }
       
  1085 
       
  1086 void yy::json_parser::error (const yy::location& yyloc,
       
  1087                                  const std::string& error)
       
  1088 {
       
  1089   /*qjsonDebug() << yyloc.begin.line;
       
  1090   qjsonDebug() << yyloc.begin.column;
       
  1091   qjsonDebug() << yyloc.end.line;
       
  1092   qjsonDebug() << yyloc.end.column;*/
       
  1093   qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ;
       
  1094   driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line);
       
  1095 }
       
  1096