37 #line 38 "json_parser.cc"
45 #line 46 "json_parser.cc"
49 # if defined __cplusplus && 201103L <= __cplusplus
50 # define YY_NULL nullptr
57 # if defined YYENABLE_NLS && YYENABLE_NLS
60 # define YY_(msgid) dgettext ("bison-runtime", msgid)
64 # define YY_(msgid) msgid
68 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
73 # ifndef YYLLOC_DEFAULT
74 # define YYLLOC_DEFAULT(Current, Rhs, N) \
78 (Current).begin = YYRHSLOC (Rhs, 1).begin; \
79 (Current).end = YYRHSLOC (Rhs, N).end; \
83 (Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
90 #define YYUSE(e) ((void) (e))
96 # define YYCDEBUG if (yydebug_) (*yycdebug_)
98 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
102 *yycdebug_ << Title << ' '; \
103 yy_symbol_print_ ((Type), (Value), (Location)); \
104 *yycdebug_ << std::endl; \
108 # define YY_REDUCE_PRINT(Rule) \
111 yy_reduce_print_ (Rule); \
114 # define YY_STACK_PRINT() \
122 # define YYCDEBUG if (false) std::cerr
123 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) YYUSE(Type)
124 # define YY_REDUCE_PRINT(Rule) static_cast<void>(0)
125 # define YY_STACK_PRINT() static_cast<void>(0)
129 #define yyerrok (yyerrstatus_ = 0)
130 #define yyclearin (yychar = yyempty_)
132 #define YYACCEPT goto yyacceptlab
133 #define YYABORT goto yyabortlab
134 #define YYERROR goto yyerrorlab
135 #define YYRECOVERING() (!!yyerrstatus_)
140 #line 141 "json_parser.cc"
148 json_parser::yytnamerr_ (
const char *yystr)
153 char const *yyp = yystr;
160 goto do_not_strip_quotes;
164 goto do_not_strip_quotes;
173 do_not_strip_quotes: ;
185 yycdebug_ (&std::cerr),
187 driver (driver_yyarg)
191 json_parser::~json_parser ()
201 json_parser::yy_symbol_value_print_ (
int yytype,
202 const semantic_type* yyvaluep,
const location_type* yylocationp)
207 std::ostream& yyoutput = yyo;
218 json_parser::yy_symbol_print_ (
int yytype,
219 const semantic_type* yyvaluep,
const location_type* yylocationp)
221 *yycdebug_ << (yytype < yyntokens_ ?
"token" :
"nterm")
222 <<
' ' << yytname_[yytype] <<
" ("
223 << *yylocationp <<
": ";
224 yy_symbol_value_print_ (yytype, yyvaluep, yylocationp);
230 json_parser::yydestruct_ (
const char* yymsg,
231 int yytype, semantic_type* yyvaluep, location_type* yylocationp)
238 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
249 json_parser::yypop_ (
unsigned int n)
251 yystate_stack_.pop (n);
252 yysemantic_stack_.pop (n);
253 yylocation_stack_.pop (n);
284 json_parser::yy_pact_value_is_default_ (
int yyvalue)
286 return yyvalue == yypact_ninf_;
290 json_parser::yy_table_value_is_error_ (
int yyvalue)
292 return yyvalue == yytable_ninf_;
299 int yychar = yyempty_;
309 int yyerrstatus_ = 0;
330 YYCDEBUG <<
"Starting parse" << std::endl;
337 yystate_stack_ = state_stack_type (0);
338 yysemantic_stack_ = semantic_stack_type (0);
339 yylocation_stack_ = location_stack_type (0);
340 yysemantic_stack_.push (yylval);
341 yylocation_stack_.push (yylloc);
345 yystate_stack_.push (yystate);
346 YYCDEBUG <<
"Entering state " << yystate << std::endl;
349 if (yystate == yyfinal_)
358 yyn = yypact_[yystate];
359 if (yy_pact_value_is_default_ (yyn))
363 if (yychar == yyempty_)
365 YYCDEBUG <<
"Reading a token: ";
366 yychar = yylex (&yylval, &yylloc, driver);
370 if (yychar <= yyeof_)
372 yychar = yytoken = yyeof_;
373 YYCDEBUG <<
"Now at end of input." << std::endl;
377 yytoken = yytranslate_ (yychar);
378 YY_SYMBOL_PRINT (
"Next token is", yytoken, &yylval, &yylloc);
384 if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yytoken)
391 if (yy_table_value_is_error_ (yyn))
398 YY_SYMBOL_PRINT (
"Shifting", yytoken, &yylval, &yylloc);
403 yysemantic_stack_.push (yylval);
404 yylocation_stack_.push (yylloc);
418 yyn = yydefact_[yystate];
435 yyval = yysemantic_stack_[yylen - 1];
437 yyval = yysemantic_stack_[0];
442 YYLLOC_DEFAULT (yyloc,
slice, yylen);
446 YY_REDUCE_PRINT (yyn);
451 #line 82 "json_parser.yy"
453 driver->m_result = (yysemantic_stack_[(1) - (1)]);
454 qjsonDebug() <<
"json_parser - parsing finished";
460 #line 87 "json_parser.yy"
461 { (yyval) = (yysemantic_stack_[(1) - (1)]); }
466 #line 89 "json_parser.yy"
468 qCritical()<<
"json_parser - syntax error found, "
469 <<
"forcing abort, Line" << (yyloc).begin.line <<
"Column" << (yyloc).begin.column;
476 #line 95 "json_parser.yy"
478 (yyval) = QVariant(QVariantMap());
484 #line 98 "json_parser.yy"
486 QVariantMap* map = (yysemantic_stack_[(3) - (2)]).value<QVariantMap*>();
487 (yyval) = QVariant(*map);
494 #line 104 "json_parser.yy"
496 QVariantMap* pair =
new QVariantMap();
497 pair->insert((yysemantic_stack_[(3) - (1)]).toString(), (yysemantic_stack_[(3) - (3)]));
498 (yyval).setValue<QVariantMap* >(pair);
504 #line 109 "json_parser.yy"
506 (yyval).value<QVariantMap*>()->insert((yysemantic_stack_[(5) - (3)]).toString(), (yysemantic_stack_[(5) - (5)]));
512 #line 113 "json_parser.yy"
514 (yyval) = QVariant(QVariantList());
520 #line 116 "json_parser.yy"
522 QVector<QVariant>* list = (yysemantic_stack_[(3) - (2)]).value<QVector<QVariant>* >();
523 (yyval) = QVariant(list->toList());
530 #line 122 "json_parser.yy"
532 QVector<QVariant>* list =
new QVector<QVariant>(1);
533 list->replace(0, (yysemantic_stack_[(1) - (1)]));
534 (yyval).setValue(list);
540 #line 127 "json_parser.yy"
542 (yyval).value<QVector<QVariant>* >()->append((yysemantic_stack_[(3) - (3)]));
548 #line 549 "json_parser.cc"
564 YY_SYMBOL_PRINT (
"-> $$ =", yyr1_[yyn], &yyval, &yyloc);
570 yysemantic_stack_.push (yyval);
571 yylocation_stack_.push (yyloc);
575 yystate = yypgoto_[yyn - yyntokens_] + yystate_stack_[0];
576 if (0 <= yystate && yystate <= yylast_
577 && yycheck_[yystate] == yystate_stack_[0])
578 yystate = yytable_[yystate];
580 yystate = yydefgoto_[yyn - yyntokens_];
589 yytoken = yytranslate_ (yychar);
595 if (yychar == yyempty_)
597 error (yylloc, yysyntax_error_ (yystate, yytoken));
600 yyerror_range[1] = yylloc;
601 if (yyerrstatus_ == 3)
605 if (yychar <= yyeof_)
608 if (yychar == yyeof_)
613 yydestruct_ (
"Error: discarding", yytoken, &yylval, &yylloc);
634 yyerror_range[1] = yylocation_stack_[yylen - 1];
639 yystate = yystate_stack_[0];
650 yyn = yypact_[yystate];
651 if (!yy_pact_value_is_default_ (yyn))
654 if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_)
663 if (yystate_stack_.height () == 1)
666 yyerror_range[1] = yylocation_stack_[0];
667 yydestruct_ (
"Error: popping",
669 &yysemantic_stack_[0], &yylocation_stack_[0]);
671 yystate = yystate_stack_[0];
675 yyerror_range[2] = yylloc;
678 YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
679 yysemantic_stack_.push (yylval);
680 yylocation_stack_.push (yyloc);
683 YY_SYMBOL_PRINT (
"Shifting", yystos_[yyn],
684 &yysemantic_stack_[0], &yylocation_stack_[0]);
700 if (yychar != yyempty_)
704 yytoken = yytranslate_ (yychar);
705 yydestruct_ (
"Cleanup: discarding lookahead", yytoken, &yylval,
712 while (1 < yystate_stack_.height ())
714 yydestruct_ (
"Cleanup: popping",
715 yystos_[yystate_stack_[0]],
716 &yysemantic_stack_[0],
717 &yylocation_stack_[0]);
725 YYCDEBUG <<
"Exception caught: cleaning lookahead and stack"
729 if (yychar != yyempty_)
734 yytoken = yytranslate_ (yychar);
735 yydestruct_ (YY_NULL, yytoken, &yylval, &yylloc);
738 while (1 < yystate_stack_.height ())
740 yydestruct_ (YY_NULL,
741 yystos_[yystate_stack_[0]],
742 &yysemantic_stack_[0],
743 &yylocation_stack_[0]);
752 json_parser::yysyntax_error_ (
int yystate,
int yytoken)
759 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
761 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
788 if (yytoken != yyempty_)
790 yyarg[yycount++] = yytname_[yytoken];
791 int yyn = yypact_[yystate];
792 if (!yy_pact_value_is_default_ (yyn))
797 int yyxbegin = yyn < 0 ? -yyn : 0;
799 int yychecklim = yylast_ - yyn + 1;
800 int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
801 for (
int yyx = yyxbegin; yyx < yyxend; ++yyx)
802 if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
803 && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
805 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
811 yyarg[yycount++] = yytname_[yyx];
816 char const* yyformat = YY_NULL;
819 #define YYCASE_(N, S) \
823 YYCASE_(0, YY_(
"syntax error"));
824 YYCASE_(1, YY_(
"syntax error, unexpected %s"));
825 YYCASE_(2, YY_(
"syntax error, unexpected %s, expecting %s"));
826 YYCASE_(3, YY_(
"syntax error, unexpected %s, expecting %s or %s"));
827 YYCASE_(4, YY_(
"syntax error, unexpected %s, expecting %s or %s or %s"));
828 YYCASE_(5, YY_(
"syntax error, unexpected %s, expecting %s or %s or %s or %s"));
834 for (
char const* yyp = yyformat; *yyp; ++yyp)
835 if (yyp[0] ==
'%' && yyp[1] ==
's' && yyi < yycount)
837 yyres += yytnamerr_ (yyarg[yyi++]);
848 const signed char json_parser::yypact_ninf_ = -5;
850 json_parser::yypact_[] =
852 0, -5, 2, 18, -5, -5, -5, -5, -5, 7,
853 -5, -5, -5, -5, -5, 1, 12, -5, -4, -5,
854 -5, 29, -5, 4, -5, 29, -5, 26, -5, 29,
862 json_parser::yydefact_[] =
864 0, 4, 0, 0, 14, 15, 16, 17, 13, 0,
865 2, 18, 19, 3, 5, 0, 0, 9, 0, 11,
866 1, 0, 6, 0, 10, 0, 7, 0, 12, 0,
872 json_parser::yypgoto_[] =
874 -5, -5, -5, -5, -5, -5, -5, -3
879 json_parser::yydefgoto_[] =
881 -1, 9, 10, 11, 16, 12, 18, 13
887 const signed char json_parser::yytable_ninf_ = -1;
889 json_parser::yytable_[] =
891 19, 1, 24, 2, 25, 3, 14, 20, 21, 4,
892 5, 6, 7, 8, 0, 15, 22, 27, 26, 0,
893 23, 2, 28, 3, 17, 0, 30, 4, 5, 6,
894 7, 8, 2, 29, 3, 0, 0, 0, 4, 5,
900 json_parser::yycheck_[] =
902 3, 1, 6, 3, 8, 5, 4, 0, 7, 9,
903 10, 11, 12, 13, -1, 13, 4, 13, 21, -1,
904 8, 3, 25, 5, 6, -1, 29, 9, 10, 11,
905 12, 13, 3, 7, 5, -1, -1, -1, 9, 10,
912 json_parser::yystos_[] =
914 0, 1, 3, 5, 9, 10, 11, 12, 13, 16,
915 17, 18, 20, 22, 4, 13, 19, 6, 21, 22,
916 0, 7, 4, 8, 6, 8, 22, 13, 22, 7,
923 const unsigned short int
924 json_parser::yytoken_number_[] =
926 0, 256, 257, 1, 2, 3, 4, 5, 6, 7,
933 json_parser::yyr1_[] =
935 0, 15, 16, 17, 17, 18, 18, 19, 19, 20,
936 20, 21, 21, 22, 22, 22, 22, 22, 22, 22
941 json_parser::yyr2_[] =
943 0, 2, 1, 1, 1, 2, 3, 3, 5, 2,
944 3, 1, 3, 1, 1, 1, 1, 1, 1, 1
951 const json_parser::yytname_[] =
953 "\"end of file\"",
"error",
"$undefined",
"\"{\"",
"\"}\"",
"\"[\"",
954 "\"]\"",
"\":\"",
"\",\"",
"\"number\"",
"\"true\"",
"\"false\"",
955 "\"null\"",
"\"string\"",
"\"invalid\"",
"$accept",
"start",
"data",
956 "object",
"members",
"array",
"values",
"value", YY_NULL
961 const json_parser::rhs_number_type
962 json_parser::yyrhs_[] =
964 16, 0, -1, 17, -1, 22, -1, 1, -1, 3,
965 4, -1, 3, 19, 4, -1, 13, 7, 22, -1,
966 19, 8, 13, 7, 22, -1, 5, 6, -1, 5,
967 21, 6, -1, 22, -1, 21, 8, 22, -1, 13,
968 -1, 9, -1, 10, -1, 11, -1, 12, -1, 18,
975 json_parser::yyprhs_[] =
977 0, 0, 3, 5, 7, 9, 12, 16, 20, 26,
978 29, 33, 35, 39, 41, 43, 45, 47, 49, 51
983 json_parser::yyrline_[] =
985 0, 82, 82, 87, 88, 95, 98, 104, 109, 113,
986 116, 122, 127, 131, 132, 133, 134, 135, 136, 137
991 json_parser::yystack_print_ ()
993 *yycdebug_ <<
"Stack now";
994 for (state_stack_type::const_iterator i = yystate_stack_.begin ();
995 i != yystate_stack_.end (); ++i)
996 *yycdebug_ <<
' ' << *i;
997 *yycdebug_ << std::endl;
1002 json_parser::yy_reduce_print_ (
int yyrule)
1004 unsigned int yylno = yyrline_[yyrule];
1005 int yynrhs = yyr2_[yyrule];
1007 *yycdebug_ <<
"Reducing stack by rule " << yyrule - 1
1008 <<
" (line " << yylno <<
"):" << std::endl;
1010 for (
int yyi = 0; yyi < yynrhs; yyi++)
1011 YY_SYMBOL_PRINT (
" $" << yyi + 1 <<
" =",
1012 yyrhs_[yyprhs_[yyrule] + yyi],
1013 &(yysemantic_stack_[(yynrhs) - (yyi + 1)]),
1014 &(yylocation_stack_[(yynrhs) - (yyi + 1)]));
1019 json_parser::token_number_type
1020 json_parser::yytranslate_ (
int t)
1023 const token_number_type
1026 0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
1027 12, 13, 14, 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, 2, 2, 2, 2,
1050 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
1051 2, 2, 2, 2, 2, 2, 1, 2
1053 if ((
unsigned int) t <= yyuser_token_number_max_)
1054 return translate_table[t];
1056 return yyundef_token_;
1059 const int json_parser::yyeof_ = 0;
1060 const int json_parser::yylast_ = 42;
1061 const int json_parser::yynnts_ = 8;
1062 const int json_parser::yyempty_ = -2;
1063 const int json_parser::yyfinal_ = 20;
1064 const int json_parser::yyterror_ = 1;
1065 const int json_parser::yyerrcode_ = 256;
1066 const int json_parser::yyntokens_ = 15;
1068 const unsigned int json_parser::yyuser_token_number_max_ = 257;
1069 const json_parser::token_number_type json_parser::yyundef_token_ = 2;
1074 #line 1075 "json_parser.cc"
1076 #line 139 "json_parser.yy"
1079 int yy::yylex(YYSTYPE *yylval,
yy::location *yylloc, QJson::ParserPrivate* driver)
1081 JSonScanner* scanner = driver->m_scanner;
1083 int ret = scanner->yylex(yylval, yylloc);
1085 qjsonDebug() <<
"json_parser::yylex - calling scanner yylval==|"
1086 << yylval->toByteArray() <<
"|, ret==|" << QString::number(ret) <<
"|";
1091 void yy::json_parser::error (
const yy::location& yyloc,
const std::string& error)
1097 qjsonDebug() <<
"json_parser::error [line" << yyloc.
end.
line <<
"] -" << error.c_str() ;
1098 driver->setError(QString::fromLatin1(error.c_str()), yyloc.
end.
line);
json_parser(QJson::ParserPrivate *driver_yyarg)
Build a parser object.
debug_level_type debug_level() const
The current debugging level.
int debug_level_type
Type for debugging levels.
void set_debug_level(debug_level_type l)
Set the current debugging level.
std::ostream & debug_stream() const
The current debugging stream.
YYSTYPE semantic_type
Symbol semantic values.
void set_debug_stream(std::ostream &)
Set the current debugging stream.
position end
End of the located region.
unsigned int line
Current line number.
Present a slice of the top of a stack.