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