00001 /* A Bison parser, made by GNU Bison 2.3. */ 00002 00003 /* Skeleton implementation for Bison LALR(1) parsers in C++ 00004 00005 Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2, or (at your option) 00010 any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. */ 00021 00022 /* As a special exception, you may create a larger work that contains 00023 part or all of the Bison parser skeleton and distribute that work 00024 under terms of your choice, so long as that work isn't itself a 00025 parser generator using the skeleton or a modified version thereof 00026 as a parser skeleton. Alternatively, if you modify or redistribute 00027 the parser skeleton itself, you may (at your option) remove this 00028 special exception, which will cause the skeleton and the resulting 00029 Bison output files to be licensed under the GNU General Public 00030 License without this special exception. 00031 00032 This special exception was added by the Free Software Foundation in 00033 version 2.2 of Bison. */ 00034 00035 00036 #include "json_parser.hh" 00037 00038 /* User implementation prologue. */ 00039 00040 00041 /* Line 317 of lalr1.cc. */ 00042 #line 43 "json_parser.cc" 00043 00044 #ifndef YY_ 00045 # if YYENABLE_NLS 00046 # if ENABLE_NLS 00047 # include <libintl.h> /* FIXME: INFRINGES ON USER NAME SPACE */ 00048 # define YY_(msgid) dgettext ("bison-runtime", msgid) 00049 # endif 00050 # endif 00051 # ifndef YY_ 00052 # define YY_(msgid) msgid 00053 # endif 00054 #endif 00055 00056 /* Suppress unused-variable warnings by "using" E. */ 00057 #define YYUSE(e) ((void) (e)) 00058 00059 /* A pseudo ostream that takes yydebug_ into account. */ 00060 # define YYCDEBUG \ 00061 for (bool yydebugcond_ = yydebug_; yydebugcond_; yydebugcond_ = false) \ 00062 (*yycdebug_) 00063 00064 /* Enable debugging if requested. */ 00065 #if YYDEBUG 00066 00067 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ 00068 do { \ 00069 if (yydebug_) \ 00070 { \ 00071 *yycdebug_ << Title << ' '; \ 00072 yy_symbol_print_ ((Type), (Value), (Location)); \ 00073 *yycdebug_ << std::endl; \ 00074 } \ 00075 } while (false) 00076 00077 # define YY_REDUCE_PRINT(Rule) \ 00078 do { \ 00079 if (yydebug_) \ 00080 yy_reduce_print_ (Rule); \ 00081 } while (false) 00082 00083 # define YY_STACK_PRINT() \ 00084 do { \ 00085 if (yydebug_) \ 00086 yystack_print_ (); \ 00087 } while (false) 00088 00089 #else /* !YYDEBUG */ 00090 00091 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) 00092 # define YY_REDUCE_PRINT(Rule) 00093 # define YY_STACK_PRINT() 00094 00095 #endif /* !YYDEBUG */ 00096 00097 #define YYACCEPT goto yyacceptlab 00098 #define YYABORT goto yyabortlab 00099 #define YYERROR goto yyerrorlab 00100 00101 namespace yy 00102 { 00103 #if YYERROR_VERBOSE 00104 00105 /* Return YYSTR after stripping away unnecessary quotes and 00106 backslashes, so that it's suitable for yyerror. The heuristic is 00107 that double-quoting is unnecessary unless the string contains an 00108 apostrophe, a comma, or backslash (other than backslash-backslash). 00109 YYSTR is taken from yytname. */ 00110 std::string 00111 json_parser::yytnamerr_ (const char *yystr) 00112 { 00113 if (*yystr == '"') 00114 { 00115 std::string yyr = ""; 00116 char const *yyp = yystr; 00117 00118 for (;;) 00119 switch (*++yyp) 00120 { 00121 case '\'': 00122 case ',': 00123 goto do_not_strip_quotes; 00124 00125 case '\\': 00126 if (*++yyp != '\\') 00127 goto do_not_strip_quotes; 00128 /* Fall through. */ 00129 default: 00130 yyr += *yyp; 00131 break; 00132 00133 case '"': 00134 return yyr; 00135 } 00136 do_not_strip_quotes: ; 00137 } 00138 00139 return yystr; 00140 } 00141 00142 #endif 00143 00145 json_parser::json_parser (QJson::ParserPrivate* driver_yyarg) 00146 : yydebug_ (false), 00147 yycdebug_ (&std::cerr), 00148 driver (driver_yyarg) 00149 { 00150 } 00151 00152 json_parser::~json_parser () 00153 { 00154 } 00155 00156 #if YYDEBUG 00157 /*--------------------------------. 00158 | Print this symbol on YYOUTPUT. | 00159 `--------------------------------*/ 00160 00161 inline void 00162 json_parser::yy_symbol_value_print_ (int yytype, 00163 const semantic_type* yyvaluep, const location_type* yylocationp) 00164 { 00165 YYUSE (yylocationp); 00166 YYUSE (yyvaluep); 00167 switch (yytype) 00168 { 00169 default: 00170 break; 00171 } 00172 } 00173 00174 00175 void 00176 json_parser::yy_symbol_print_ (int yytype, 00177 const semantic_type* yyvaluep, const location_type* yylocationp) 00178 { 00179 *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm") 00180 << ' ' << yytname_[yytype] << " (" 00181 << *yylocationp << ": "; 00182 yy_symbol_value_print_ (yytype, yyvaluep, yylocationp); 00183 *yycdebug_ << ')'; 00184 } 00185 #endif /* ! YYDEBUG */ 00186 00187 void 00188 json_parser::yydestruct_ (const char* yymsg, 00189 int yytype, semantic_type* yyvaluep, location_type* yylocationp) 00190 { 00191 YYUSE (yylocationp); 00192 YYUSE (yymsg); 00193 YYUSE (yyvaluep); 00194 00195 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 00196 00197 switch (yytype) 00198 { 00199 00200 default: 00201 break; 00202 } 00203 } 00204 00205 void 00206 json_parser::yypop_ (unsigned int n) 00207 { 00208 yystate_stack_.pop (n); 00209 yysemantic_stack_.pop (n); 00210 yylocation_stack_.pop (n); 00211 } 00212 00213 std::ostream& 00214 json_parser::debug_stream () const 00215 { 00216 return *yycdebug_; 00217 } 00218 00219 void 00220 json_parser::set_debug_stream (std::ostream& o) 00221 { 00222 yycdebug_ = &o; 00223 } 00224 00225 00226 json_parser::debug_level_type 00227 json_parser::debug_level () const 00228 { 00229 return yydebug_; 00230 } 00231 00232 void 00233 json_parser::set_debug_level (debug_level_type l) 00234 { 00235 yydebug_ = l; 00236 } 00237 00238 00239 int 00240 json_parser::parse () 00241 { 00243 int yychar = yyempty_; 00244 int yytoken = 0; 00245 00246 /* State. */ 00247 int yyn; 00248 int yylen = 0; 00249 int yystate = 0; 00250 00251 /* Error handling. */ 00252 int yynerrs_ = 0; 00253 int yyerrstatus_ = 0; 00254 00256 semantic_type yylval; 00258 location_type yylloc; 00260 location yyerror_range[2]; 00261 00263 semantic_type yyval; 00265 location_type yyloc; 00266 00267 int yyresult; 00268 00269 YYCDEBUG << "Starting parse" << std::endl; 00270 00271 00272 /* Initialize the stacks. The initial state will be pushed in 00273 yynewstate, since the latter expects the semantical and the 00274 location values to have been already stored, initialize these 00275 stacks with a primary value. */ 00276 yystate_stack_ = state_stack_type (0); 00277 yysemantic_stack_ = semantic_stack_type (0); 00278 yylocation_stack_ = location_stack_type (0); 00279 yysemantic_stack_.push (yylval); 00280 yylocation_stack_.push (yylloc); 00281 00282 /* New state. */ 00283 yynewstate: 00284 yystate_stack_.push (yystate); 00285 YYCDEBUG << "Entering state " << yystate << std::endl; 00286 goto yybackup; 00287 00288 /* Backup. */ 00289 yybackup: 00290 00291 /* Try to take a decision without look-ahead. */ 00292 yyn = yypact_[yystate]; 00293 if (yyn == yypact_ninf_) 00294 goto yydefault; 00295 00296 /* Read a look-ahead token. */ 00297 if (yychar == yyempty_) 00298 { 00299 YYCDEBUG << "Reading a token: "; 00300 yychar = yylex (&yylval, &yylloc, driver); 00301 } 00302 00303 00304 /* Convert token to internal form. */ 00305 if (yychar <= yyeof_) 00306 { 00307 yychar = yytoken = yyeof_; 00308 YYCDEBUG << "Now at end of input." << std::endl; 00309 } 00310 else 00311 { 00312 yytoken = yytranslate_ (yychar); 00313 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 00314 } 00315 00316 /* If the proper action on seeing token YYTOKEN is to reduce or to 00317 detect an error, take that action. */ 00318 yyn += yytoken; 00319 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken) 00320 goto yydefault; 00321 00322 /* Reduce or error. */ 00323 yyn = yytable_[yyn]; 00324 if (yyn <= 0) 00325 { 00326 if (yyn == 0 || yyn == yytable_ninf_) 00327 goto yyerrlab; 00328 yyn = -yyn; 00329 goto yyreduce; 00330 } 00331 00332 /* Accept? */ 00333 if (yyn == yyfinal_) 00334 goto yyacceptlab; 00335 00336 /* Shift the look-ahead token. */ 00337 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 00338 00339 /* Discard the token being shifted unless it is eof. */ 00340 if (yychar != yyeof_) 00341 yychar = yyempty_; 00342 00343 yysemantic_stack_.push (yylval); 00344 yylocation_stack_.push (yylloc); 00345 00346 /* Count tokens shifted since error; after three, turn off error 00347 status. */ 00348 if (yyerrstatus_) 00349 --yyerrstatus_; 00350 00351 yystate = yyn; 00352 goto yynewstate; 00353 00354 /*-----------------------------------------------------------. 00355 | yydefault -- do the default action for the current state. | 00356 `-----------------------------------------------------------*/ 00357 yydefault: 00358 yyn = yydefact_[yystate]; 00359 if (yyn == 0) 00360 goto yyerrlab; 00361 goto yyreduce; 00362 00363 /*-----------------------------. 00364 | yyreduce -- Do a reduction. | 00365 `-----------------------------*/ 00366 yyreduce: 00367 yylen = yyr2_[yyn]; 00368 /* If YYLEN is nonzero, implement the default value of the action: 00369 `$$ = $1'. Otherwise, use the top of the stack. 00370 00371 Otherwise, the following line sets YYVAL to garbage. 00372 This behavior is undocumented and Bison 00373 users should not rely upon it. */ 00374 if (yylen) 00375 yyval = yysemantic_stack_[yylen - 1]; 00376 else 00377 yyval = yysemantic_stack_[0]; 00378 00379 { 00380 slice<location_type, location_stack_type> slice (yylocation_stack_, yylen); 00381 YYLLOC_DEFAULT (yyloc, slice, yylen); 00382 } 00383 YY_REDUCE_PRINT (yyn); 00384 switch (yyn) 00385 { 00386 case 2: 00387 #line 84 "json_parser.yy" 00388 { 00389 driver->m_result = (yysemantic_stack_[(1) - (1)]); 00390 qjsonDebug() << "json_parser - parsing finished"; 00391 ;} 00392 break; 00393 00394 case 3: 00395 #line 89 "json_parser.yy" 00396 { (yyval) = (yysemantic_stack_[(1) - (1)]); ;} 00397 break; 00398 00399 case 4: 00400 #line 91 "json_parser.yy" 00401 { 00402 qCritical()<< "json_parser - syntax error found, " 00403 << "forcing abort, Line" << (yyloc).begin.line << "Column" << (yyloc).begin.column; 00404 YYABORT; 00405 ;} 00406 break; 00407 00408 case 6: 00409 #line 98 "json_parser.yy" 00410 { (yyval) = (yysemantic_stack_[(3) - (2)]); ;} 00411 break; 00412 00413 case 7: 00414 #line 100 "json_parser.yy" 00415 { (yyval) = QVariant (QVariantMap()); ;} 00416 break; 00417 00418 case 8: 00419 #line 101 "json_parser.yy" 00420 { 00421 QVariantMap members = (yysemantic_stack_[(2) - (2)]).toMap(); 00422 (yysemantic_stack_[(2) - (2)]) = QVariant(); // Allow reuse of map 00423 (yyval) = QVariant(members.unite ((yysemantic_stack_[(2) - (1)]).toMap())); 00424 ;} 00425 break; 00426 00427 case 9: 00428 #line 107 "json_parser.yy" 00429 { (yyval) = QVariant (QVariantMap()); ;} 00430 break; 00431 00432 case 10: 00433 #line 108 "json_parser.yy" 00434 { 00435 QVariantMap members = (yysemantic_stack_[(3) - (3)]).toMap(); 00436 (yysemantic_stack_[(3) - (3)]) = QVariant(); // Allow reuse of map 00437 (yyval) = QVariant(members.unite ((yysemantic_stack_[(3) - (2)]).toMap())); 00438 ;} 00439 break; 00440 00441 case 11: 00442 #line 114 "json_parser.yy" 00443 { 00444 QVariantMap pair; 00445 pair.insert ((yysemantic_stack_[(3) - (1)]).toString(), QVariant((yysemantic_stack_[(3) - (3)]))); 00446 (yyval) = QVariant (pair); 00447 ;} 00448 break; 00449 00450 case 12: 00451 #line 120 "json_parser.yy" 00452 { (yyval) = (yysemantic_stack_[(3) - (2)]); ;} 00453 break; 00454 00455 case 13: 00456 #line 122 "json_parser.yy" 00457 { (yyval) = QVariant (QVariantList()); ;} 00458 break; 00459 00460 case 14: 00461 #line 123 "json_parser.yy" 00462 { 00463 QVariantList members = (yysemantic_stack_[(2) - (2)]).toList(); 00464 (yysemantic_stack_[(2) - (2)]) = QVariant(); // Allow reuse of list 00465 members.prepend ((yysemantic_stack_[(2) - (1)])); 00466 (yyval) = QVariant(members); 00467 ;} 00468 break; 00469 00470 case 15: 00471 #line 130 "json_parser.yy" 00472 { (yyval) = QVariant (QVariantList()); ;} 00473 break; 00474 00475 case 16: 00476 #line 131 "json_parser.yy" 00477 { 00478 QVariantList members = (yysemantic_stack_[(3) - (3)]).toList(); 00479 (yysemantic_stack_[(3) - (3)]) = QVariant(); // Allow reuse of list 00480 members.prepend ((yysemantic_stack_[(3) - (2)])); 00481 (yyval) = QVariant(members); 00482 ;} 00483 break; 00484 00485 case 17: 00486 #line 138 "json_parser.yy" 00487 { (yyval) = (yysemantic_stack_[(1) - (1)]); ;} 00488 break; 00489 00490 case 18: 00491 #line 139 "json_parser.yy" 00492 { (yyval) = (yysemantic_stack_[(1) - (1)]); ;} 00493 break; 00494 00495 case 19: 00496 #line 140 "json_parser.yy" 00497 { (yyval) = (yysemantic_stack_[(1) - (1)]); ;} 00498 break; 00499 00500 case 20: 00501 #line 141 "json_parser.yy" 00502 { (yyval) = (yysemantic_stack_[(1) - (1)]); ;} 00503 break; 00504 00505 case 21: 00506 #line 142 "json_parser.yy" 00507 { (yyval) = QVariant (true); ;} 00508 break; 00509 00510 case 22: 00511 #line 143 "json_parser.yy" 00512 { (yyval) = QVariant (false); ;} 00513 break; 00514 00515 case 23: 00516 #line 144 "json_parser.yy" 00517 { 00518 QVariant null_variant; 00519 (yyval) = null_variant; 00520 ;} 00521 break; 00522 00523 case 24: 00524 #line 149 "json_parser.yy" 00525 { (yyval) = QVariant(QVariant::Double); (yyval).setValue( -std::numeric_limits<double>::infinity() ); ;} 00526 break; 00527 00528 case 25: 00529 #line 150 "json_parser.yy" 00530 { (yyval) = QVariant(QVariant::Double); (yyval).setValue( std::numeric_limits<double>::infinity() ); ;} 00531 break; 00532 00533 case 26: 00534 #line 151 "json_parser.yy" 00535 { (yyval) = QVariant(QVariant::Double); (yyval).setValue( std::numeric_limits<double>::quiet_NaN() ); ;} 00536 break; 00537 00538 case 28: 00539 #line 154 "json_parser.yy" 00540 { 00541 if ((yysemantic_stack_[(1) - (1)]).toByteArray().startsWith('-')) { 00542 (yyval) = QVariant (QVariant::LongLong); 00543 (yyval).setValue((yysemantic_stack_[(1) - (1)]).toLongLong()); 00544 } 00545 else { 00546 (yyval) = QVariant (QVariant::ULongLong); 00547 (yyval).setValue((yysemantic_stack_[(1) - (1)]).toULongLong()); 00548 } 00549 ;} 00550 break; 00551 00552 case 29: 00553 #line 164 "json_parser.yy" 00554 { 00555 const QByteArray value = (yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray(); 00556 (yyval) = QVariant(QVariant::Double); 00557 (yyval).setValue(value.toDouble()); 00558 ;} 00559 break; 00560 00561 case 30: 00562 #line 169 "json_parser.yy" 00563 { (yyval) = QVariant ((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;} 00564 break; 00565 00566 case 31: 00567 #line 170 "json_parser.yy" 00568 { 00569 const QByteArray value = (yysemantic_stack_[(3) - (1)]).toByteArray() + (yysemantic_stack_[(3) - (2)]).toByteArray() + (yysemantic_stack_[(3) - (3)]).toByteArray(); 00570 (yyval) = QVariant (value); 00571 ;} 00572 break; 00573 00574 case 32: 00575 #line 175 "json_parser.yy" 00576 { (yyval) = QVariant ((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;} 00577 break; 00578 00579 case 33: 00580 #line 176 "json_parser.yy" 00581 { (yyval) = QVariant (QByteArray("-") + (yysemantic_stack_[(3) - (2)]).toByteArray() + (yysemantic_stack_[(3) - (3)]).toByteArray()); ;} 00582 break; 00583 00584 case 34: 00585 #line 178 "json_parser.yy" 00586 { (yyval) = QVariant (QByteArray("")); ;} 00587 break; 00588 00589 case 35: 00590 #line 179 "json_parser.yy" 00591 { 00592 (yyval) = QVariant((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); 00593 ;} 00594 break; 00595 00596 case 36: 00597 #line 183 "json_parser.yy" 00598 { 00599 (yyval) = QVariant(QByteArray(".") + (yysemantic_stack_[(2) - (2)]).toByteArray()); 00600 ;} 00601 break; 00602 00603 case 37: 00604 #line 187 "json_parser.yy" 00605 { (yyval) = QVariant((yysemantic_stack_[(2) - (1)]).toByteArray() + (yysemantic_stack_[(2) - (2)]).toByteArray()); ;} 00606 break; 00607 00608 case 38: 00609 #line 189 "json_parser.yy" 00610 { (yyval) = (yysemantic_stack_[(3) - (2)]); ;} 00611 break; 00612 00613 case 39: 00614 #line 191 "json_parser.yy" 00615 { (yyval) = QVariant (QString(QLatin1String(""))); ;} 00616 break; 00617 00618 case 40: 00619 #line 192 "json_parser.yy" 00620 { 00621 (yyval) = (yysemantic_stack_[(1) - (1)]); 00622 ;} 00623 break; 00624 00625 00626 /* Line 675 of lalr1.cc. */ 00627 #line 628 "json_parser.cc" 00628 default: break; 00629 } 00630 YY_SYMBOL_PRINT ("-> $$ =", yyr1_[yyn], &yyval, &yyloc); 00631 00632 yypop_ (yylen); 00633 yylen = 0; 00634 YY_STACK_PRINT (); 00635 00636 yysemantic_stack_.push (yyval); 00637 yylocation_stack_.push (yyloc); 00638 00639 /* Shift the result of the reduction. */ 00640 yyn = yyr1_[yyn]; 00641 yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0]; 00642 if (0 <= yystate && yystate <= yylast_ 00643 && yycheck_[yystate] == yystate_stack_[0]) 00644 yystate = yytable_[yystate]; 00645 else 00646 yystate = yydefgoto_[yyn - yyntokens_]; 00647 goto yynewstate; 00648 00649 /*------------------------------------. 00650 | yyerrlab -- here on detecting error | 00651 `------------------------------------*/ 00652 yyerrlab: 00653 /* If not already recovering from an error, report this error. */ 00654 if (!yyerrstatus_) 00655 { 00656 ++yynerrs_; 00657 error (yylloc, yysyntax_error_ (yystate, yytoken)); 00658 } 00659 00660 yyerror_range[0] = yylloc; 00661 if (yyerrstatus_ == 3) 00662 { 00663 /* If just tried and failed to reuse look-ahead token after an 00664 error, discard it. */ 00665 00666 if (yychar <= yyeof_) 00667 { 00668 /* Return failure if at end of input. */ 00669 if (yychar == yyeof_) 00670 YYABORT; 00671 } 00672 else 00673 { 00674 yydestruct_ ("Error: discarding", yytoken, &yylval, &yylloc); 00675 yychar = yyempty_; 00676 } 00677 } 00678 00679 /* Else will try to reuse look-ahead token after shifting the error 00680 token. */ 00681 goto yyerrlab1; 00682 00683 00684 /*---------------------------------------------------. 00685 | yyerrorlab -- error raised explicitly by YYERROR. | 00686 `---------------------------------------------------*/ 00687 yyerrorlab: 00688 00689 /* Pacify compilers like GCC when the user code never invokes 00690 YYERROR and the label yyerrorlab therefore never appears in user 00691 code. */ 00692 if (false) 00693 goto yyerrorlab; 00694 00695 yyerror_range[0] = yylocation_stack_[yylen - 1]; 00696 /* Do not reclaim the symbols of the rule which action triggered 00697 this YYERROR. */ 00698 yypop_ (yylen); 00699 yylen = 0; 00700 yystate = yystate_stack_[0]; 00701 goto yyerrlab1; 00702 00703 /*-------------------------------------------------------------. 00704 | yyerrlab1 -- common code for both syntax error and YYERROR. | 00705 `-------------------------------------------------------------*/ 00706 yyerrlab1: 00707 yyerrstatus_ = 3; /* Each real token shifted decrements this. */ 00708 00709 for (;;) 00710 { 00711 yyn = yypact_[yystate]; 00712 if (yyn != yypact_ninf_) 00713 { 00714 yyn += yyterror_; 00715 if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) 00716 { 00717 yyn = yytable_[yyn]; 00718 if (0 < yyn) 00719 break; 00720 } 00721 } 00722 00723 /* Pop the current state because it cannot handle the error token. */ 00724 if (yystate_stack_.height () == 1) 00725 YYABORT; 00726 00727 yyerror_range[0] = yylocation_stack_[0]; 00728 yydestruct_ ("Error: popping", 00729 yystos_[yystate], 00730 &yysemantic_stack_[0], &yylocation_stack_[0]); 00731 yypop_ (); 00732 yystate = yystate_stack_[0]; 00733 YY_STACK_PRINT (); 00734 } 00735 00736 if (yyn == yyfinal_) 00737 goto yyacceptlab; 00738 00739 yyerror_range[1] = yylloc; 00740 // Using YYLLOC is tempting, but would change the location of 00741 // the look-ahead. YYLOC is available though. 00742 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); 00743 yysemantic_stack_.push (yylval); 00744 yylocation_stack_.push (yyloc); 00745 00746 /* Shift the error token. */ 00747 YY_SYMBOL_PRINT ("Shifting", yystos_[yyn], 00748 &yysemantic_stack_[0], &yylocation_stack_[0]); 00749 00750 yystate = yyn; 00751 goto yynewstate; 00752 00753 /* Accept. */ 00754 yyacceptlab: 00755 yyresult = 0; 00756 goto yyreturn; 00757 00758 /* Abort. */ 00759 yyabortlab: 00760 yyresult = 1; 00761 goto yyreturn; 00762 00763 yyreturn: 00764 if (yychar != yyeof_ && yychar != yyempty_) 00765 yydestruct_ ("Cleanup: discarding lookahead", yytoken, &yylval, &yylloc); 00766 00767 /* Do not reclaim the symbols of the rule which action triggered 00768 this YYABORT or YYACCEPT. */ 00769 yypop_ (yylen); 00770 while (yystate_stack_.height () != 1) 00771 { 00772 yydestruct_ ("Cleanup: popping", 00773 yystos_[yystate_stack_[0]], 00774 &yysemantic_stack_[0], 00775 &yylocation_stack_[0]); 00776 yypop_ (); 00777 } 00778 00779 return yyresult; 00780 } 00781 00782 // Generate an error message. 00783 std::string 00784 json_parser::yysyntax_error_ (int yystate, int tok) 00785 { 00786 std::string res; 00787 YYUSE (yystate); 00788 #if YYERROR_VERBOSE 00789 int yyn = yypact_[yystate]; 00790 if (yypact_ninf_ < yyn && yyn <= yylast_) 00791 { 00792 /* Start YYX at -YYN if negative to avoid negative indexes in 00793 YYCHECK. */ 00794 int yyxbegin = yyn < 0 ? -yyn : 0; 00795 00796 /* Stay within bounds of both yycheck and yytname. */ 00797 int yychecklim = yylast_ - yyn + 1; 00798 int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; 00799 int count = 0; 00800 for (int x = yyxbegin; x < yyxend; ++x) 00801 if (yycheck_[x + yyn] == x && x != yyterror_) 00802 ++count; 00803 00804 // FIXME: This method of building the message is not compatible 00805 // with internationalization. It should work like yacc.c does it. 00806 // That is, first build a string that looks like this: 00807 // "syntax error, unexpected %s or %s or %s" 00808 // Then, invoke YY_ on this string. 00809 // Finally, use the string as a format to output 00810 // yytname_[tok], etc. 00811 // Until this gets fixed, this message appears in English only. 00812 res = "syntax error, unexpected "; 00813 res += yytnamerr_ (yytname_[tok]); 00814 if (count < 5) 00815 { 00816 count = 0; 00817 for (int x = yyxbegin; x < yyxend; ++x) 00818 if (yycheck_[x + yyn] == x && x != yyterror_) 00819 { 00820 res += (!count++) ? ", expecting " : " or "; 00821 res += yytnamerr_ (yytname_[x]); 00822 } 00823 } 00824 } 00825 else 00826 #endif 00827 res = YY_("syntax error"); 00828 return res; 00829 } 00830 00831 00832 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 00833 STATE-NUM. */ 00834 const signed char json_parser::yypact_ninf_ = -21; 00835 const signed char 00836 json_parser::yypact_[] = 00837 { 00838 3, -21, -21, -6, 31, -10, 0, -21, -21, -21, 00839 6, -21, -21, 25, -21, -21, -21, -21, -21, -21, 00840 -5, -21, 22, 19, 21, 23, 24, 0, -21, 0, 00841 -21, -21, 13, -21, 0, 0, 29, -21, -21, -6, 00842 -21, 31, -21, 31, -21, -21, -21, -21, -21, -21, 00843 -21, 19, -21, 24, -21, -21 00844 }; 00845 00846 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE 00847 doesn't specify something else to do. Zero means the default is an 00848 error. */ 00849 const unsigned char 00850 json_parser::yydefact_[] = 00851 { 00852 0, 5, 4, 7, 13, 0, 34, 21, 22, 23, 00853 39, 25, 26, 0, 2, 19, 20, 3, 18, 27, 00854 28, 17, 0, 9, 0, 0, 15, 34, 24, 34, 00855 32, 40, 0, 1, 34, 34, 29, 30, 6, 0, 00856 8, 0, 12, 0, 14, 33, 35, 38, 36, 37, 00857 31, 9, 11, 15, 10, 16 00858 }; 00859 00860 /* YYPGOTO[NTERM-NUM]. */ 00861 const signed char 00862 json_parser::yypgoto_[] = 00863 { 00864 -21, -21, -21, -21, -21, -20, 4, -21, -21, -18, 00865 -4, -21, -21, -21, -14, -21, -3, -1, -21 00866 }; 00867 00868 /* YYDEFGOTO[NTERM-NUM]. */ 00869 const signed char 00870 json_parser::yydefgoto_[] = 00871 { 00872 -1, 13, 14, 15, 22, 40, 23, 16, 25, 44, 00873 17, 18, 19, 20, 30, 36, 37, 21, 32 00874 }; 00875 00876 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 00877 positive, shift that token. If negative, reduce the rule which 00878 number is the opposite. If zero, do what YYDEFACT says. */ 00879 const signed char json_parser::yytable_ninf_ = -1; 00880 const unsigned char 00881 json_parser::yytable_[] = 00882 { 00883 26, 27, 24, 1, 2, 34, 3, 35, 4, 28, 00884 10, 29, 5, 45, 6, 46, 7, 8, 9, 10, 00885 48, 49, 11, 12, 31, 33, 38, 39, 41, 42, 00886 47, 54, 43, 50, 3, 55, 4, 52, 24, 53, 00887 5, 35, 6, 51, 7, 8, 9, 10, 0, 0, 00888 11, 12 00889 }; 00890 00891 /* YYCHECK. */ 00892 const signed char 00893 json_parser::yycheck_[] = 00894 { 00895 4, 11, 3, 0, 1, 10, 3, 12, 5, 19, 00896 16, 11, 9, 27, 11, 29, 13, 14, 15, 16, 00897 34, 35, 19, 20, 18, 0, 4, 8, 7, 6, 00898 17, 51, 8, 36, 3, 53, 5, 41, 39, 43, 00899 9, 12, 11, 39, 13, 14, 15, 16, -1, -1, 00900 19, 20 00901 }; 00902 00903 /* STOS_[STATE-NUM] -- The (internal number of the) accessing 00904 symbol of state STATE-NUM. */ 00905 const unsigned char 00906 json_parser::yystos_[] = 00907 { 00908 0, 0, 1, 3, 5, 9, 11, 13, 14, 15, 00909 16, 19, 20, 22, 23, 24, 28, 31, 32, 33, 00910 34, 38, 25, 27, 38, 29, 31, 11, 19, 11, 00911 35, 18, 39, 0, 10, 12, 36, 37, 4, 8, 00912 26, 7, 6, 8, 30, 35, 35, 17, 35, 35, 00913 37, 27, 31, 31, 26, 30 00914 }; 00915 00916 #if YYDEBUG 00917 /* TOKEN_NUMBER_[YYLEX-NUM] -- Internal symbol number corresponding 00918 to YYLEX-NUM. */ 00919 const unsigned short int 00920 json_parser::yytoken_number_[] = 00921 { 00922 0, 256, 257, 1, 2, 3, 4, 5, 6, 7, 00923 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 00924 18 00925 }; 00926 #endif 00927 00928 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 00929 const unsigned char 00930 json_parser::yyr1_[] = 00931 { 00932 0, 21, 22, 23, 23, 23, 24, 25, 25, 26, 00933 26, 27, 28, 29, 29, 30, 30, 31, 31, 31, 00934 31, 31, 31, 31, 32, 32, 32, 32, 33, 33, 00935 33, 33, 34, 34, 35, 35, 36, 37, 38, 39, 00936 39 00937 }; 00938 00939 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 00940 const unsigned char 00941 json_parser::yyr2_[] = 00942 { 00943 0, 2, 1, 1, 1, 1, 3, 0, 2, 0, 00944 3, 3, 3, 0, 2, 0, 3, 1, 1, 1, 00945 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 00946 2, 3, 2, 3, 0, 2, 2, 2, 3, 0, 00947 1 00948 }; 00949 00950 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE 00951 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 00952 First, the terminals, then, starting at \a yyntokens_, nonterminals. */ 00953 const char* 00954 const json_parser::yytname_[] = 00955 { 00956 "\"end of file\"", "error", "$undefined", "\"{\"", "\"}\"", "\"[\"", 00957 "\"]\"", "\":\"", "\",\"", "\"-\"", "\".\"", "\"digit\"", 00958 "\"exponential\"", "\"true\"", "\"false\"", "\"null\"", 00959 "\"open quotation mark\"", "\"close quotation mark\"", "\"string\"", 00960 "\"Infinity\"", "\"NaN\"", "$accept", "start", "data", "object", 00961 "members", "r_members", "pair", "array", "values", "r_values", "value", 00962 "special_or_number", "number", "int", "digits", "fract", "exp", "string", 00963 "string_arg", 0 00964 }; 00965 #endif 00966 00967 #if YYDEBUG 00968 /* YYRHS -- A `-1'-separated list of the rules' RHS. */ 00969 const json_parser::rhs_number_type 00970 json_parser::yyrhs_[] = 00971 { 00972 22, 0, -1, 23, -1, 31, -1, 1, -1, 0, 00973 -1, 3, 25, 4, -1, -1, 27, 26, -1, -1, 00974 8, 27, 26, -1, 38, 7, 31, -1, 5, 29, 00975 6, -1, -1, 31, 30, -1, -1, 8, 31, 30, 00976 -1, 38, -1, 32, -1, 24, -1, 28, -1, 13, 00977 -1, 14, -1, 15, -1, 9, 19, -1, 19, -1, 00978 20, -1, 33, -1, 34, -1, 34, 36, -1, 34, 00979 37, -1, 34, 36, 37, -1, 11, 35, -1, 9, 00980 11, 35, -1, -1, 11, 35, -1, 10, 35, -1, 00981 12, 35, -1, 16, 39, 17, -1, -1, 18, -1 00982 }; 00983 00984 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in 00985 YYRHS. */ 00986 const unsigned char 00987 json_parser::yyprhs_[] = 00988 { 00989 0, 0, 3, 5, 7, 9, 11, 15, 16, 19, 00990 20, 24, 28, 32, 33, 36, 37, 41, 43, 45, 00991 47, 49, 51, 53, 55, 58, 60, 62, 64, 66, 00992 69, 72, 76, 79, 83, 84, 87, 90, 93, 97, 00993 98 00994 }; 00995 00996 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ 00997 const unsigned char 00998 json_parser::yyrline_[] = 00999 { 01000 0, 84, 84, 89, 90, 96, 98, 100, 101, 107, 01001 108, 114, 120, 122, 123, 130, 131, 138, 139, 140, 01002 141, 142, 143, 144, 149, 150, 151, 152, 154, 164, 01003 169, 170, 175, 176, 178, 179, 183, 187, 189, 191, 01004 192 01005 }; 01006 01007 // Print the state stack on the debug stream. 01008 void 01009 json_parser::yystack_print_ () 01010 { 01011 *yycdebug_ << "Stack now"; 01012 for (state_stack_type::const_iterator i = yystate_stack_.begin (); 01013 i != yystate_stack_.end (); ++i) 01014 *yycdebug_ << ' ' << *i; 01015 *yycdebug_ << std::endl; 01016 } 01017 01018 // Report on the debug stream that the rule \a yyrule is going to be reduced. 01019 void 01020 json_parser::yy_reduce_print_ (int yyrule) 01021 { 01022 unsigned int yylno = yyrline_[yyrule]; 01023 int yynrhs = yyr2_[yyrule]; 01024 /* Print the symbols being reduced, and their result. */ 01025 *yycdebug_ << "Reducing stack by rule " << yyrule - 1 01026 << " (line " << yylno << "), "; 01027 /* The symbols being reduced. */ 01028 for (int yyi = 0; yyi < yynrhs; yyi++) 01029 YY_SYMBOL_PRINT (" $" << yyi + 1 << " =", 01030 yyrhs_[yyprhs_[yyrule] + yyi], 01031 &(yysemantic_stack_[(yynrhs) - (yyi + 1)]), 01032 &(yylocation_stack_[(yynrhs) - (yyi + 1)])); 01033 } 01034 #endif // YYDEBUG 01035 01036 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 01037 json_parser::token_number_type 01038 json_parser::yytranslate_ (int t) 01039 { 01040 static 01041 const token_number_type 01042 translate_table[] = 01043 { 01044 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 01045 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 01046 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01047 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01048 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01049 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01050 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01051 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01052 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01053 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01054 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01055 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01056 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01057 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01058 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01059 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01060 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01061 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01062 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01063 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01064 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01065 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01066 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01067 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01068 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 01069 2, 2, 2, 2, 2, 2, 1, 2 01070 }; 01071 if ((unsigned int) t <= yyuser_token_number_max_) 01072 return translate_table[t]; 01073 else 01074 return yyundef_token_; 01075 } 01076 01077 const int json_parser::yyeof_ = 0; 01078 const int json_parser::yylast_ = 51; 01079 const int json_parser::yynnts_ = 19; 01080 const int json_parser::yyempty_ = -2; 01081 const int json_parser::yyfinal_ = 33; 01082 const int json_parser::yyterror_ = 1; 01083 const int json_parser::yyerrcode_ = 256; 01084 const int json_parser::yyntokens_ = 21; 01085 01086 const unsigned int json_parser::yyuser_token_number_max_ = 257; 01087 const json_parser::token_number_type json_parser::yyundef_token_ = 2; 01088 01089 } // namespace yy 01090 01091 #line 196 "json_parser.yy" 01092 01093 01094 int yy::yylex(YYSTYPE *yylval, yy::location *yylloc, QJson::ParserPrivate* driver) 01095 { 01096 JSonScanner* scanner = driver->m_scanner; 01097 yylval->clear(); 01098 int ret = scanner->yylex(yylval, yylloc); 01099 01100 qjsonDebug() << "json_parser::yylex - calling scanner yylval==|" 01101 << yylval->toByteArray() << "|, ret==|" << QString::number(ret) << "|"; 01102 01103 return ret; 01104 } 01105 01106 void yy::json_parser::error (const yy::location& yyloc, 01107 const std::string& error) 01108 { 01109 /*qjsonDebug() << yyloc.begin.line; 01110 qjsonDebug() << yyloc.begin.column; 01111 qjsonDebug() << yyloc.end.line; 01112 qjsonDebug() << yyloc.end.column;*/ 01113 qjsonDebug() << "json_parser::error [line" << yyloc.end.line << "] -" << error.c_str() ; 01114 driver->setError(QString::fromLatin1(error.c_str()), yyloc.end.line); 01115 } 01116
|
hosts this site. |
Send comments to: QJson Developers |