From 6ce98d6f8f6b4b1a35a2d1059aeec639d871ab29 Mon Sep 17 00:00:00 2001 From: itchyny Date: Sun, 5 May 2024 10:01:49 +0900 Subject: [PATCH] Improve parser to allow binary operator expressions as object values --- src/parser.c | 2130 +++++++++++++++++++++++-------------------------- src/parser.y | 247 +++--- tests/jq.test | 43 +- 3 files changed, 1155 insertions(+), 1265 deletions(-) diff --git a/src/parser.c b/src/parser.c index 97f3725224..8e583c5127 100644 --- a/src/parser.c +++ b/src/parser.c @@ -360,18 +360,18 @@ enum yysymbol_kind_t YYSYMBOL_Module = 72, /* Module */ YYSYMBOL_Imports = 73, /* Imports */ YYSYMBOL_FuncDefs = 74, /* FuncDefs */ - YYSYMBOL_Exp = 75, /* Exp */ - YYSYMBOL_Import = 76, /* Import */ - YYSYMBOL_ImportWhat = 77, /* ImportWhat */ - YYSYMBOL_ImportFrom = 78, /* ImportFrom */ - YYSYMBOL_FuncDef = 79, /* FuncDef */ - YYSYMBOL_Params = 80, /* Params */ - YYSYMBOL_Param = 81, /* Param */ - YYSYMBOL_StringStart = 82, /* StringStart */ - YYSYMBOL_String = 83, /* String */ - YYSYMBOL_QQString = 84, /* QQString */ - YYSYMBOL_ElseBody = 85, /* ElseBody */ - YYSYMBOL_ExpD = 86, /* ExpD */ + YYSYMBOL_Query = 75, /* Query */ + YYSYMBOL_Expr = 76, /* Expr */ + YYSYMBOL_Import = 77, /* Import */ + YYSYMBOL_ImportWhat = 78, /* ImportWhat */ + YYSYMBOL_ImportFrom = 79, /* ImportFrom */ + YYSYMBOL_FuncDef = 80, /* FuncDef */ + YYSYMBOL_Params = 81, /* Params */ + YYSYMBOL_Param = 82, /* Param */ + YYSYMBOL_StringStart = 83, /* StringStart */ + YYSYMBOL_String = 84, /* String */ + YYSYMBOL_QQString = 85, /* QQString */ + YYSYMBOL_ElseBody = 86, /* ElseBody */ YYSYMBOL_Term = 87, /* Term */ YYSYMBOL_Args = 88, /* Args */ YYSYMBOL_Arg = 89, /* Arg */ @@ -382,8 +382,9 @@ enum yysymbol_kind_t YYSYMBOL_ObjPats = 94, /* ObjPats */ YYSYMBOL_ObjPat = 95, /* ObjPat */ YYSYMBOL_Keyword = 96, /* Keyword */ - YYSYMBOL_MkDict = 97, /* MkDict */ - YYSYMBOL_MkDictPair = 98 /* MkDictPair */ + YYSYMBOL_DictPairs = 97, /* DictPairs */ + YYSYMBOL_DictPair = 98, /* DictPair */ + YYSYMBOL_DictExpr = 99 /* DictExpr */ }; typedef enum yysymbol_kind_t yysymbol_kind_t; @@ -550,7 +551,7 @@ static block gen_loc_object(location *loc, struct locfile *locations) { } -#line 554 "src/parser.c" +#line 555 "src/parser.c" #ifdef short @@ -875,14 +876,14 @@ union yyalloc #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 30 +#define YYFINAL 31 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 2007 +#define YYLAST 1275 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 70 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 29 +#define YYNNTS 30 /* YYNRULES -- Number of rules. */ #define YYNRULES 168 /* YYNSTATES -- Number of states. */ @@ -941,22 +942,22 @@ static const yytype_int8 yytranslate[] = static const yytype_int16 yyrline[] = { 0, 290, 290, 293, 298, 301, 316, 319, 324, 327, - 332, 336, 340, 347, 351, 355, 359, 363, 367, 371, - 375, 379, 383, 387, 391, 395, 399, 403, 407, 411, - 415, 419, 423, 427, 431, 435, 439, 443, 448, 451, - 468, 477, 484, 492, 503, 508, 514, 517, 522, 526, - 533, 536, 542, 549, 552, 555, 561, 564, 567, 572, - 575, 581, 584, 587, 595, 599, 602, 605, 608, 611, - 614, 617, 620, 623, 627, 633, 636, 639, 642, 645, - 648, 651, 654, 657, 660, 663, 666, 669, 672, 675, - 678, 681, 684, 687, 690, 693, 696, 699, 706, 709, - 712, 715, 718, 722, 725, 729, 747, 751, 755, 758, - 770, 775, 776, 777, 778, 781, 784, 789, 794, 797, - 802, 805, 810, 814, 817, 822, 825, 830, 833, 838, - 841, 844, 847, 850, 853, 861, 867, 870, 873, 876, - 879, 882, 885, 888, 891, 894, 897, 900, 903, 906, - 909, 912, 915, 918, 923, 926, 927, 928, 931, 934, - 937, 940, 944, 949, 953, 957, 961, 965, 973 + 333, 336, 339, 345, 348, 351, 357, 360, 363, 366, + 369, 372, 375, 378, 381, 384, 387, 390, 393, 396, + 399, 402, 405, 408, 411, 414, 417, 420, 423, 429, + 432, 449, 458, 465, 473, 484, 489, 495, 498, 503, + 507, 514, 517, 523, 530, 533, 536, 542, 545, 548, + 554, 557, 560, 568, 572, 575, 578, 581, 584, 587, + 590, 593, 596, 600, 606, 609, 612, 615, 618, 621, + 624, 627, 630, 633, 636, 639, 642, 645, 648, 651, + 654, 657, 660, 663, 666, 669, 672, 679, 682, 685, + 688, 691, 695, 698, 702, 720, 724, 728, 731, 743, + 748, 749, 750, 751, 754, 757, 762, 767, 770, 775, + 778, 783, 787, 790, 795, 798, 803, 806, 811, 814, + 817, 820, 823, 826, 834, 840, 843, 846, 849, 852, + 855, 858, 861, 864, 867, 870, 873, 876, 879, 882, + 885, 888, 891, 897, 900, 903, 908, 911, 914, 917, + 921, 926, 930, 934, 938, 942, 950, 956, 959 }; #endif @@ -984,10 +985,11 @@ static const char *const yytname[] = "FUNCDEF", "'|'", "','", "'='", "'<'", "'>'", "'+'", "'-'", "'*'", "'/'", "'%'", "NONOPT", "'?'", "'.'", "'['", "';'", "':'", "'('", "')'", "']'", "'{'", "'}'", "'$'", "$accept", "TopLevel", "Module", "Imports", - "FuncDefs", "Exp", "Import", "ImportWhat", "ImportFrom", "FuncDef", - "Params", "Param", "StringStart", "String", "QQString", "ElseBody", - "ExpD", "Term", "Args", "Arg", "RepPatterns", "Patterns", "Pattern", - "ArrayPats", "ObjPats", "ObjPat", "Keyword", "MkDict", "MkDictPair", YY_NULLPTR + "FuncDefs", "Query", "Expr", "Import", "ImportWhat", "ImportFrom", + "FuncDef", "Params", "Param", "StringStart", "String", "QQString", + "ElseBody", "Term", "Args", "Arg", "RepPatterns", "Patterns", "Pattern", + "ArrayPats", "ObjPats", "ObjPat", "Keyword", "DictPairs", "DictPair", + "DictExpr", YY_NULLPTR }; static const char * @@ -997,12 +999,12 @@ yysymbol_name (yysymbol_kind_t yysymbol) } #endif -#define YYPACT_NINF (-183) +#define YYPACT_NINF (-179) #define yypact_value_is_default(Yyn) \ ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF (-155) +#define YYTABLE_NINF (-154) #define yytable_value_is_error(Yyn) \ ((Yyn) == YYTABLE_NINF) @@ -1011,38 +1013,38 @@ yysymbol_name (yysymbol_kind_t yysymbol) STATE-NUM. */ static const yytype_int16 yypact[] = { - 21, 903, 40, 38, -20, -11, -183, -183, 9, -183, - 55, 903, 969, 969, 903, 68, 37, -183, -183, 969, - 280, 413, 480, 186, 6, 1421, 903, -183, -183, 11, - -183, 0, 0, 903, 38, 705, 903, -183, -183, 2, - 1677, 59, 62, 54, 29, -183, -183, 104, -183, 113, - 9, 57, 51, -183, 1087, 60, 1256, -35, 61, 63, - -183, -183, -183, -183, -183, -183, -183, -183, -183, -183, - -183, -183, -183, -183, -183, -183, -183, -183, -183, 903, - 64, 66, 67, 82, 72, 903, 903, 903, 903, 903, - 903, 903, 903, 903, 903, 903, 903, 903, 903, 903, - 903, 903, 903, 903, 903, 903, 903, 903, 903, -183, - 1837, 3, 73, -4, -183, -3, 346, 129, -183, -183, - -183, 1837, 903, -183, -183, 1453, 1837, -53, -183, 903, - 48, 547, -4, -4, 614, 903, -183, -183, -183, -183, - -183, -183, 676, 969, -183, 969, 969, 1289, 969, 969, - -183, 676, 138, 1901, 1920, 1920, 1869, 1950, 929, 1901, - 1901, 1901, 1901, 1901, 1901, 1920, 1920, 1837, 1869, 1901, - 1920, 1920, 24, 24, -183, -183, -183, -183, 903, -183, - -183, -183, -4, 1031, 106, 100, 108, 771, 91, 85, - 903, 93, 1053, 56, -183, -183, 903, -183, 1485, -183, - -183, -12, -183, -183, 1629, 90, 96, -183, -183, 1837, - -32, -183, 109, 104, 109, 109, 98, 109, 109, -183, - -183, 1709, -183, -25, 99, 103, 105, 903, 107, -38, - -183, 110, -4, 903, 112, 1121, -183, -183, 1155, -183, - 837, 115, -183, -183, -183, -183, 48, 117, 903, 903, - -183, -183, 903, 903, 969, 969, -183, -4, -183, -4, - -4, -4, 1322, -4, 1031, -183, -4, 126, 1837, -183, - 116, 122, 123, 1189, -183, -183, 903, 1757, 1805, 1517, - 1549, 109, 109, -183, -183, -183, -183, 120, -183, -183, - -183, -183, -183, -183, 125, 1581, -183, 903, 903, 903, - -4, -183, -183, 1629, 1355, 1223, -183, -183, -183, 903, - -183, 1388, -183 + 0, 1003, 32, 51, -25, -4, -179, -179, 17, -179, + 59, 1003, 1069, 1069, 1069, 68, 18, -179, -179, 1069, + 392, 458, 525, 721, 9, 22, 1186, 1003, -179, -179, + 1, -179, 15, 15, 1003, 51, 805, 1003, -179, -179, + 98, -8, 267, 6, 1153, 61, 45, -179, -179, 6, + -179, 104, 17, 95, 44, -179, 47, 66, 72, -34, + 55, 106, -179, -179, -179, -179, -179, -179, -179, -179, + -179, -179, -179, -179, -179, -179, -179, -179, -179, -179, + -179, 1003, 126, 131, 135, 157, 147, 1003, 1003, -179, + 1069, 1069, 1069, 1069, 1069, 1069, 1069, 1069, 1069, 1069, + 1069, 1069, 1069, 1069, 1069, 1069, 1069, 1069, 1069, 1069, + 1069, 1069, 209, 5, 160, -3, -179, 14, 151, 226, + -179, -179, -179, 209, 1003, -179, -179, 63, 209, 73, + -179, 1003, 142, 592, -3, -3, 659, 1003, -179, -179, + -179, -179, -179, -179, 1069, -179, 1069, 1069, 119, 1069, + 1069, -179, 776, 236, 209, -179, 1218, 315, 315, 1186, + 618, 88, 1218, 1218, 1218, 1218, 1218, 1218, 315, 315, + 1218, 315, 315, 181, 181, -179, -179, -179, -179, 1003, + -179, -179, -179, -3, 1131, 203, 198, 218, 871, 191, + 194, 1003, 202, 28, 225, -179, -179, 1003, -179, 67, + -179, -179, 111, -179, -179, 176, 199, 206, -179, -179, + 209, 1186, 214, 214, 214, 204, 214, 214, 208, -179, + -179, 185, -179, -41, 210, 211, 213, 1003, 219, -21, + -179, 220, -3, 1003, 207, 53, -179, -179, 58, -179, + 937, 227, -179, -179, -179, -179, 142, 221, 1003, 1003, + -179, -179, 1003, 1003, 1069, 1069, -179, -3, -179, -3, + -3, -3, 123, -3, 1131, -179, -3, 231, 209, -179, + 228, 229, 230, 60, -179, -179, 1003, -18, 24, 161, + 173, 214, 214, -179, -179, -179, -179, 222, -179, -179, + -179, -179, -179, -179, 232, 179, -179, 1003, 1003, 1003, + -3, -179, -179, 176, 137, 115, -179, -179, -179, 1003, + -179, 143, -179 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -1050,54 +1052,54 @@ static const yytype_int16 yypact[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 4, 0, 0, 6, 109, 70, 107, 90, 92, 62, - 0, 0, 0, 0, 0, 0, 0, 108, 51, 0, - 0, 0, 0, 0, 0, 0, 0, 53, 91, 37, - 1, 0, 0, 8, 6, 0, 0, 66, 50, 0, - 0, 0, 0, 105, 0, 64, 63, 93, 73, 0, - 0, 72, 0, 96, 0, 0, 0, 0, 164, 163, - 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, - 146, 147, 148, 149, 150, 151, 152, 153, 165, 0, - 161, 166, 0, 155, 0, 0, 0, 0, 0, 0, + 4, 0, 0, 6, 108, 69, 106, 89, 91, 61, + 0, 0, 0, 0, 0, 0, 0, 107, 52, 0, + 0, 0, 0, 0, 0, 0, 15, 0, 54, 90, + 38, 1, 0, 0, 8, 6, 0, 0, 65, 51, + 0, 0, 0, 38, 0, 104, 0, 63, 62, 92, + 72, 0, 0, 71, 0, 95, 0, 0, 0, 0, + 162, 161, 135, 136, 137, 138, 139, 140, 141, 142, + 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, + 163, 0, 159, 164, 0, 154, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, - 10, 0, 69, 0, 89, 0, 0, 0, 43, 42, - 3, 2, 8, 7, 38, 0, 117, 0, 115, 0, - 0, 0, 0, 0, 0, 0, 74, 68, 112, 95, - 111, 94, 0, 0, 114, 0, 0, 0, 0, 0, - 97, 0, 0, 30, 31, 32, 16, 15, 14, 18, - 22, 24, 26, 29, 17, 35, 36, 19, 20, 13, - 33, 34, 21, 23, 25, 27, 28, 54, 0, 52, - 65, 122, 0, 0, 0, 0, 121, 0, 71, 0, - 0, 80, 0, 0, 9, 39, 0, 110, 0, 49, - 48, 0, 46, 102, 0, 0, 0, 104, 103, 12, - 0, 157, 168, 60, 158, 162, 0, 160, 159, 156, - 106, 0, 125, 0, 0, 0, 129, 0, 0, 0, - 127, 0, 0, 0, 82, 0, 67, 113, 0, 79, - 0, 76, 41, 40, 116, 44, 0, 0, 0, 0, - 58, 101, 0, 0, 0, 0, 55, 0, 123, 0, - 0, 0, 0, 0, 0, 124, 0, 120, 11, 81, - 78, 88, 87, 0, 75, 47, 0, 0, 0, 0, - 0, 59, 167, 126, 135, 131, 130, 0, 133, 128, - 132, 77, 85, 84, 86, 0, 57, 0, 0, 0, - 0, 83, 45, 0, 0, 0, 134, 56, 98, 0, - 100, 0, 99 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 10, 0, 68, 0, 88, 0, 0, 0, + 44, 43, 3, 2, 8, 7, 39, 0, 116, 0, + 114, 0, 0, 0, 0, 0, 0, 0, 73, 67, + 111, 94, 110, 93, 0, 113, 0, 0, 0, 0, + 0, 96, 0, 0, 13, 14, 31, 32, 33, 16, + 19, 18, 21, 23, 25, 27, 30, 20, 36, 37, + 17, 34, 35, 22, 24, 26, 28, 29, 55, 0, + 53, 64, 121, 0, 0, 0, 0, 120, 0, 70, + 0, 0, 79, 0, 0, 9, 40, 0, 109, 0, + 50, 49, 0, 47, 101, 0, 0, 0, 103, 102, + 12, 168, 166, 156, 160, 0, 158, 157, 0, 155, + 105, 0, 124, 0, 0, 0, 128, 0, 0, 0, + 126, 0, 0, 0, 81, 0, 66, 112, 0, 78, + 0, 75, 42, 41, 115, 45, 0, 0, 0, 0, + 59, 100, 0, 0, 0, 0, 56, 0, 122, 0, + 0, 0, 0, 0, 0, 123, 0, 119, 11, 80, + 77, 87, 86, 0, 74, 48, 0, 0, 0, 0, + 0, 167, 165, 125, 134, 130, 129, 0, 132, 127, + 131, 76, 84, 83, 85, 0, 58, 0, 0, 0, + 0, 82, 46, 0, 0, 0, 133, 57, 97, 0, + 99, 0, 98 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -183, -183, -183, 135, 50, -1, -183, -183, 144, -14, - -183, -61, -183, -5, -183, -115, -142, 10, -183, 1, - -183, -64, -121, -183, -183, -73, -182, -106, -183 + -179, -179, -179, 255, 171, 16, 241, -179, -179, 266, + -32, -179, 64, -179, -19, -179, 8, -1, -179, 112, + -179, 65, -178, -179, -179, 48, -175, 164, -179, -104 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_uint8 yydefgoto[] = { - 0, 2, 3, 33, 120, 110, 34, 35, 117, 26, - 201, 202, 27, 28, 111, 251, 212, 29, 127, 128, - 184, 185, 186, 223, 229, 230, 81, 82, 83 + 0, 2, 3, 34, 122, 112, 26, 35, 36, 119, + 27, 202, 203, 28, 29, 113, 251, 43, 129, 130, + 185, 186, 187, 223, 229, 230, 83, 84, 85, 212 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -1105,83 +1107,93 @@ static const yytype_uint8 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_int16 yytable[] = { - 25, 231, 181, 214, 215, 50, 217, 218, 50, 196, - 40, 264, 197, 43, 142, 51, 112, 142, 80, 122, - 54, 56, 41, 42, 257, 113, 118, 118, 143, 47, - 265, 143, 121, 144, 125, 126, 211, 1, 45, 18, - 30, 258, 18, 46, 36, 219, 177, 178, 37, 179, - 246, 38, 199, 247, 200, 31, 32, 182, 187, 39, - 242, 222, 243, 183, 112, 129, 130, 112, 205, 206, - 114, 115, 116, 132, 44, 84, 133, 135, 147, 106, - 107, 108, 231, 134, 153, 154, 155, 156, 157, 158, - 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, - 169, 170, 171, 172, 173, 174, 175, 176, 122, 112, - 188, 267, 281, 282, 136, 192, 137, 138, 114, 115, - 116, 114, 115, 116, 145, 140, 146, 148, 198, 149, - 204, 151, 180, 208, 209, 150, 283, 80, 284, 285, - 286, 152, 288, 193, 220, 290, 80, 232, 233, -119, - 236, 237, 239, 213, 252, 213, 213, 254, 213, 213, - 253, 255, 259, 114, 115, 116, 260, -118, 261, 123, - 263, 269, 194, 266, 274, 291, 119, 221, 228, 306, - 276, 292, 293, 300, 301, 275, 235, 57, 307, 238, - 58, 289, 59, 0, 50, 126, 0, 244, 0, 0, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 0, - 0, 0, 0, 0, 0, 0, 262, 0, 18, 0, - 0, 0, 268, 0, 0, 0, 0, 0, 0, 273, - 0, 0, 0, 0, 0, 0, 0, 277, 278, 0, - 79, 279, 280, 0, -154, 0, 0, 0, 0, 228, - 0, 0, 0, 0, 213, 213, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 295, 0, 0, 0, 0, - -61, 48, 0, 0, 49, -61, 0, 0, 50, 0, - -61, -61, -61, -61, -61, 0, 303, 304, 305, 0, - -61, -61, -61, 0, 0, -61, -61, -61, 311, -61, - 0, 0, 0, -61, -61, -61, -61, -61, -61, -61, - -61, 0, 18, 0, 0, -61, 0, 0, -61, -61, - -61, -61, -61, -61, -61, -61, -61, -61, 0, -61, - -61, -61, -61, -61, 0, -61, -61, 189, -61, 0, - 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, - 0, 10, 0, 0, 0, 11, 0, 0, 0, 12, - 13, 0, 0, 0, 14, 0, 15, 16, 17, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 19, 0, 0, 0, 0, 0, 20, 21, 0, 190, - 22, 0, 191, 23, 52, 24, 0, 4, 5, 6, - 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, - 0, 0, 11, 0, 0, 0, 12, 13, 0, 0, - 0, 14, 0, 15, 16, 17, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, - 0, 0, 0, 20, 21, 0, 0, 22, 0, 53, - 23, 55, 24, 0, 4, 5, 6, 7, 8, 9, - 0, 0, 0, 0, 0, 10, 0, 0, 0, 11, - 0, 0, 0, 12, 13, 0, 0, 0, 14, 0, - 15, 16, 17, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, - 20, 21, 0, 0, 22, 0, 0, 23, 203, 24, - 0, 4, 5, 6, 7, 8, 9, 0, 0, 0, - 0, 0, 10, 0, 0, 0, 11, 0, 0, 0, - 12, 13, 0, 0, 0, 14, 0, 15, 16, 17, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 19, 0, 0, 0, 0, 0, 20, 21, 0, - 0, 22, 0, 0, 23, 207, 24, 0, 4, 5, - 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, - 0, 0, 0, 11, 0, 0, 0, 12, 13, 0, - 0, 0, 14, 0, 15, 16, 17, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, - 0, 0, 0, 0, 20, 21, 0, 210, 22, 0, - 58, 23, 59, 24, 50, 0, 0, 0, 0, 0, - 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, - 70, 71, 72, 73, 74, 75, 76, 77, 78, 4, + 30, 53, 124, 182, 82, 222, 114, 296, 257, 231, + 30, 114, 133, 120, 120, 115, 1, 25, 49, 47, + 30, 30, 52, 52, 48, 258, 30, 41, 264, 144, + 87, 88, 31, 30, 145, 30, 30, 56, 58, 37, + 87, 88, 213, 214, 297, 216, 217, 265, 178, 179, + 123, 180, 127, 128, 267, 38, 18, 18, 183, 39, + 116, 117, 118, 40, 184, 116, 117, 118, 32, 33, + 87, 88, 87, 88, 46, 188, 87, 88, 86, 283, + 30, 284, 285, 286, 89, 288, 30, 30, 290, 231, + 136, 240, 124, 137, 241, 87, 88, 148, 189, 91, + 92, 87, 88, 154, 155, 138, 87, 88, 87, 88, + 140, 87, 88, 141, 94, 87, 88, 30, 146, 270, + 87, 88, 306, 30, 271, 196, 294, 102, 103, 245, + 30, 142, 30, 82, 193, 197, 30, 143, 198, 105, + 106, 107, 108, 109, 110, 111, 200, 199, 201, 205, + 281, 282, 190, 210, 139, 4, 5, 6, 7, 8, + 9, 131, 132, 87, 88, 228, 10, 87, 88, 147, + 11, 87, 88, 246, 12, 13, 247, 309, 30, 14, + 310, 15, 16, 17, 215, 87, 88, 30, 287, 149, + 30, 87, 88, 18, 150, 221, 30, 248, 249, 206, + 207, 250, 308, 151, 235, 19, 152, 238, 312, 87, + 88, 20, 21, 128, 191, 22, 153, 192, 23, 181, + 24, 87, 88, 298, 87, 88, 30, 87, 88, 242, + 256, 243, 30, 87, 88, 299, 109, 110, 111, 30, + 194, 302, 220, 262, 232, 228, 233, 30, 30, 268, + 236, 30, 30, 42, 44, 45, 273, 87, 88, -118, + 237, 239, 254, 252, 277, 278, 269, 255, 279, 280, + 253, 144, -117, 259, 260, 30, 261, 90, 91, 92, + 93, 134, 263, 266, 276, 300, 274, 291, 292, 293, + 125, 301, 295, 94, 95, 195, 30, 30, 30, 121, + 96, 97, 98, 99, 100, 101, 102, 103, 30, 244, + 275, 307, 289, 303, 304, 305, 219, 104, 105, 106, + 107, 108, 109, 110, 111, 311, -154, -154, 0, 0, + 0, 156, 157, 158, 159, 160, 161, 162, 163, 164, + 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, + 175, 176, 177, 0, -154, -154, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -154, -154, 107, 108, + 109, 110, 111, 0, 0, 0, 0, 209, 0, 0, + 0, 0, 0, 0, 0, 211, 0, 211, 211, 0, + 211, 211, -60, 50, 0, 0, 51, -60, 0, 0, + 52, 0, -60, -60, -60, -60, -60, 0, 0, 0, + 0, 0, -60, -60, -60, 0, 0, -60, -60, -60, + 0, -60, 0, 0, 0, -60, -60, -60, -60, -60, + -60, -60, -60, 0, 18, 0, 0, -60, 0, 0, + -60, -60, -60, -60, -60, -60, -60, -60, -60, -60, + 0, -60, -60, -60, -60, -60, 0, -60, -60, 54, + -60, 0, 4, 5, 6, 7, 8, 9, 0, 0, + 0, 0, 0, 10, 0, 0, 0, 11, 0, 0, + 0, 12, 13, 0, 0, 0, 14, 0, 15, 16, + 17, 0, 0, 0, 0, 211, 211, 0, 0, 0, + 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 19, 0, 0, 0, 0, 0, 20, 21, + 0, 0, 22, 0, 55, 23, 57, 24, 0, 4, + 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, + 10, 0, 0, 0, 11, 0, 0, 0, 12, 13, + 0, 0, 0, 14, 0, 15, 16, 17, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, + 0, 0, 0, 0, 0, 20, 21, 0, 0, 22, + 0, 0, 23, 204, 24, 0, 4, 5, 6, 7, + 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, + 0, 11, 0, 0, 0, 12, 13, 0, 0, 0, + 14, 0, 15, 16, 17, 0, 0, 0, 0, 91, + 92, 0, 0, 0, 18, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, + 0, 0, 20, 21, 0, 0, 22, 102, 103, 23, + 208, 24, 0, 4, 5, 6, 7, 8, 9, 105, + 106, 107, 108, 109, 110, 111, 0, 0, 11, 0, + 0, 0, 12, 13, 0, 0, 0, 14, 0, 0, + 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 19, 0, 0, 0, 0, 0, 20, + 21, 0, 59, 22, 0, 60, 23, 61, 24, 52, + 0, 0, 0, 0, 0, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 218, 0, 0, + 60, 0, 61, 0, 52, 81, 0, 0, 0, -153, + 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, + 72, 73, 74, 75, 76, 77, 78, 79, 80, 4, 5, 6, 7, 8, 9, 0, 0, 0, 18, 0, 10, 0, 0, 0, 11, 0, 0, 0, 12, 13, 0, 0, 0, 14, 0, 15, 16, 17, 0, 0, - 79, 0, 0, 0, -154, 0, 0, 18, 0, 0, + 81, 0, 0, 0, -153, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, - 0, 0, 0, 0, 0, 20, 21, 124, 0, 22, + 0, 0, 0, 0, 0, 20, 21, 126, 0, 22, 0, 0, 23, 0, 24, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 11, 0, 0, 0, 12, 13, 0, 0, 0, 14, @@ -1199,186 +1211,113 @@ static const yytype_int16 yytable[] = 7, 8, 9, 0, 0, 0, 0, 0, 10, 0, 0, 0, 11, 0, 0, 0, 12, 13, 0, 0, 0, 14, 0, 15, 16, 17, 0, 0, 0, 0, - 86, 87, 0, 0, 0, 18, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 89, 0, 19, 0, 0, - 0, 0, 0, 20, 21, 0, 0, 22, 97, 98, + 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, + 0, 0, 0, 20, 21, 0, 0, 22, 0, 0, 23, 0, 24, 4, 5, 6, 7, 8, 9, 0, - 102, 103, 104, 105, 106, 107, 108, 0, 11, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 12, 13, 0, 0, 0, 14, 0, 0, 16, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 0, 0, 20, - 21, 0, 224, 22, 0, 225, 23, 226, 24, 50, - 0, 0, 0, 0, 0, 60, 61, 62, 63, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 76, 77, 85, 86, 87, 88, 0, 0, 0, - 0, 0, 0, 18, 0, 0, 0, 0, 0, 89, - 90, 0, 0, 0, 0, 0, 91, 92, 93, 94, - 95, 96, 97, 98, 0, 227, 0, 85, 86, 87, - 88, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 0, 0, 89, 90, 0, 240, 0, 0, 241, - 91, 92, 93, 94, 95, 96, 97, 98, 0, 0, - 0, 85, 86, 87, 88, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 0, 0, 89, 90, 0, - 0, 0, 0, 139, 91, 92, 93, 94, 95, 96, - 97, 98, 0, 0, 0, 85, 86, 87, 88, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 0, - 0, 89, 90, 0, 0, 0, 0, 270, 91, 92, - 93, 94, 95, 96, 97, 98, 0, 0, 0, 85, - 86, 87, 88, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 0, 0, 89, 90, 0, 0, 0, - 0, 271, 91, 92, 93, 94, 95, 96, 97, 98, - 0, 0, 0, 85, 86, 87, 88, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 0, 0, 89, - 90, 0, 0, 0, 0, 294, 91, 92, 93, 94, - 95, 96, 97, 98, 0, 0, 85, 86, 87, 88, - 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 0, 89, 90, 0, 309, 0, 0, 310, 91, - 92, 93, 94, 95, 96, 97, 98, 0, 0, 85, - 86, 87, 88, 0, 99, 100, 101, 102, 103, 104, - 105, 106, 107, 108, 0, 89, 90, 0, 0, 0, - 0, 141, 91, 92, 93, 94, 95, 96, 97, 98, - 0, 0, 85, 86, 87, 88, 0, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 0, 89, 90, - 0, 0, 0, 0, 216, 91, 92, 93, 94, 95, - 96, 97, 98, 0, 0, 85, 86, 87, 88, 0, - 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, - 0, 89, 90, 0, 0, 0, 0, 287, 91, 92, - 93, 94, 95, 96, 97, 98, 0, 0, 85, 86, - 87, 88, 0, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 0, 89, 90, 0, 0, 0, 0, - 308, 91, 92, 93, 94, 95, 96, 97, 98, 0, - 0, 85, 86, 87, 88, 0, 99, 100, 101, 102, - 103, 104, 105, 106, 107, 108, 0, 89, 90, 0, - 0, 0, 0, 312, 91, 92, 93, 94, 95, 96, - 97, 98, 0, 85, 86, 87, 88, 0, 0, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 89, - 90, 0, 0, 109, 0, 0, 91, 92, 93, 94, - 95, 96, 97, 98, 0, 85, 86, 87, 88, 0, - 0, 99, 100, 101, 102, 103, 104, 105, 106, 107, - 108, 89, 90, 0, 0, 195, 0, 0, 91, 92, - 93, 94, 95, 96, 97, 98, 0, 85, 86, 87, - 88, 0, 0, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 89, 90, 0, 0, 245, 0, 0, - 91, 92, 93, 94, 95, 96, 97, 98, 0, 85, - 86, 87, 88, 0, 0, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 89, 90, 0, 0, 298, - 0, 0, 91, 92, 93, 94, 95, 96, 97, 98, - 0, 85, 86, 87, 88, 0, 0, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 89, 90, 0, - 0, 299, 0, 0, 91, 92, 93, 94, 95, 96, - 97, 98, 0, 0, 0, 0, 0, 0, 0, 99, - 100, 101, 102, 103, 104, 105, 106, 107, 108, 85, - 86, 87, 88, 302, 0, 0, 0, 0, 0, 0, - 248, 249, 0, 0, 250, 89, 90, 0, 0, 0, - 0, 0, 91, 92, 93, 94, 95, 96, 97, 98, - 0, 0, 0, 0, 0, 0, 0, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 85, 86, 87, - 88, 0, 0, 0, 0, 0, 0, 131, 0, 0, - 0, 0, 0, 89, 90, 0, 0, 0, 0, 0, - 91, 92, 93, 94, 95, 96, 97, 98, 0, 85, - 86, 87, 88, 0, 0, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 89, 90, 0, 0, 0, - 0, 0, 91, 92, 93, 94, 95, 96, 97, 98, - 0, 0, 0, 0, 256, 0, 0, 99, 100, 101, - 102, 103, 104, 105, 106, 107, 108, 85, 86, 87, - 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 296, 89, 90, 0, 0, 0, 0, 0, - 91, 92, 93, 94, 95, 96, 97, 98, 0, 0, - 0, 0, 0, 0, 0, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 85, 86, 87, 88, 0, - 0, 0, 0, 0, 0, 297, 0, 0, 0, 0, - 0, 89, 90, 0, 0, 0, 0, 0, 91, 92, - 93, 94, 95, 96, 97, 98, 0, 85, 86, 87, - 88, 0, 0, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 89, 90, 0, 0, 0, 0, 0, - 91, 92, 93, 94, 95, 96, 97, 98, 0, 85, - 86, 87, 88, 0, 0, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 89, 90, 0, 0, 0, - 0, 0, 91, 92, 93, 94, 95, 96, 97, 98, - 0, -155, 86, 87, 0, 0, 0, 0, 0, 101, - 102, 103, 104, 105, 106, 107, 108, 89, 90, 0, - 0, -155, -155, 0, -155, -155, -155, -155, -155, -155, - 97, 98, 0, 0, 0, 0, 0, 0, 0, 0, - 0, -155, 102, 103, 104, 105, 106, 107, 108, -155, - -155, 86, 87, 0, 0, 0, 0, 0, 0, 0, - 0, -155, -155, 104, 105, 106, 107, 108, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 97, - 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 102, 103, 104, 105, 106, 107, 108 + 21, 0, 224, 22, 0, 225, 23, 226, 24, 52, + 0, 0, 0, 0, 0, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 90, 91, 92, 93, 135, 0, 0, + 0, 0, 0, 18, 0, 0, 0, 0, 0, 94, + 95, 0, 0, 0, 0, 0, 96, 97, 98, 99, + 100, 101, 102, 103, 0, 227, 90, 91, 92, 93, + 0, 0, 0, 104, 105, 106, 107, 108, 109, 110, + 111, 0, 94, 95, 0, 0, 0, 0, 0, 96, + 97, 98, 99, 100, 101, 102, 103, 0, -154, 91, + 92, 0, 0, 0, 0, 0, 104, 105, 106, 107, + 108, 109, 110, 111, 94, 95, 0, 0, 0, 0, + 0, -154, -154, -154, -154, -154, -154, 102, 103, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -154, 105, + 106, 107, 108, 109, 110, 111 }; static const yytype_int16 yycheck[] = { - 1, 183, 6, 145, 146, 8, 148, 149, 8, 62, - 11, 49, 65, 14, 49, 20, 5, 49, 23, 33, - 21, 22, 12, 13, 49, 14, 31, 32, 63, 19, - 68, 63, 33, 68, 35, 36, 142, 16, 1, 42, - 0, 66, 42, 6, 64, 151, 43, 44, 59, 46, - 62, 42, 4, 65, 6, 17, 18, 61, 61, 4, - 4, 182, 6, 67, 5, 63, 64, 5, 132, 133, - 59, 60, 61, 14, 6, 69, 14, 48, 79, 55, - 56, 57, 264, 29, 85, 86, 87, 88, 89, 90, - 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, - 101, 102, 103, 104, 105, 106, 107, 108, 122, 5, - 115, 232, 254, 255, 1, 116, 59, 66, 59, 60, - 61, 59, 60, 61, 63, 65, 63, 63, 129, 63, - 131, 49, 59, 134, 135, 68, 257, 142, 259, 260, - 261, 69, 263, 14, 6, 266, 151, 41, 48, 41, - 59, 66, 59, 143, 64, 145, 146, 48, 148, 149, - 64, 63, 63, 59, 60, 61, 63, 41, 63, 34, - 63, 59, 122, 63, 59, 59, 32, 178, 183, 300, - 63, 59, 59, 63, 59, 246, 187, 1, 303, 190, - 4, 264, 6, -1, 8, 196, -1, 196, -1, -1, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, - -1, -1, -1, -1, -1, -1, 227, -1, 42, -1, - -1, -1, 233, -1, -1, -1, -1, -1, -1, 240, - -1, -1, -1, -1, -1, -1, -1, 248, 249, -1, - 64, 252, 253, -1, 68, -1, -1, -1, -1, 264, - -1, -1, -1, -1, 254, 255, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 276, -1, -1, -1, -1, - 0, 1, -1, -1, 4, 5, -1, -1, 8, -1, - 10, 11, 12, 13, 14, -1, 297, 298, 299, -1, - 20, 21, 22, -1, -1, 25, 26, 27, 309, 29, - -1, -1, -1, 33, 34, 35, 36, 37, 38, 39, - 40, -1, 42, -1, -1, 45, -1, -1, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, -1, 59, - 60, 61, 62, 63, -1, 65, 66, 1, 68, -1, - 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, - -1, 15, -1, -1, -1, 19, -1, -1, -1, 23, - 24, -1, -1, -1, 28, -1, 30, 31, 32, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 54, -1, -1, -1, -1, -1, 60, 61, -1, 63, - 64, -1, 66, 67, 1, 69, -1, 4, 5, 6, - 7, 8, 9, -1, -1, -1, -1, -1, 15, -1, - -1, -1, 19, -1, -1, -1, 23, 24, -1, -1, - -1, 28, -1, 30, 31, 32, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 42, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 54, -1, -1, - -1, -1, -1, 60, 61, -1, -1, 64, -1, 66, - 67, 1, 69, -1, 4, 5, 6, 7, 8, 9, - -1, -1, -1, -1, -1, 15, -1, -1, -1, 19, - -1, -1, -1, 23, 24, -1, -1, -1, 28, -1, - 30, 31, 32, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 42, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 54, -1, -1, -1, -1, -1, - 60, 61, -1, -1, 64, -1, -1, 67, 1, 69, - -1, 4, 5, 6, 7, 8, 9, -1, -1, -1, - -1, -1, 15, -1, -1, -1, 19, -1, -1, -1, - 23, 24, -1, -1, -1, 28, -1, 30, 31, 32, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 42, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 54, -1, -1, -1, -1, -1, 60, 61, -1, - -1, 64, -1, -1, 67, 1, 69, -1, 4, 5, - 6, 7, 8, 9, -1, -1, -1, -1, -1, 15, - -1, -1, -1, 19, -1, -1, -1, 23, 24, -1, - -1, -1, 28, -1, 30, 31, 32, -1, -1, -1, - -1, -1, -1, -1, -1, -1, 42, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, 54, -1, - -1, -1, -1, -1, 60, 61, -1, 1, 64, -1, - 4, 67, 6, 69, 8, -1, -1, -1, -1, -1, + 1, 20, 34, 6, 23, 183, 5, 25, 49, 184, + 11, 5, 20, 32, 33, 14, 16, 1, 19, 1, + 21, 22, 8, 8, 6, 66, 27, 11, 49, 63, + 48, 49, 0, 34, 68, 36, 37, 21, 22, 64, + 48, 49, 146, 147, 20, 149, 150, 68, 43, 44, + 34, 46, 36, 37, 232, 59, 42, 42, 61, 42, + 59, 60, 61, 4, 67, 59, 60, 61, 17, 18, + 48, 49, 48, 49, 6, 61, 48, 49, 69, 257, + 81, 259, 260, 261, 62, 263, 87, 88, 266, 264, + 29, 63, 124, 48, 66, 48, 49, 81, 117, 11, + 12, 48, 49, 87, 88, 1, 48, 49, 48, 49, + 66, 48, 49, 66, 26, 48, 49, 118, 63, 66, + 48, 49, 300, 124, 66, 62, 66, 39, 40, 62, + 131, 65, 133, 152, 118, 62, 137, 65, 65, 51, + 52, 53, 54, 55, 56, 57, 4, 131, 6, 133, + 254, 255, 1, 137, 59, 4, 5, 6, 7, 8, + 9, 63, 64, 48, 49, 184, 15, 48, 49, 63, + 19, 48, 49, 62, 23, 24, 65, 62, 179, 28, + 65, 30, 31, 32, 65, 48, 49, 188, 65, 63, + 191, 48, 49, 42, 63, 179, 197, 21, 22, 134, + 135, 25, 65, 68, 188, 54, 49, 191, 65, 48, + 49, 60, 61, 197, 63, 64, 69, 66, 67, 59, + 69, 48, 49, 62, 48, 49, 227, 48, 49, 4, + 45, 6, 233, 48, 49, 62, 55, 56, 57, 240, + 14, 62, 6, 227, 41, 264, 48, 248, 249, 233, + 59, 252, 253, 12, 13, 14, 240, 48, 49, 41, + 66, 59, 48, 64, 248, 249, 59, 63, 252, 253, + 64, 63, 41, 63, 63, 276, 63, 10, 11, 12, + 13, 14, 63, 63, 63, 63, 59, 59, 59, 59, + 35, 59, 276, 26, 27, 124, 297, 298, 299, 33, + 33, 34, 35, 36, 37, 38, 39, 40, 309, 197, + 246, 303, 264, 297, 298, 299, 152, 50, 51, 52, + 53, 54, 55, 56, 57, 309, 11, 12, -1, -1, + -1, 90, 91, 92, 93, 94, 95, 96, 97, 98, + 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, + 109, 110, 111, -1, 39, 40, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 51, 52, 53, 54, + 55, 56, 57, -1, -1, -1, -1, 136, -1, -1, + -1, -1, -1, -1, -1, 144, -1, 146, 147, -1, + 149, 150, 0, 1, -1, -1, 4, 5, -1, -1, + 8, -1, 10, 11, 12, 13, 14, -1, -1, -1, + -1, -1, 20, 21, 22, -1, -1, 25, 26, 27, + -1, 29, -1, -1, -1, 33, 34, 35, 36, 37, + 38, 39, 40, -1, 42, -1, -1, 45, -1, -1, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + -1, 59, 60, 61, 62, 63, -1, 65, 66, 1, + 68, -1, 4, 5, 6, 7, 8, 9, -1, -1, + -1, -1, -1, 15, -1, -1, -1, 19, -1, -1, + -1, 23, 24, -1, -1, -1, 28, -1, 30, 31, + 32, -1, -1, -1, -1, 254, 255, -1, -1, -1, + 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 54, -1, -1, -1, -1, -1, 60, 61, + -1, -1, 64, -1, 66, 67, 1, 69, -1, 4, + 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, + 15, -1, -1, -1, 19, -1, -1, -1, 23, 24, + -1, -1, -1, 28, -1, 30, 31, 32, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 42, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 54, + -1, -1, -1, -1, -1, 60, 61, -1, -1, 64, + -1, -1, 67, 1, 69, -1, 4, 5, 6, 7, + 8, 9, -1, -1, -1, -1, -1, 15, -1, -1, + -1, 19, -1, -1, -1, 23, 24, -1, -1, -1, + 28, -1, 30, 31, 32, -1, -1, -1, -1, 11, + 12, -1, -1, -1, 42, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 54, -1, -1, -1, + -1, -1, 60, 61, -1, -1, 64, 39, 40, 67, + 1, 69, -1, 4, 5, 6, 7, 8, 9, 51, + 52, 53, 54, 55, 56, 57, -1, -1, 19, -1, + -1, -1, 23, 24, -1, -1, -1, 28, -1, -1, + 31, 32, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 42, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 54, -1, -1, -1, -1, -1, 60, + 61, -1, 1, 64, -1, 4, 67, 6, 69, 8, + -1, -1, -1, -1, -1, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 42, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 1, -1, -1, + 4, -1, 6, -1, 8, 64, -1, -1, -1, 68, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 4, 5, 6, 7, 8, 9, -1, -1, -1, 42, -1, @@ -1404,11 +1343,11 @@ static const yytype_int16 yycheck[] = 7, 8, 9, -1, -1, -1, -1, -1, 15, -1, -1, -1, 19, -1, -1, -1, 23, 24, -1, -1, -1, 28, -1, 30, 31, 32, -1, -1, -1, -1, - 11, 12, -1, -1, -1, 42, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 26, -1, 54, -1, -1, - -1, -1, -1, 60, 61, -1, -1, 64, 39, 40, + -1, -1, -1, -1, -1, 42, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 54, -1, -1, + -1, -1, -1, 60, 61, -1, -1, 64, -1, -1, 67, -1, 69, 4, 5, 6, 7, 8, 9, -1, - 51, 52, 53, 54, 55, 56, 57, -1, 19, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 19, -1, -1, -1, 23, 24, -1, -1, -1, 28, -1, -1, 31, 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, 42, -1, -1, -1, -1, -1, -1, -1, -1, @@ -1416,101 +1355,18 @@ static const yytype_int16 yycheck[] = 61, -1, 1, 64, -1, 4, 67, 6, 69, 8, -1, -1, -1, -1, -1, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 10, 11, 12, 13, -1, -1, -1, + 29, 30, 31, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, 42, -1, -1, -1, -1, -1, 26, 27, -1, -1, -1, -1, -1, 33, 34, 35, 36, - 37, 38, 39, 40, -1, 64, -1, 10, 11, 12, - 13, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, -1, -1, 26, 27, -1, 63, -1, -1, 66, - 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, - -1, 10, 11, 12, 13, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, -1, -1, 26, 27, -1, - -1, -1, -1, 66, 33, 34, 35, 36, 37, 38, - 39, 40, -1, -1, -1, 10, 11, 12, 13, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, - -1, 26, 27, -1, -1, -1, -1, 66, 33, 34, - 35, 36, 37, 38, 39, 40, -1, -1, -1, 10, - 11, 12, 13, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, -1, -1, 26, 27, -1, -1, -1, - -1, 66, 33, 34, 35, 36, 37, 38, 39, 40, - -1, -1, -1, 10, 11, 12, 13, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, -1, -1, 26, - 27, -1, -1, -1, -1, 66, 33, 34, 35, 36, - 37, 38, 39, 40, -1, -1, 10, 11, 12, 13, - -1, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, -1, 26, 27, -1, 62, -1, -1, 65, 33, - 34, 35, 36, 37, 38, 39, 40, -1, -1, 10, - 11, 12, 13, -1, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, -1, 26, 27, -1, -1, -1, - -1, 65, 33, 34, 35, 36, 37, 38, 39, 40, - -1, -1, 10, 11, 12, 13, -1, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, -1, 26, 27, - -1, -1, -1, -1, 65, 33, 34, 35, 36, 37, - 38, 39, 40, -1, -1, 10, 11, 12, 13, -1, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - -1, 26, 27, -1, -1, -1, -1, 65, 33, 34, - 35, 36, 37, 38, 39, 40, -1, -1, 10, 11, - 12, 13, -1, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, -1, 26, 27, -1, -1, -1, -1, - 65, 33, 34, 35, 36, 37, 38, 39, 40, -1, - -1, 10, 11, 12, 13, -1, 48, 49, 50, 51, - 52, 53, 54, 55, 56, 57, -1, 26, 27, -1, - -1, -1, -1, 65, 33, 34, 35, 36, 37, 38, - 39, 40, -1, 10, 11, 12, 13, -1, -1, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 26, - 27, -1, -1, 62, -1, -1, 33, 34, 35, 36, - 37, 38, 39, 40, -1, 10, 11, 12, 13, -1, - -1, 48, 49, 50, 51, 52, 53, 54, 55, 56, - 57, 26, 27, -1, -1, 62, -1, -1, 33, 34, - 35, 36, 37, 38, 39, 40, -1, 10, 11, 12, - 13, -1, -1, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 26, 27, -1, -1, 62, -1, -1, - 33, 34, 35, 36, 37, 38, 39, 40, -1, 10, - 11, 12, 13, -1, -1, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 26, 27, -1, -1, 62, - -1, -1, 33, 34, 35, 36, 37, 38, 39, 40, - -1, 10, 11, 12, 13, -1, -1, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 26, 27, -1, - -1, 62, -1, -1, 33, 34, 35, 36, 37, 38, - 39, 40, -1, -1, -1, -1, -1, -1, -1, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 10, - 11, 12, 13, 62, -1, -1, -1, -1, -1, -1, - 21, 22, -1, -1, 25, 26, 27, -1, -1, -1, - -1, -1, 33, 34, 35, 36, 37, 38, 39, 40, - -1, -1, -1, -1, -1, -1, -1, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 10, 11, 12, - 13, -1, -1, -1, -1, -1, -1, 20, -1, -1, - -1, -1, -1, 26, 27, -1, -1, -1, -1, -1, - 33, 34, 35, 36, 37, 38, 39, 40, -1, 10, - 11, 12, 13, -1, -1, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 26, 27, -1, -1, -1, - -1, -1, 33, 34, 35, 36, 37, 38, 39, 40, - -1, -1, -1, -1, 45, -1, -1, 48, 49, 50, - 51, 52, 53, 54, 55, 56, 57, 10, 11, 12, - 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, 25, 26, 27, -1, -1, -1, -1, -1, - 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, - -1, -1, -1, -1, -1, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 10, 11, 12, 13, -1, - -1, -1, -1, -1, -1, 20, -1, -1, -1, -1, - -1, 26, 27, -1, -1, -1, -1, -1, 33, 34, - 35, 36, 37, 38, 39, 40, -1, 10, 11, 12, - 13, -1, -1, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 26, 27, -1, -1, -1, -1, -1, - 33, 34, 35, 36, 37, 38, 39, 40, -1, 10, - 11, 12, 13, -1, -1, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 26, 27, -1, -1, -1, - -1, -1, 33, 34, 35, 36, 37, 38, 39, 40, - -1, 10, 11, 12, -1, -1, -1, -1, -1, 50, - 51, 52, 53, 54, 55, 56, 57, 26, 27, -1, - -1, 11, 12, -1, 33, 34, 35, 36, 37, 38, - 39, 40, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 50, 51, 52, 53, 54, 55, 56, 57, 39, - 40, 11, 12, -1, -1, -1, -1, -1, -1, -1, - -1, 51, 52, 53, 54, 55, 56, 57, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, - 40, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 51, 52, 53, 54, 55, 56, 57 + 37, 38, 39, 40, -1, 64, 10, 11, 12, 13, + -1, -1, -1, 50, 51, 52, 53, 54, 55, 56, + 57, -1, 26, 27, -1, -1, -1, -1, -1, 33, + 34, 35, 36, 37, 38, 39, 40, -1, 10, 11, + 12, -1, -1, -1, -1, -1, 50, 51, 52, 53, + 54, 55, 56, 57, 26, 27, -1, -1, -1, -1, + -1, 33, 34, 35, 36, 37, 38, 39, 40, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 50, 51, + 52, 53, 54, 55, 56, 57 }; /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of @@ -1519,35 +1375,35 @@ static const yytype_int8 yystos[] = { 0, 16, 71, 72, 4, 5, 6, 7, 8, 9, 15, 19, 23, 24, 28, 30, 31, 32, 42, 54, - 60, 61, 64, 67, 69, 75, 79, 82, 83, 87, - 0, 17, 18, 73, 76, 77, 64, 59, 42, 4, - 75, 87, 87, 75, 6, 1, 6, 87, 1, 4, - 8, 83, 1, 66, 75, 1, 75, 1, 4, 6, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 64, - 83, 96, 97, 98, 69, 10, 11, 12, 13, 26, - 27, 33, 34, 35, 36, 37, 38, 39, 40, 48, - 49, 50, 51, 52, 53, 54, 55, 56, 57, 62, - 75, 84, 5, 14, 59, 60, 61, 78, 83, 78, - 74, 75, 79, 73, 62, 75, 75, 88, 89, 63, - 64, 20, 14, 14, 29, 48, 1, 59, 66, 66, - 65, 65, 49, 63, 68, 63, 63, 75, 63, 63, - 68, 49, 69, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 43, 44, 46, - 59, 6, 61, 67, 90, 91, 92, 61, 83, 1, - 63, 66, 75, 14, 74, 62, 62, 65, 75, 4, - 6, 80, 81, 1, 75, 91, 91, 1, 75, 75, - 1, 97, 86, 87, 86, 86, 65, 86, 86, 97, - 6, 75, 92, 93, 1, 4, 6, 64, 83, 94, + 60, 61, 64, 67, 69, 75, 76, 80, 83, 84, + 87, 0, 17, 18, 73, 77, 78, 64, 59, 42, + 4, 75, 76, 87, 76, 76, 6, 1, 6, 87, + 1, 4, 8, 84, 1, 66, 75, 1, 75, 1, + 4, 6, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 64, 84, 96, 97, 98, 69, 48, 49, 62, + 10, 11, 12, 13, 26, 27, 33, 34, 35, 36, + 37, 38, 39, 40, 50, 51, 52, 53, 54, 55, + 56, 57, 75, 85, 5, 14, 59, 60, 61, 79, + 84, 79, 74, 75, 80, 73, 62, 75, 75, 88, + 89, 63, 64, 20, 14, 14, 29, 48, 1, 59, + 66, 66, 65, 65, 63, 68, 63, 63, 75, 63, + 63, 68, 49, 69, 75, 75, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 43, 44, + 46, 59, 6, 61, 67, 90, 91, 92, 61, 84, + 1, 63, 66, 75, 14, 74, 62, 62, 65, 75, + 4, 6, 81, 82, 1, 75, 91, 91, 1, 76, + 75, 76, 99, 99, 99, 65, 99, 99, 1, 97, + 6, 75, 92, 93, 1, 4, 6, 64, 84, 94, 95, 96, 41, 48, 66, 75, 59, 66, 75, 59, 63, 66, 4, 6, 89, 62, 62, 65, 21, 22, - 25, 85, 64, 64, 48, 63, 45, 49, 66, 63, + 25, 86, 64, 64, 48, 63, 45, 49, 66, 63, 63, 63, 75, 63, 49, 68, 63, 92, 75, 59, - 66, 66, 66, 75, 59, 81, 63, 75, 75, 75, - 75, 86, 86, 92, 92, 92, 92, 65, 92, 95, + 66, 66, 66, 75, 59, 82, 63, 75, 75, 75, + 75, 99, 99, 92, 92, 92, 92, 65, 92, 95, 92, 59, 59, 59, 66, 75, 25, 20, 62, 62, - 63, 59, 62, 75, 75, 75, 92, 85, 65, 62, + 63, 59, 62, 75, 75, 75, 92, 86, 65, 62, 65, 75, 65 }; @@ -1555,44 +1411,44 @@ static const yytype_int8 yystos[] = static const yytype_int8 yyr1[] = { 0, 70, 71, 71, 72, 72, 73, 73, 74, 74, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, - 75, 75, 75, 75, 75, 75, 75, 75, 76, 76, - 77, 77, 77, 78, 79, 79, 80, 80, 81, 81, - 82, 82, 83, 84, 84, 84, 85, 85, 85, 86, - 86, 87, 87, 87, 87, 87, 87, 87, 87, 87, + 75, 75, 75, 75, 75, 75, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 77, + 77, 78, 78, 78, 79, 80, 80, 81, 81, 82, + 82, 83, 83, 84, 85, 85, 85, 86, 86, 86, + 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, - 87, 87, 87, 87, 87, 88, 88, 89, 90, 90, - 91, 91, 92, 92, 92, 93, 93, 94, 94, 95, - 95, 95, 95, 95, 95, 95, 96, 96, 96, 96, + 87, 87, 87, 87, 88, 88, 89, 90, 90, 91, + 91, 92, 92, 92, 93, 93, 94, 94, 95, 95, + 95, 95, 95, 95, 95, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, - 96, 96, 96, 96, 97, 97, 97, 97, 98, 98, - 98, 98, 98, 98, 98, 98, 98, 98, 98 + 96, 96, 96, 97, 97, 97, 98, 98, 98, 98, + 98, 98, 98, 98, 98, 98, 98, 99, 99 }; /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ static const yytype_int8 yyr2[] = { 0, 2, 3, 3, 0, 3, 0, 2, 0, 2, - 2, 5, 4, 3, 3, 3, 3, 3, 3, 3, + 2, 5, 4, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 1, 2, 3, - 4, 4, 2, 1, 5, 8, 1, 3, 1, 1, - 2, 1, 3, 0, 2, 4, 5, 3, 1, 3, - 1, 1, 1, 2, 2, 3, 2, 4, 3, 2, - 1, 3, 2, 2, 3, 5, 4, 6, 5, 4, - 3, 5, 4, 7, 6, 6, 6, 5, 5, 2, - 1, 1, 1, 2, 3, 3, 2, 3, 9, 11, - 9, 5, 4, 4, 4, 2, 4, 1, 1, 1, - 4, 3, 3, 4, 3, 1, 3, 1, 3, 1, - 3, 1, 1, 3, 3, 1, 3, 1, 3, 1, - 3, 3, 3, 3, 5, 3, 1, 1, 1, 1, + 3, 3, 3, 3, 3, 3, 3, 3, 1, 2, + 3, 4, 4, 2, 1, 5, 8, 1, 3, 1, + 1, 2, 1, 3, 0, 2, 4, 5, 3, 1, + 1, 1, 2, 2, 3, 2, 4, 3, 2, 1, + 3, 2, 2, 3, 5, 4, 6, 5, 4, 3, + 5, 4, 7, 6, 6, 6, 5, 5, 2, 1, + 1, 1, 2, 3, 3, 2, 3, 9, 11, 9, + 5, 4, 4, 4, 2, 4, 1, 1, 1, 4, + 3, 3, 4, 3, 1, 3, 1, 3, 1, 3, + 1, 1, 3, 3, 1, 3, 1, 3, 1, 3, + 3, 3, 3, 5, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 0, 1, 3, 3, 3, 3, - 3, 1, 3, 1, 1, 1, 1, 5, 3 + 1, 1, 1, 0, 1, 3, 3, 3, 3, 1, + 3, 1, 1, 1, 1, 5, 3, 3, 1 }; @@ -2162,199 +2018,205 @@ yydestruct (const char *yymsg, case YYSYMBOL_IDENT: /* IDENT */ #line 37 "src/parser.y" { jv_free(((*yyvaluep).literal)); } -#line 2166 "src/parser.c" +#line 2022 "src/parser.c" break; case YYSYMBOL_FIELD: /* FIELD */ #line 37 "src/parser.y" { jv_free(((*yyvaluep).literal)); } -#line 2172 "src/parser.c" +#line 2028 "src/parser.c" break; case YYSYMBOL_BINDING: /* BINDING */ #line 37 "src/parser.y" { jv_free(((*yyvaluep).literal)); } -#line 2178 "src/parser.c" +#line 2034 "src/parser.c" break; case YYSYMBOL_LITERAL: /* LITERAL */ #line 37 "src/parser.y" { jv_free(((*yyvaluep).literal)); } -#line 2184 "src/parser.c" +#line 2040 "src/parser.c" break; case YYSYMBOL_FORMAT: /* FORMAT */ #line 37 "src/parser.y" { jv_free(((*yyvaluep).literal)); } -#line 2190 "src/parser.c" +#line 2046 "src/parser.c" break; case YYSYMBOL_QQSTRING_TEXT: /* QQSTRING_TEXT */ #line 37 "src/parser.y" { jv_free(((*yyvaluep).literal)); } -#line 2196 "src/parser.c" +#line 2052 "src/parser.c" break; case YYSYMBOL_Module: /* Module */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2202 "src/parser.c" +#line 2058 "src/parser.c" break; case YYSYMBOL_Imports: /* Imports */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2208 "src/parser.c" +#line 2064 "src/parser.c" break; case YYSYMBOL_FuncDefs: /* FuncDefs */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2214 "src/parser.c" +#line 2070 "src/parser.c" break; - case YYSYMBOL_Exp: /* Exp */ + case YYSYMBOL_Query: /* Query */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2220 "src/parser.c" +#line 2076 "src/parser.c" + break; + + case YYSYMBOL_Expr: /* Expr */ +#line 38 "src/parser.y" + { block_free(((*yyvaluep).blk)); } +#line 2082 "src/parser.c" break; case YYSYMBOL_Import: /* Import */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2226 "src/parser.c" +#line 2088 "src/parser.c" break; case YYSYMBOL_ImportWhat: /* ImportWhat */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2232 "src/parser.c" +#line 2094 "src/parser.c" break; case YYSYMBOL_ImportFrom: /* ImportFrom */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2238 "src/parser.c" +#line 2100 "src/parser.c" break; case YYSYMBOL_FuncDef: /* FuncDef */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2244 "src/parser.c" +#line 2106 "src/parser.c" break; case YYSYMBOL_Params: /* Params */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2250 "src/parser.c" +#line 2112 "src/parser.c" break; case YYSYMBOL_Param: /* Param */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2256 "src/parser.c" +#line 2118 "src/parser.c" break; case YYSYMBOL_StringStart: /* StringStart */ #line 37 "src/parser.y" { jv_free(((*yyvaluep).literal)); } -#line 2262 "src/parser.c" +#line 2124 "src/parser.c" break; case YYSYMBOL_String: /* String */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2268 "src/parser.c" +#line 2130 "src/parser.c" break; case YYSYMBOL_QQString: /* QQString */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2274 "src/parser.c" +#line 2136 "src/parser.c" break; case YYSYMBOL_ElseBody: /* ElseBody */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2280 "src/parser.c" - break; - - case YYSYMBOL_ExpD: /* ExpD */ -#line 38 "src/parser.y" - { block_free(((*yyvaluep).blk)); } -#line 2286 "src/parser.c" +#line 2142 "src/parser.c" break; case YYSYMBOL_Term: /* Term */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2292 "src/parser.c" +#line 2148 "src/parser.c" break; case YYSYMBOL_Args: /* Args */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2298 "src/parser.c" +#line 2154 "src/parser.c" break; case YYSYMBOL_Arg: /* Arg */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2304 "src/parser.c" +#line 2160 "src/parser.c" break; case YYSYMBOL_RepPatterns: /* RepPatterns */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2310 "src/parser.c" +#line 2166 "src/parser.c" break; case YYSYMBOL_Patterns: /* Patterns */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2316 "src/parser.c" +#line 2172 "src/parser.c" break; case YYSYMBOL_Pattern: /* Pattern */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2322 "src/parser.c" +#line 2178 "src/parser.c" break; case YYSYMBOL_ArrayPats: /* ArrayPats */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2328 "src/parser.c" +#line 2184 "src/parser.c" break; case YYSYMBOL_ObjPats: /* ObjPats */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2334 "src/parser.c" +#line 2190 "src/parser.c" break; case YYSYMBOL_ObjPat: /* ObjPat */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2340 "src/parser.c" +#line 2196 "src/parser.c" break; case YYSYMBOL_Keyword: /* Keyword */ #line 37 "src/parser.y" { jv_free(((*yyvaluep).literal)); } -#line 2346 "src/parser.c" +#line 2202 "src/parser.c" + break; + + case YYSYMBOL_DictPairs: /* DictPairs */ +#line 38 "src/parser.y" + { block_free(((*yyvaluep).blk)); } +#line 2208 "src/parser.c" break; - case YYSYMBOL_MkDict: /* MkDict */ + case YYSYMBOL_DictPair: /* DictPair */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2352 "src/parser.c" +#line 2214 "src/parser.c" break; - case YYSYMBOL_MkDictPair: /* MkDictPair */ + case YYSYMBOL_DictExpr: /* DictExpr */ #line 38 "src/parser.y" { block_free(((*yyvaluep).blk)); } -#line 2358 "src/parser.c" +#line 2220 "src/parser.c" break; default: @@ -2657,12 +2519,12 @@ YYLTYPE yylloc = yyloc_default; YY_REDUCE_PRINT (yyn); switch (yyn) { - case 2: /* TopLevel: Module Imports Exp */ + case 2: /* TopLevel: Module Imports Query */ #line 290 "src/parser.y" - { + { *answer = BLOCK((yyvsp[-2].blk), (yyvsp[-1].blk), gen_op_simple(TOP), (yyvsp[0].blk)); } -#line 2666 "src/parser.c" +#line 2528 "src/parser.c" break; case 3: /* TopLevel: Module Imports FuncDefs */ @@ -2670,7 +2532,7 @@ YYLTYPE yylloc = yyloc_default; { *answer = BLOCK((yyvsp[-2].blk), (yyvsp[-1].blk), (yyvsp[0].blk)); } -#line 2674 "src/parser.c" +#line 2536 "src/parser.c" break; case 4: /* Module: %empty */ @@ -2678,12 +2540,12 @@ YYLTYPE yylloc = yyloc_default; { (yyval.blk) = gen_noop(); } -#line 2682 "src/parser.c" +#line 2544 "src/parser.c" break; - case 5: /* Module: "module" Exp ';' */ + case 5: /* Module: "module" Query ';' */ #line 301 "src/parser.y" - { + { if (!block_is_const((yyvsp[-1].blk))) { FAIL((yyloc), "Module metadata must be constant"); (yyval.blk) = gen_noop(); @@ -2696,7 +2558,7 @@ YYLTYPE yylloc = yyloc_default; (yyval.blk) = gen_module((yyvsp[-1].blk)); } } -#line 2700 "src/parser.c" +#line 2562 "src/parser.c" break; case 6: /* Imports: %empty */ @@ -2704,7 +2566,7 @@ YYLTYPE yylloc = yyloc_default; { (yyval.blk) = gen_noop(); } -#line 2708 "src/parser.c" +#line 2570 "src/parser.c" break; case 7: /* Imports: Import Imports */ @@ -2712,7 +2574,7 @@ YYLTYPE yylloc = yyloc_default; { (yyval.blk) = BLOCK((yyvsp[-1].blk), (yyvsp[0].blk)); } -#line 2716 "src/parser.c" +#line 2578 "src/parser.c" break; case 8: /* FuncDefs: %empty */ @@ -2720,7 +2582,7 @@ YYLTYPE yylloc = yyloc_default; { (yyval.blk) = gen_noop(); } -#line 2724 "src/parser.c" +#line 2586 "src/parser.c" break; case 9: /* FuncDefs: FuncDef FuncDefs */ @@ -2728,247 +2590,255 @@ YYLTYPE yylloc = yyloc_default; { (yyval.blk) = block_join((yyvsp[-1].blk), (yyvsp[0].blk)); } -#line 2732 "src/parser.c" +#line 2594 "src/parser.c" break; - case 10: /* Exp: FuncDef Exp */ -#line 332 "src/parser.y" - { + case 10: /* Query: FuncDef Query */ +#line 333 "src/parser.y" + { (yyval.blk) = block_bind_referenced((yyvsp[-1].blk), (yyvsp[0].blk), OP_IS_CALL_PSEUDO); } -#line 2740 "src/parser.c" +#line 2602 "src/parser.c" break; - case 11: /* Exp: Term "as" Patterns '|' Exp */ + case 11: /* Query: Term "as" Patterns '|' Query */ #line 336 "src/parser.y" - { + { (yyval.blk) = gen_destructure((yyvsp[-4].blk), (yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 2748 "src/parser.c" +#line 2610 "src/parser.c" break; - case 12: /* Exp: "label" BINDING '|' Exp */ -#line 340 "src/parser.y" - { + case 12: /* Query: "label" BINDING '|' Query */ +#line 339 "src/parser.y" + { jv v = jv_string_fmt("*label-%s", jv_string_value((yyvsp[-2].literal))); (yyval.blk) = gen_location((yyloc), locations, gen_label(jv_string_value(v), (yyvsp[0].blk))); jv_free((yyvsp[-2].literal)); jv_free(v); } -#line 2759 "src/parser.c" +#line 2621 "src/parser.c" break; - case 13: /* Exp: Exp '=' Exp */ -#line 347 "src/parser.y" - { - (yyval.blk) = gen_call("_assign", BLOCK(gen_lambda((yyvsp[-2].blk)), gen_lambda((yyvsp[0].blk)))); + case 13: /* Query: Query '|' Query */ +#line 345 "src/parser.y" + { + (yyval.blk) = block_join((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 2767 "src/parser.c" +#line 2629 "src/parser.c" break; - case 14: /* Exp: Exp "or" Exp */ -#line 351 "src/parser.y" - { - (yyval.blk) = gen_or((yyvsp[-2].blk), (yyvsp[0].blk)); + case 14: /* Query: Query ',' Query */ +#line 348 "src/parser.y" + { + (yyval.blk) = gen_both((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 2775 "src/parser.c" +#line 2637 "src/parser.c" break; - case 15: /* Exp: Exp "and" Exp */ -#line 355 "src/parser.y" - { - (yyval.blk) = gen_and((yyvsp[-2].blk), (yyvsp[0].blk)); + case 15: /* Query: Expr */ +#line 351 "src/parser.y" + { + (yyval.blk) = (yyvsp[0].blk); } -#line 2783 "src/parser.c" +#line 2645 "src/parser.c" break; - case 16: /* Exp: Exp "//" Exp */ -#line 359 "src/parser.y" - { + case 16: /* Expr: Expr "//" Expr */ +#line 357 "src/parser.y" + { (yyval.blk) = gen_definedor((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 2791 "src/parser.c" +#line 2653 "src/parser.c" break; - case 17: /* Exp: Exp "//=" Exp */ -#line 363 "src/parser.y" + case 17: /* Expr: Expr '=' Expr */ +#line 360 "src/parser.y" { - (yyval.blk) = gen_definedor_assign((yyvsp[-2].blk), (yyvsp[0].blk)); + (yyval.blk) = gen_call("_assign", BLOCK(gen_lambda((yyvsp[-2].blk)), gen_lambda((yyvsp[0].blk)))); } -#line 2799 "src/parser.c" +#line 2661 "src/parser.c" break; - case 18: /* Exp: Exp "|=" Exp */ -#line 367 "src/parser.y" - { - (yyval.blk) = gen_call("_modify", BLOCK(gen_lambda((yyvsp[-2].blk)), gen_lambda((yyvsp[0].blk)))); + case 18: /* Expr: Expr "or" Expr */ +#line 363 "src/parser.y" + { + (yyval.blk) = gen_or((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 2807 "src/parser.c" +#line 2669 "src/parser.c" break; - case 19: /* Exp: Exp '|' Exp */ -#line 371 "src/parser.y" - { - (yyval.blk) = block_join((yyvsp[-2].blk), (yyvsp[0].blk)); + case 19: /* Expr: Expr "and" Expr */ +#line 366 "src/parser.y" + { + (yyval.blk) = gen_and((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 2815 "src/parser.c" +#line 2677 "src/parser.c" break; - case 20: /* Exp: Exp ',' Exp */ -#line 375 "src/parser.y" - { - (yyval.blk) = gen_both((yyvsp[-2].blk), (yyvsp[0].blk)); + case 20: /* Expr: Expr "//=" Expr */ +#line 369 "src/parser.y" + { + (yyval.blk) = gen_definedor_assign((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 2823 "src/parser.c" +#line 2685 "src/parser.c" break; - case 21: /* Exp: Exp '+' Exp */ -#line 379 "src/parser.y" - { + case 21: /* Expr: Expr "|=" Expr */ +#line 372 "src/parser.y" + { + (yyval.blk) = gen_call("_modify", BLOCK(gen_lambda((yyvsp[-2].blk)), gen_lambda((yyvsp[0].blk)))); +} +#line 2693 "src/parser.c" + break; + + case 22: /* Expr: Expr '+' Expr */ +#line 375 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '+'); } -#line 2831 "src/parser.c" +#line 2701 "src/parser.c" break; - case 22: /* Exp: Exp "+=" Exp */ -#line 383 "src/parser.y" - { + case 23: /* Expr: Expr "+=" Expr */ +#line 378 "src/parser.y" + { (yyval.blk) = gen_update((yyvsp[-2].blk), (yyvsp[0].blk), '+'); } -#line 2839 "src/parser.c" +#line 2709 "src/parser.c" break; - case 23: /* Exp: Exp '-' Exp */ -#line 387 "src/parser.y" - { + case 24: /* Expr: Expr '-' Expr */ +#line 381 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '-'); } -#line 2847 "src/parser.c" +#line 2717 "src/parser.c" break; - case 24: /* Exp: Exp "-=" Exp */ -#line 391 "src/parser.y" - { + case 25: /* Expr: Expr "-=" Expr */ +#line 384 "src/parser.y" + { (yyval.blk) = gen_update((yyvsp[-2].blk), (yyvsp[0].blk), '-'); } -#line 2855 "src/parser.c" +#line 2725 "src/parser.c" break; - case 25: /* Exp: Exp '*' Exp */ -#line 395 "src/parser.y" - { + case 26: /* Expr: Expr '*' Expr */ +#line 387 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '*'); } -#line 2863 "src/parser.c" +#line 2733 "src/parser.c" break; - case 26: /* Exp: Exp "*=" Exp */ -#line 399 "src/parser.y" - { + case 27: /* Expr: Expr "*=" Expr */ +#line 390 "src/parser.y" + { (yyval.blk) = gen_update((yyvsp[-2].blk), (yyvsp[0].blk), '*'); } -#line 2871 "src/parser.c" +#line 2741 "src/parser.c" break; - case 27: /* Exp: Exp '/' Exp */ -#line 403 "src/parser.y" - { + case 28: /* Expr: Expr '/' Expr */ +#line 393 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '/'); } -#line 2879 "src/parser.c" +#line 2749 "src/parser.c" break; - case 28: /* Exp: Exp '%' Exp */ -#line 407 "src/parser.y" - { + case 29: /* Expr: Expr '%' Expr */ +#line 396 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '%'); } -#line 2887 "src/parser.c" +#line 2757 "src/parser.c" break; - case 29: /* Exp: Exp "/=" Exp */ -#line 411 "src/parser.y" - { + case 30: /* Expr: Expr "/=" Expr */ +#line 399 "src/parser.y" + { (yyval.blk) = gen_update((yyvsp[-2].blk), (yyvsp[0].blk), '/'); } -#line 2895 "src/parser.c" +#line 2765 "src/parser.c" break; - case 30: /* Exp: Exp "%=" Exp */ -#line 415 "src/parser.y" - { + case 31: /* Expr: Expr "%=" Expr */ +#line 402 "src/parser.y" + { (yyval.blk) = gen_update((yyvsp[-2].blk), (yyvsp[0].blk), '%'); } -#line 2903 "src/parser.c" +#line 2773 "src/parser.c" break; - case 31: /* Exp: Exp "==" Exp */ -#line 419 "src/parser.y" - { + case 32: /* Expr: Expr "==" Expr */ +#line 405 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), EQ); } -#line 2911 "src/parser.c" +#line 2781 "src/parser.c" break; - case 32: /* Exp: Exp "!=" Exp */ -#line 423 "src/parser.y" - { + case 33: /* Expr: Expr "!=" Expr */ +#line 408 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), NEQ); } -#line 2919 "src/parser.c" +#line 2789 "src/parser.c" break; - case 33: /* Exp: Exp '<' Exp */ -#line 427 "src/parser.y" - { + case 34: /* Expr: Expr '<' Expr */ +#line 411 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '<'); } -#line 2927 "src/parser.c" +#line 2797 "src/parser.c" break; - case 34: /* Exp: Exp '>' Exp */ -#line 431 "src/parser.y" - { + case 35: /* Expr: Expr '>' Expr */ +#line 414 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), '>'); } -#line 2935 "src/parser.c" +#line 2805 "src/parser.c" break; - case 35: /* Exp: Exp "<=" Exp */ -#line 435 "src/parser.y" - { + case 36: /* Expr: Expr "<=" Expr */ +#line 417 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), LESSEQ); } -#line 2943 "src/parser.c" +#line 2813 "src/parser.c" break; - case 36: /* Exp: Exp ">=" Exp */ -#line 439 "src/parser.y" - { + case 37: /* Expr: Expr ">=" Expr */ +#line 420 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-2].blk), (yyvsp[0].blk), GREATEREQ); } -#line 2951 "src/parser.c" +#line 2821 "src/parser.c" break; - case 37: /* Exp: Term */ -#line 443 "src/parser.y" + case 38: /* Expr: Term */ +#line 423 "src/parser.y" { (yyval.blk) = (yyvsp[0].blk); } -#line 2959 "src/parser.c" +#line 2829 "src/parser.c" break; - case 38: /* Import: ImportWhat ';' */ -#line 448 "src/parser.y" + case 39: /* Import: ImportWhat ';' */ +#line 429 "src/parser.y" { (yyval.blk) = (yyvsp[-1].blk); } -#line 2967 "src/parser.c" +#line 2837 "src/parser.c" break; - case 39: /* Import: ImportWhat Exp ';' */ -#line 451 "src/parser.y" - { + case 40: /* Import: ImportWhat Query ';' */ +#line 432 "src/parser.y" + { if (!block_is_const((yyvsp[-1].blk))) { FAIL((yyloc), "Module metadata must be constant"); (yyval.blk) = gen_noop(); @@ -2983,11 +2853,11 @@ YYLTYPE yylloc = yyloc_default; (yyval.blk) = gen_import_meta((yyvsp[-2].blk), (yyvsp[-1].blk)); } } -#line 2987 "src/parser.c" +#line 2857 "src/parser.c" break; - case 40: /* ImportWhat: "import" ImportFrom "as" BINDING */ -#line 468 "src/parser.y" + case 41: /* ImportWhat: "import" ImportFrom "as" BINDING */ +#line 449 "src/parser.y" { jv v = block_const((yyvsp[-2].blk)); // XXX Make gen_import take only blocks and the int is_data so we @@ -2997,11 +2867,11 @@ YYLTYPE yylloc = yyloc_default; jv_free((yyvsp[0].literal)); jv_free(v); } -#line 3001 "src/parser.c" +#line 2871 "src/parser.c" break; - case 41: /* ImportWhat: "import" ImportFrom "as" IDENT */ -#line 477 "src/parser.y" + case 42: /* ImportWhat: "import" ImportFrom "as" IDENT */ +#line 458 "src/parser.y" { jv v = block_const((yyvsp[-2].blk)); (yyval.blk) = gen_import(jv_string_value(v), jv_string_value((yyvsp[0].literal)), 0); @@ -3009,22 +2879,22 @@ YYLTYPE yylloc = yyloc_default; jv_free((yyvsp[0].literal)); jv_free(v); } -#line 3013 "src/parser.c" +#line 2883 "src/parser.c" break; - case 42: /* ImportWhat: "include" ImportFrom */ -#line 484 "src/parser.y" + case 43: /* ImportWhat: "include" ImportFrom */ +#line 465 "src/parser.y" { jv v = block_const((yyvsp[0].blk)); (yyval.blk) = gen_import(jv_string_value(v), NULL, 0); block_free((yyvsp[0].blk)); jv_free(v); } -#line 3024 "src/parser.c" +#line 2894 "src/parser.c" break; - case 43: /* ImportFrom: String */ -#line 492 "src/parser.y" + case 44: /* ImportFrom: String */ +#line 473 "src/parser.y" { if (!block_is_const((yyvsp[0].blk))) { FAIL((yyloc), "Import path must be constant"); @@ -3034,168 +2904,152 @@ YYLTYPE yylloc = yyloc_default; (yyval.blk) = (yyvsp[0].blk); } } -#line 3038 "src/parser.c" +#line 2908 "src/parser.c" break; - case 44: /* FuncDef: "def" IDENT ':' Exp ';' */ -#line 503 "src/parser.y" - { + case 45: /* FuncDef: "def" IDENT ':' Query ';' */ +#line 484 "src/parser.y" + { (yyval.blk) = gen_function(jv_string_value((yyvsp[-3].literal)), gen_noop(), (yyvsp[-1].blk)); jv_free((yyvsp[-3].literal)); } -#line 3047 "src/parser.c" +#line 2917 "src/parser.c" break; - case 45: /* FuncDef: "def" IDENT '(' Params ')' ':' Exp ';' */ -#line 508 "src/parser.y" - { + case 46: /* FuncDef: "def" IDENT '(' Params ')' ':' Query ';' */ +#line 489 "src/parser.y" + { (yyval.blk) = gen_function(jv_string_value((yyvsp[-6].literal)), (yyvsp[-4].blk), (yyvsp[-1].blk)); jv_free((yyvsp[-6].literal)); } -#line 3056 "src/parser.c" +#line 2926 "src/parser.c" break; - case 46: /* Params: Param */ -#line 514 "src/parser.y" + case 47: /* Params: Param */ +#line 495 "src/parser.y" { (yyval.blk) = (yyvsp[0].blk); } -#line 3064 "src/parser.c" +#line 2934 "src/parser.c" break; - case 47: /* Params: Params ';' Param */ -#line 517 "src/parser.y" + case 48: /* Params: Params ';' Param */ +#line 498 "src/parser.y" { (yyval.blk) = BLOCK((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 3072 "src/parser.c" +#line 2942 "src/parser.c" break; - case 48: /* Param: BINDING */ -#line 522 "src/parser.y" + case 49: /* Param: BINDING */ +#line 503 "src/parser.y" { (yyval.blk) = gen_param_regular(jv_string_value((yyvsp[0].literal))); jv_free((yyvsp[0].literal)); } -#line 3081 "src/parser.c" +#line 2951 "src/parser.c" break; - case 49: /* Param: IDENT */ -#line 526 "src/parser.y" + case 50: /* Param: IDENT */ +#line 507 "src/parser.y" { (yyval.blk) = gen_param(jv_string_value((yyvsp[0].literal))); jv_free((yyvsp[0].literal)); } -#line 3090 "src/parser.c" +#line 2960 "src/parser.c" break; - case 50: /* StringStart: FORMAT QQSTRING_START */ -#line 533 "src/parser.y" + case 51: /* StringStart: FORMAT QQSTRING_START */ +#line 514 "src/parser.y" { (yyval.literal) = (yyvsp[-1].literal); } -#line 3098 "src/parser.c" +#line 2968 "src/parser.c" break; - case 51: /* StringStart: QQSTRING_START */ -#line 536 "src/parser.y" + case 52: /* StringStart: QQSTRING_START */ +#line 517 "src/parser.y" { (yyval.literal) = jv_string("text"); } -#line 3106 "src/parser.c" +#line 2976 "src/parser.c" break; - case 52: /* String: StringStart QQString QQSTRING_END */ -#line 542 "src/parser.y" + case 53: /* String: StringStart QQString QQSTRING_END */ +#line 523 "src/parser.y" { (yyval.blk) = (yyvsp[-1].blk); jv_free((yyvsp[-2].literal)); } -#line 3115 "src/parser.c" +#line 2985 "src/parser.c" break; - case 53: /* QQString: %empty */ -#line 549 "src/parser.y" + case 54: /* QQString: %empty */ +#line 530 "src/parser.y" { (yyval.blk) = gen_const(jv_string("")); } -#line 3123 "src/parser.c" +#line 2993 "src/parser.c" break; - case 54: /* QQString: QQString QQSTRING_TEXT */ -#line 552 "src/parser.y" + case 55: /* QQString: QQString QQSTRING_TEXT */ +#line 533 "src/parser.y" { (yyval.blk) = gen_binop((yyvsp[-1].blk), gen_const((yyvsp[0].literal)), '+'); } -#line 3131 "src/parser.c" +#line 3001 "src/parser.c" break; - case 55: /* QQString: QQString QQSTRING_INTERP_START Exp QQSTRING_INTERP_END */ -#line 555 "src/parser.y" - { + case 56: /* QQString: QQString QQSTRING_INTERP_START Query QQSTRING_INTERP_END */ +#line 536 "src/parser.y" + { (yyval.blk) = gen_binop((yyvsp[-3].blk), gen_format((yyvsp[-1].blk), jv_copy((yyvsp[-4].literal))), '+'); } -#line 3139 "src/parser.c" +#line 3009 "src/parser.c" break; - case 56: /* ElseBody: "elif" Exp "then" Exp ElseBody */ -#line 561 "src/parser.y" - { + case 57: /* ElseBody: "elif" Query "then" Query ElseBody */ +#line 542 "src/parser.y" + { (yyval.blk) = gen_cond((yyvsp[-3].blk), (yyvsp[-1].blk), (yyvsp[0].blk)); } -#line 3147 "src/parser.c" +#line 3017 "src/parser.c" break; - case 57: /* ElseBody: "else" Exp "end" */ -#line 564 "src/parser.y" - { + case 58: /* ElseBody: "else" Query "end" */ +#line 545 "src/parser.y" + { (yyval.blk) = (yyvsp[-1].blk); } -#line 3155 "src/parser.c" +#line 3025 "src/parser.c" break; - case 58: /* ElseBody: "end" */ -#line 567 "src/parser.y" + case 59: /* ElseBody: "end" */ +#line 548 "src/parser.y" { (yyval.blk) = gen_noop(); } -#line 3163 "src/parser.c" +#line 3033 "src/parser.c" break; - case 59: /* ExpD: ExpD '|' ExpD */ -#line 572 "src/parser.y" - { - (yyval.blk) = block_join((yyvsp[-2].blk), (yyvsp[0].blk)); -} -#line 3171 "src/parser.c" - break; - - case 60: /* ExpD: Term */ -#line 575 "src/parser.y" - { - (yyval.blk) = (yyvsp[0].blk); -} -#line 3179 "src/parser.c" - break; - - case 61: /* Term: '.' */ -#line 581 "src/parser.y" + case 60: /* Term: '.' */ +#line 554 "src/parser.y" { (yyval.blk) = gen_noop(); } -#line 3187 "src/parser.c" +#line 3041 "src/parser.c" break; - case 62: /* Term: ".." */ -#line 584 "src/parser.y" + case 61: /* Term: ".." */ +#line 557 "src/parser.y" { (yyval.blk) = gen_call("recurse", gen_noop()); } -#line 3195 "src/parser.c" +#line 3049 "src/parser.c" break; - case 63: /* Term: "break" BINDING */ -#line 587 "src/parser.y" + case 62: /* Term: "break" BINDING */ +#line 560 "src/parser.y" { jv v = jv_string_fmt("*label-%s", jv_string_value((yyvsp[0].literal))); // impossible symbol (yyval.blk) = gen_location((yyloc), locations, @@ -3204,383 +3058,383 @@ YYLTYPE yylloc = yyloc_default; jv_free(v); jv_free((yyvsp[0].literal)); } -#line 3208 "src/parser.c" +#line 3062 "src/parser.c" break; - case 64: /* Term: "break" error */ -#line 595 "src/parser.y" + case 63: /* Term: "break" error */ +#line 568 "src/parser.y" { FAIL((yyloc), "break requires a label to break to"); (yyval.blk) = gen_noop(); } -#line 3217 "src/parser.c" +#line 3071 "src/parser.c" break; - case 65: /* Term: Term FIELD '?' */ -#line 599 "src/parser.y" + case 64: /* Term: Term FIELD '?' */ +#line 572 "src/parser.y" { (yyval.blk) = gen_index_opt((yyvsp[-2].blk), gen_const((yyvsp[-1].literal))); } -#line 3225 "src/parser.c" +#line 3079 "src/parser.c" break; - case 66: /* Term: FIELD '?' */ -#line 602 "src/parser.y" + case 65: /* Term: FIELD '?' */ +#line 575 "src/parser.y" { (yyval.blk) = gen_index_opt(gen_noop(), gen_const((yyvsp[-1].literal))); } -#line 3233 "src/parser.c" +#line 3087 "src/parser.c" break; - case 67: /* Term: Term '.' String '?' */ -#line 605 "src/parser.y" + case 66: /* Term: Term '.' String '?' */ +#line 578 "src/parser.y" { (yyval.blk) = gen_index_opt((yyvsp[-3].blk), (yyvsp[-1].blk)); } -#line 3241 "src/parser.c" +#line 3095 "src/parser.c" break; - case 68: /* Term: '.' String '?' */ -#line 608 "src/parser.y" + case 67: /* Term: '.' String '?' */ +#line 581 "src/parser.y" { (yyval.blk) = gen_index_opt(gen_noop(), (yyvsp[-1].blk)); } -#line 3249 "src/parser.c" +#line 3103 "src/parser.c" break; - case 69: /* Term: Term FIELD */ -#line 611 "src/parser.y" + case 68: /* Term: Term FIELD */ +#line 584 "src/parser.y" { (yyval.blk) = gen_index((yyvsp[-1].blk), gen_const((yyvsp[0].literal))); } -#line 3257 "src/parser.c" +#line 3111 "src/parser.c" break; - case 70: /* Term: FIELD */ -#line 614 "src/parser.y" + case 69: /* Term: FIELD */ +#line 587 "src/parser.y" { (yyval.blk) = gen_index(gen_noop(), gen_const((yyvsp[0].literal))); } -#line 3265 "src/parser.c" +#line 3119 "src/parser.c" break; - case 71: /* Term: Term '.' String */ -#line 617 "src/parser.y" + case 70: /* Term: Term '.' String */ +#line 590 "src/parser.y" { (yyval.blk) = gen_index((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 3273 "src/parser.c" +#line 3127 "src/parser.c" break; - case 72: /* Term: '.' String */ -#line 620 "src/parser.y" + case 71: /* Term: '.' String */ +#line 593 "src/parser.y" { (yyval.blk) = gen_index(gen_noop(), (yyvsp[0].blk)); } -#line 3281 "src/parser.c" +#line 3135 "src/parser.c" break; - case 73: /* Term: '.' error */ -#line 623 "src/parser.y" + case 72: /* Term: '.' error */ +#line 596 "src/parser.y" { FAIL((yyloc), "try .[\"field\"] instead of .field for unusually named fields"); (yyval.blk) = gen_noop(); } -#line 3290 "src/parser.c" +#line 3144 "src/parser.c" break; - case 74: /* Term: '.' IDENT error */ -#line 627 "src/parser.y" + case 73: /* Term: '.' IDENT error */ +#line 600 "src/parser.y" { jv_free((yyvsp[-1].literal)); FAIL((yyloc), "try .[\"field\"] instead of .field for unusually named fields"); (yyval.blk) = gen_noop(); } -#line 3300 "src/parser.c" +#line 3154 "src/parser.c" break; - case 75: /* Term: Term '[' Exp ']' '?' */ -#line 633 "src/parser.y" - { + case 74: /* Term: Term '[' Query ']' '?' */ +#line 606 "src/parser.y" + { (yyval.blk) = gen_index_opt((yyvsp[-4].blk), (yyvsp[-2].blk)); } -#line 3308 "src/parser.c" +#line 3162 "src/parser.c" break; - case 76: /* Term: Term '[' Exp ']' */ -#line 636 "src/parser.y" - { + case 75: /* Term: Term '[' Query ']' */ +#line 609 "src/parser.y" + { (yyval.blk) = gen_index((yyvsp[-3].blk), (yyvsp[-1].blk)); } -#line 3316 "src/parser.c" +#line 3170 "src/parser.c" break; - case 77: /* Term: Term '.' '[' Exp ']' '?' */ -#line 639 "src/parser.y" - { + case 76: /* Term: Term '.' '[' Query ']' '?' */ +#line 612 "src/parser.y" + { (yyval.blk) = gen_index_opt((yyvsp[-5].blk), (yyvsp[-2].blk)); } -#line 3324 "src/parser.c" +#line 3178 "src/parser.c" break; - case 78: /* Term: Term '.' '[' Exp ']' */ -#line 642 "src/parser.y" - { + case 77: /* Term: Term '.' '[' Query ']' */ +#line 615 "src/parser.y" + { (yyval.blk) = gen_index((yyvsp[-4].blk), (yyvsp[-1].blk)); } -#line 3332 "src/parser.c" +#line 3186 "src/parser.c" break; - case 79: /* Term: Term '[' ']' '?' */ -#line 645 "src/parser.y" + case 78: /* Term: Term '[' ']' '?' */ +#line 618 "src/parser.y" { (yyval.blk) = block_join((yyvsp[-3].blk), gen_op_simple(EACH_OPT)); } -#line 3340 "src/parser.c" +#line 3194 "src/parser.c" break; - case 80: /* Term: Term '[' ']' */ -#line 648 "src/parser.y" + case 79: /* Term: Term '[' ']' */ +#line 621 "src/parser.y" { (yyval.blk) = block_join((yyvsp[-2].blk), gen_op_simple(EACH)); } -#line 3348 "src/parser.c" +#line 3202 "src/parser.c" break; - case 81: /* Term: Term '.' '[' ']' '?' */ -#line 651 "src/parser.y" + case 80: /* Term: Term '.' '[' ']' '?' */ +#line 624 "src/parser.y" { (yyval.blk) = block_join((yyvsp[-4].blk), gen_op_simple(EACH_OPT)); } -#line 3356 "src/parser.c" +#line 3210 "src/parser.c" break; - case 82: /* Term: Term '.' '[' ']' */ -#line 654 "src/parser.y" + case 81: /* Term: Term '.' '[' ']' */ +#line 627 "src/parser.y" { (yyval.blk) = block_join((yyvsp[-3].blk), gen_op_simple(EACH)); } -#line 3364 "src/parser.c" +#line 3218 "src/parser.c" break; - case 83: /* Term: Term '[' Exp ':' Exp ']' '?' */ -#line 657 "src/parser.y" - { + case 82: /* Term: Term '[' Query ':' Query ']' '?' */ +#line 630 "src/parser.y" + { (yyval.blk) = gen_slice_index((yyvsp[-6].blk), (yyvsp[-4].blk), (yyvsp[-2].blk), INDEX_OPT); } -#line 3372 "src/parser.c" +#line 3226 "src/parser.c" break; - case 84: /* Term: Term '[' Exp ':' ']' '?' */ -#line 660 "src/parser.y" - { + case 83: /* Term: Term '[' Query ':' ']' '?' */ +#line 633 "src/parser.y" + { (yyval.blk) = gen_slice_index((yyvsp[-5].blk), (yyvsp[-3].blk), gen_const(jv_null()), INDEX_OPT); } -#line 3380 "src/parser.c" +#line 3234 "src/parser.c" break; - case 85: /* Term: Term '[' ':' Exp ']' '?' */ -#line 663 "src/parser.y" - { + case 84: /* Term: Term '[' ':' Query ']' '?' */ +#line 636 "src/parser.y" + { (yyval.blk) = gen_slice_index((yyvsp[-5].blk), gen_const(jv_null()), (yyvsp[-2].blk), INDEX_OPT); } -#line 3388 "src/parser.c" +#line 3242 "src/parser.c" break; - case 86: /* Term: Term '[' Exp ':' Exp ']' */ -#line 666 "src/parser.y" - { + case 85: /* Term: Term '[' Query ':' Query ']' */ +#line 639 "src/parser.y" + { (yyval.blk) = gen_slice_index((yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk), INDEX); } -#line 3396 "src/parser.c" +#line 3250 "src/parser.c" break; - case 87: /* Term: Term '[' Exp ':' ']' */ -#line 669 "src/parser.y" - { + case 86: /* Term: Term '[' Query ':' ']' */ +#line 642 "src/parser.y" + { (yyval.blk) = gen_slice_index((yyvsp[-4].blk), (yyvsp[-2].blk), gen_const(jv_null()), INDEX); } -#line 3404 "src/parser.c" +#line 3258 "src/parser.c" break; - case 88: /* Term: Term '[' ':' Exp ']' */ -#line 672 "src/parser.y" - { + case 87: /* Term: Term '[' ':' Query ']' */ +#line 645 "src/parser.y" + { (yyval.blk) = gen_slice_index((yyvsp[-4].blk), gen_const(jv_null()), (yyvsp[-1].blk), INDEX); } -#line 3412 "src/parser.c" +#line 3266 "src/parser.c" break; - case 89: /* Term: Term '?' */ -#line 675 "src/parser.y" + case 88: /* Term: Term '?' */ +#line 648 "src/parser.y" { (yyval.blk) = gen_try((yyvsp[-1].blk), gen_op_simple(BACKTRACK)); } -#line 3420 "src/parser.c" +#line 3274 "src/parser.c" break; - case 90: /* Term: LITERAL */ -#line 678 "src/parser.y" + case 89: /* Term: LITERAL */ +#line 651 "src/parser.y" { (yyval.blk) = gen_const((yyvsp[0].literal)); } -#line 3428 "src/parser.c" +#line 3282 "src/parser.c" break; - case 91: /* Term: String */ -#line 681 "src/parser.y" + case 90: /* Term: String */ +#line 654 "src/parser.y" { (yyval.blk) = (yyvsp[0].blk); } -#line 3436 "src/parser.c" +#line 3290 "src/parser.c" break; - case 92: /* Term: FORMAT */ -#line 684 "src/parser.y" + case 91: /* Term: FORMAT */ +#line 657 "src/parser.y" { (yyval.blk) = gen_format(gen_noop(), (yyvsp[0].literal)); } -#line 3444 "src/parser.c" +#line 3298 "src/parser.c" break; - case 93: /* Term: '-' Term */ -#line 687 "src/parser.y" + case 92: /* Term: '-' Term */ +#line 660 "src/parser.y" { (yyval.blk) = BLOCK((yyvsp[0].blk), gen_call("_negate", gen_noop())); } -#line 3452 "src/parser.c" +#line 3306 "src/parser.c" break; - case 94: /* Term: '(' Exp ')' */ -#line 690 "src/parser.y" - { + case 93: /* Term: '(' Query ')' */ +#line 663 "src/parser.y" + { (yyval.blk) = (yyvsp[-1].blk); } -#line 3460 "src/parser.c" +#line 3314 "src/parser.c" break; - case 95: /* Term: '[' Exp ']' */ -#line 693 "src/parser.y" - { + case 94: /* Term: '[' Query ']' */ +#line 666 "src/parser.y" + { (yyval.blk) = gen_collect((yyvsp[-1].blk)); } -#line 3468 "src/parser.c" +#line 3322 "src/parser.c" break; - case 96: /* Term: '[' ']' */ -#line 696 "src/parser.y" + case 95: /* Term: '[' ']' */ +#line 669 "src/parser.y" { (yyval.blk) = gen_const(jv_array()); } -#line 3476 "src/parser.c" +#line 3330 "src/parser.c" break; - case 97: /* Term: '{' MkDict '}' */ -#line 699 "src/parser.y" - { + case 96: /* Term: '{' DictPairs '}' */ +#line 672 "src/parser.y" + { block o = gen_const_object((yyvsp[-1].blk)); if (o.first != NULL) (yyval.blk) = o; else (yyval.blk) = BLOCK(gen_subexp(gen_const(jv_object())), (yyvsp[-1].blk), gen_op_simple(POP)); } -#line 3488 "src/parser.c" +#line 3342 "src/parser.c" break; - case 98: /* Term: "reduce" Term "as" Patterns '(' Exp ';' Exp ')' */ -#line 706 "src/parser.y" - { + case 97: /* Term: "reduce" Expr "as" Patterns '(' Query ';' Query ')' */ +#line 679 "src/parser.y" + { (yyval.blk) = gen_reduce((yyvsp[-7].blk), (yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk)); } -#line 3496 "src/parser.c" +#line 3350 "src/parser.c" break; - case 99: /* Term: "foreach" Term "as" Patterns '(' Exp ';' Exp ';' Exp ')' */ -#line 709 "src/parser.y" - { + case 98: /* Term: "foreach" Expr "as" Patterns '(' Query ';' Query ';' Query ')' */ +#line 682 "src/parser.y" + { (yyval.blk) = gen_foreach((yyvsp[-9].blk), (yyvsp[-7].blk), (yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk)); } -#line 3504 "src/parser.c" +#line 3358 "src/parser.c" break; - case 100: /* Term: "foreach" Term "as" Patterns '(' Exp ';' Exp ')' */ -#line 712 "src/parser.y" - { + case 99: /* Term: "foreach" Expr "as" Patterns '(' Query ';' Query ')' */ +#line 685 "src/parser.y" + { (yyval.blk) = gen_foreach((yyvsp[-7].blk), (yyvsp[-5].blk), (yyvsp[-3].blk), (yyvsp[-1].blk), gen_noop()); } -#line 3512 "src/parser.c" +#line 3366 "src/parser.c" break; - case 101: /* Term: "if" Exp "then" Exp ElseBody */ -#line 715 "src/parser.y" - { + case 100: /* Term: "if" Query "then" Query ElseBody */ +#line 688 "src/parser.y" + { (yyval.blk) = gen_cond((yyvsp[-3].blk), (yyvsp[-1].blk), (yyvsp[0].blk)); } -#line 3520 "src/parser.c" +#line 3374 "src/parser.c" break; - case 102: /* Term: "if" Exp "then" error */ -#line 718 "src/parser.y" - { + case 101: /* Term: "if" Query "then" error */ +#line 691 "src/parser.y" + { FAIL((yyloc), "Possibly unterminated 'if' statement"); (yyval.blk) = (yyvsp[-2].blk); } -#line 3529 "src/parser.c" +#line 3383 "src/parser.c" break; - case 103: /* Term: "try" Exp "catch" Exp */ -#line 722 "src/parser.y" - { + case 102: /* Term: "try" Expr "catch" Expr */ +#line 695 "src/parser.y" + { (yyval.blk) = gen_try((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 3537 "src/parser.c" +#line 3391 "src/parser.c" break; - case 104: /* Term: "try" Exp "catch" error */ -#line 725 "src/parser.y" - { + case 103: /* Term: "try" Expr "catch" error */ +#line 698 "src/parser.y" + { FAIL((yyloc), "Possibly unterminated 'try' statement"); (yyval.blk) = (yyvsp[-2].blk); } -#line 3546 "src/parser.c" +#line 3400 "src/parser.c" break; - case 105: /* Term: "try" Exp */ -#line 729 "src/parser.y" - { + case 104: /* Term: "try" Expr */ +#line 702 "src/parser.y" + { (yyval.blk) = gen_try((yyvsp[0].blk), gen_op_simple(BACKTRACK)); } -#line 3554 "src/parser.c" +#line 3408 "src/parser.c" break; - case 106: /* Term: '$' '$' '$' BINDING */ -#line 747 "src/parser.y" + case 105: /* Term: '$' '$' '$' BINDING */ +#line 720 "src/parser.y" { (yyval.blk) = gen_location((yyloc), locations, gen_op_unbound(LOADVN, jv_string_value((yyvsp[0].literal)))); jv_free((yyvsp[0].literal)); } -#line 3563 "src/parser.c" +#line 3417 "src/parser.c" break; - case 107: /* Term: BINDING */ -#line 751 "src/parser.y" + case 106: /* Term: BINDING */ +#line 724 "src/parser.y" { (yyval.blk) = gen_location((yyloc), locations, gen_op_unbound(LOADV, jv_string_value((yyvsp[0].literal)))); jv_free((yyvsp[0].literal)); } -#line 3572 "src/parser.c" +#line 3426 "src/parser.c" break; - case 108: /* Term: "$__loc__" */ -#line 755 "src/parser.y" + case 107: /* Term: "$__loc__" */ +#line 728 "src/parser.y" { (yyval.blk) = gen_loc_object(&(yyloc), locations); } -#line 3580 "src/parser.c" +#line 3434 "src/parser.c" break; - case 109: /* Term: IDENT */ -#line 758 "src/parser.y" + case 108: /* Term: IDENT */ +#line 731 "src/parser.y" { const char *s = jv_string_value((yyvsp[0].literal)); if (strcmp(s, "false") == 0) @@ -3593,199 +3447,199 @@ YYLTYPE yylloc = yyloc_default; (yyval.blk) = gen_location((yyloc), locations, gen_call(s, gen_noop())); jv_free((yyvsp[0].literal)); } -#line 3597 "src/parser.c" +#line 3451 "src/parser.c" break; - case 110: /* Term: IDENT '(' Args ')' */ -#line 770 "src/parser.y" + case 109: /* Term: IDENT '(' Args ')' */ +#line 743 "src/parser.y" { (yyval.blk) = gen_call(jv_string_value((yyvsp[-3].literal)), (yyvsp[-1].blk)); (yyval.blk) = gen_location((yylsp[-3]), locations, (yyval.blk)); jv_free((yyvsp[-3].literal)); } -#line 3607 "src/parser.c" +#line 3461 "src/parser.c" break; - case 111: /* Term: '(' error ')' */ -#line 775 "src/parser.y" + case 110: /* Term: '(' error ')' */ +#line 748 "src/parser.y" { (yyval.blk) = gen_noop(); } -#line 3613 "src/parser.c" +#line 3467 "src/parser.c" break; - case 112: /* Term: '[' error ']' */ -#line 776 "src/parser.y" + case 111: /* Term: '[' error ']' */ +#line 749 "src/parser.y" { (yyval.blk) = gen_noop(); } -#line 3619 "src/parser.c" +#line 3473 "src/parser.c" break; - case 113: /* Term: Term '[' error ']' */ -#line 777 "src/parser.y" + case 112: /* Term: Term '[' error ']' */ +#line 750 "src/parser.y" { (yyval.blk) = (yyvsp[-3].blk); } -#line 3625 "src/parser.c" +#line 3479 "src/parser.c" break; - case 114: /* Term: '{' error '}' */ -#line 778 "src/parser.y" + case 113: /* Term: '{' error '}' */ +#line 751 "src/parser.y" { (yyval.blk) = gen_noop(); } -#line 3631 "src/parser.c" +#line 3485 "src/parser.c" break; - case 115: /* Args: Arg */ -#line 781 "src/parser.y" + case 114: /* Args: Arg */ +#line 754 "src/parser.y" { (yyval.blk) = (yyvsp[0].blk); } -#line 3639 "src/parser.c" +#line 3493 "src/parser.c" break; - case 116: /* Args: Args ';' Arg */ -#line 784 "src/parser.y" + case 115: /* Args: Args ';' Arg */ +#line 757 "src/parser.y" { (yyval.blk) = BLOCK((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 3647 "src/parser.c" +#line 3501 "src/parser.c" break; - case 117: /* Arg: Exp */ -#line 789 "src/parser.y" - { + case 116: /* Arg: Query */ +#line 762 "src/parser.y" + { (yyval.blk) = gen_lambda((yyvsp[0].blk)); } -#line 3655 "src/parser.c" +#line 3509 "src/parser.c" break; - case 118: /* RepPatterns: RepPatterns "?//" Pattern */ -#line 794 "src/parser.y" + case 117: /* RepPatterns: RepPatterns "?//" Pattern */ +#line 767 "src/parser.y" { (yyval.blk) = BLOCK((yyvsp[-2].blk), gen_destructure_alt((yyvsp[0].blk))); } -#line 3663 "src/parser.c" +#line 3517 "src/parser.c" break; - case 119: /* RepPatterns: Pattern */ -#line 797 "src/parser.y" + case 118: /* RepPatterns: Pattern */ +#line 770 "src/parser.y" { (yyval.blk) = gen_destructure_alt((yyvsp[0].blk)); } -#line 3671 "src/parser.c" +#line 3525 "src/parser.c" break; - case 120: /* Patterns: RepPatterns "?//" Pattern */ -#line 802 "src/parser.y" + case 119: /* Patterns: RepPatterns "?//" Pattern */ +#line 775 "src/parser.y" { (yyval.blk) = BLOCK((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 3679 "src/parser.c" +#line 3533 "src/parser.c" break; - case 121: /* Patterns: Pattern */ -#line 805 "src/parser.y" + case 120: /* Patterns: Pattern */ +#line 778 "src/parser.y" { (yyval.blk) = (yyvsp[0].blk); } -#line 3687 "src/parser.c" +#line 3541 "src/parser.c" break; - case 122: /* Pattern: BINDING */ -#line 810 "src/parser.y" + case 121: /* Pattern: BINDING */ +#line 783 "src/parser.y" { (yyval.blk) = gen_op_unbound(STOREV, jv_string_value((yyvsp[0].literal))); jv_free((yyvsp[0].literal)); } -#line 3696 "src/parser.c" +#line 3550 "src/parser.c" break; - case 123: /* Pattern: '[' ArrayPats ']' */ -#line 814 "src/parser.y" + case 122: /* Pattern: '[' ArrayPats ']' */ +#line 787 "src/parser.y" { (yyval.blk) = BLOCK((yyvsp[-1].blk), gen_op_simple(POP)); } -#line 3704 "src/parser.c" +#line 3558 "src/parser.c" break; - case 124: /* Pattern: '{' ObjPats '}' */ -#line 817 "src/parser.y" + case 123: /* Pattern: '{' ObjPats '}' */ +#line 790 "src/parser.y" { (yyval.blk) = BLOCK((yyvsp[-1].blk), gen_op_simple(POP)); } -#line 3712 "src/parser.c" +#line 3566 "src/parser.c" break; - case 125: /* ArrayPats: Pattern */ -#line 822 "src/parser.y" + case 124: /* ArrayPats: Pattern */ +#line 795 "src/parser.y" { (yyval.blk) = gen_array_matcher(gen_noop(), (yyvsp[0].blk)); } -#line 3720 "src/parser.c" +#line 3574 "src/parser.c" break; - case 126: /* ArrayPats: ArrayPats ',' Pattern */ -#line 825 "src/parser.y" + case 125: /* ArrayPats: ArrayPats ',' Pattern */ +#line 798 "src/parser.y" { (yyval.blk) = gen_array_matcher((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 3728 "src/parser.c" +#line 3582 "src/parser.c" break; - case 127: /* ObjPats: ObjPat */ -#line 830 "src/parser.y" + case 126: /* ObjPats: ObjPat */ +#line 803 "src/parser.y" { (yyval.blk) = (yyvsp[0].blk); } -#line 3736 "src/parser.c" +#line 3590 "src/parser.c" break; - case 128: /* ObjPats: ObjPats ',' ObjPat */ -#line 833 "src/parser.y" + case 127: /* ObjPats: ObjPats ',' ObjPat */ +#line 806 "src/parser.y" { (yyval.blk) = BLOCK((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 3744 "src/parser.c" +#line 3598 "src/parser.c" break; - case 129: /* ObjPat: BINDING */ -#line 838 "src/parser.y" + case 128: /* ObjPat: BINDING */ +#line 811 "src/parser.y" { (yyval.blk) = gen_object_matcher(gen_const((yyvsp[0].literal)), gen_op_unbound(STOREV, jv_string_value((yyvsp[0].literal)))); } -#line 3752 "src/parser.c" +#line 3606 "src/parser.c" break; - case 130: /* ObjPat: BINDING ':' Pattern */ -#line 841 "src/parser.y" + case 129: /* ObjPat: BINDING ':' Pattern */ +#line 814 "src/parser.y" { (yyval.blk) = gen_object_matcher(gen_const((yyvsp[-2].literal)), BLOCK(gen_op_simple(DUP), gen_op_unbound(STOREV, jv_string_value((yyvsp[-2].literal))), (yyvsp[0].blk))); } -#line 3760 "src/parser.c" +#line 3614 "src/parser.c" break; - case 131: /* ObjPat: IDENT ':' Pattern */ -#line 844 "src/parser.y" + case 130: /* ObjPat: IDENT ':' Pattern */ +#line 817 "src/parser.y" { (yyval.blk) = gen_object_matcher(gen_const((yyvsp[-2].literal)), (yyvsp[0].blk)); } -#line 3768 "src/parser.c" +#line 3622 "src/parser.c" break; - case 132: /* ObjPat: Keyword ':' Pattern */ -#line 847 "src/parser.y" + case 131: /* ObjPat: Keyword ':' Pattern */ +#line 820 "src/parser.y" { (yyval.blk) = gen_object_matcher(gen_const((yyvsp[-2].literal)), (yyvsp[0].blk)); } -#line 3776 "src/parser.c" +#line 3630 "src/parser.c" break; - case 133: /* ObjPat: String ':' Pattern */ -#line 850 "src/parser.y" + case 132: /* ObjPat: String ':' Pattern */ +#line 823 "src/parser.y" { (yyval.blk) = gen_object_matcher((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 3784 "src/parser.c" +#line 3638 "src/parser.c" break; - case 134: /* ObjPat: '(' Exp ')' ':' Pattern */ -#line 853 "src/parser.y" - { + case 133: /* ObjPat: '(' Query ')' ':' Pattern */ +#line 826 "src/parser.y" + { jv msg = check_object_key((yyvsp[-3].blk)); if (jv_is_valid(msg)) { FAIL((yyloc), jv_string_value(msg)); @@ -3793,291 +3647,305 @@ YYLTYPE yylloc = yyloc_default; jv_free(msg); (yyval.blk) = gen_object_matcher((yyvsp[-3].blk), (yyvsp[0].blk)); } -#line 3797 "src/parser.c" +#line 3651 "src/parser.c" break; - case 135: /* ObjPat: error ':' Pattern */ -#line 861 "src/parser.y" + case 134: /* ObjPat: error ':' Pattern */ +#line 834 "src/parser.y" { FAIL((yyloc), "May need parentheses around object key expression"); (yyval.blk) = (yyvsp[0].blk); } -#line 3806 "src/parser.c" +#line 3660 "src/parser.c" break; - case 136: /* Keyword: "as" */ -#line 867 "src/parser.y" + case 135: /* Keyword: "as" */ +#line 840 "src/parser.y" { (yyval.literal) = jv_string("as"); } -#line 3814 "src/parser.c" +#line 3668 "src/parser.c" break; - case 137: /* Keyword: "def" */ -#line 870 "src/parser.y" + case 136: /* Keyword: "def" */ +#line 843 "src/parser.y" { (yyval.literal) = jv_string("def"); } -#line 3822 "src/parser.c" +#line 3676 "src/parser.c" break; - case 138: /* Keyword: "module" */ -#line 873 "src/parser.y" + case 137: /* Keyword: "module" */ +#line 846 "src/parser.y" { (yyval.literal) = jv_string("module"); } -#line 3830 "src/parser.c" +#line 3684 "src/parser.c" break; - case 139: /* Keyword: "import" */ -#line 876 "src/parser.y" + case 138: /* Keyword: "import" */ +#line 849 "src/parser.y" { (yyval.literal) = jv_string("import"); } -#line 3838 "src/parser.c" +#line 3692 "src/parser.c" break; - case 140: /* Keyword: "include" */ -#line 879 "src/parser.y" + case 139: /* Keyword: "include" */ +#line 852 "src/parser.y" { (yyval.literal) = jv_string("include"); } -#line 3846 "src/parser.c" +#line 3700 "src/parser.c" break; - case 141: /* Keyword: "if" */ -#line 882 "src/parser.y" + case 140: /* Keyword: "if" */ +#line 855 "src/parser.y" { (yyval.literal) = jv_string("if"); } -#line 3854 "src/parser.c" +#line 3708 "src/parser.c" break; - case 142: /* Keyword: "then" */ -#line 885 "src/parser.y" + case 141: /* Keyword: "then" */ +#line 858 "src/parser.y" { (yyval.literal) = jv_string("then"); } -#line 3862 "src/parser.c" +#line 3716 "src/parser.c" break; - case 143: /* Keyword: "else" */ -#line 888 "src/parser.y" + case 142: /* Keyword: "else" */ +#line 861 "src/parser.y" { (yyval.literal) = jv_string("else"); } -#line 3870 "src/parser.c" +#line 3724 "src/parser.c" break; - case 144: /* Keyword: "elif" */ -#line 891 "src/parser.y" + case 143: /* Keyword: "elif" */ +#line 864 "src/parser.y" { (yyval.literal) = jv_string("elif"); } -#line 3878 "src/parser.c" +#line 3732 "src/parser.c" break; - case 145: /* Keyword: "reduce" */ -#line 894 "src/parser.y" + case 144: /* Keyword: "reduce" */ +#line 867 "src/parser.y" { (yyval.literal) = jv_string("reduce"); } -#line 3886 "src/parser.c" +#line 3740 "src/parser.c" break; - case 146: /* Keyword: "foreach" */ -#line 897 "src/parser.y" + case 145: /* Keyword: "foreach" */ +#line 870 "src/parser.y" { (yyval.literal) = jv_string("foreach"); } -#line 3894 "src/parser.c" +#line 3748 "src/parser.c" break; - case 147: /* Keyword: "end" */ -#line 900 "src/parser.y" + case 146: /* Keyword: "end" */ +#line 873 "src/parser.y" { (yyval.literal) = jv_string("end"); } -#line 3902 "src/parser.c" +#line 3756 "src/parser.c" break; - case 148: /* Keyword: "and" */ -#line 903 "src/parser.y" + case 147: /* Keyword: "and" */ +#line 876 "src/parser.y" { (yyval.literal) = jv_string("and"); } -#line 3910 "src/parser.c" +#line 3764 "src/parser.c" break; - case 149: /* Keyword: "or" */ -#line 906 "src/parser.y" + case 148: /* Keyword: "or" */ +#line 879 "src/parser.y" { (yyval.literal) = jv_string("or"); } -#line 3918 "src/parser.c" +#line 3772 "src/parser.c" break; - case 150: /* Keyword: "try" */ -#line 909 "src/parser.y" + case 149: /* Keyword: "try" */ +#line 882 "src/parser.y" { (yyval.literal) = jv_string("try"); } -#line 3926 "src/parser.c" +#line 3780 "src/parser.c" break; - case 151: /* Keyword: "catch" */ -#line 912 "src/parser.y" + case 150: /* Keyword: "catch" */ +#line 885 "src/parser.y" { (yyval.literal) = jv_string("catch"); } -#line 3934 "src/parser.c" +#line 3788 "src/parser.c" break; - case 152: /* Keyword: "label" */ -#line 915 "src/parser.y" + case 151: /* Keyword: "label" */ +#line 888 "src/parser.y" { (yyval.literal) = jv_string("label"); } -#line 3942 "src/parser.c" +#line 3796 "src/parser.c" break; - case 153: /* Keyword: "break" */ -#line 918 "src/parser.y" + case 152: /* Keyword: "break" */ +#line 891 "src/parser.y" { (yyval.literal) = jv_string("break"); } -#line 3950 "src/parser.c" +#line 3804 "src/parser.c" break; - case 154: /* MkDict: %empty */ -#line 923 "src/parser.y" + case 153: /* DictPairs: %empty */ +#line 897 "src/parser.y" { - (yyval.blk)=gen_noop(); + (yyval.blk) = gen_noop(); } -#line 3958 "src/parser.c" +#line 3812 "src/parser.c" break; - case 155: /* MkDict: MkDictPair */ -#line 926 "src/parser.y" - { (yyval.blk) = (yyvsp[0].blk); } -#line 3964 "src/parser.c" - break; - - case 156: /* MkDict: MkDictPair ',' MkDict */ -#line 927 "src/parser.y" - { (yyval.blk)=block_join((yyvsp[-2].blk), (yyvsp[0].blk)); } -#line 3970 "src/parser.c" + case 154: /* DictPairs: DictPair */ +#line 900 "src/parser.y" + { + (yyval.blk) = (yyvsp[0].blk); +} +#line 3820 "src/parser.c" break; - case 157: /* MkDict: error ',' MkDict */ -#line 928 "src/parser.y" - { (yyval.blk) = (yyvsp[0].blk); } -#line 3976 "src/parser.c" + case 155: /* DictPairs: DictPair ',' DictPairs */ +#line 903 "src/parser.y" + { + (yyval.blk) = block_join((yyvsp[-2].blk), (yyvsp[0].blk)); +} +#line 3828 "src/parser.c" break; - case 158: /* MkDictPair: IDENT ':' ExpD */ -#line 931 "src/parser.y" - { + case 156: /* DictPair: IDENT ':' DictExpr */ +#line 908 "src/parser.y" + { (yyval.blk) = gen_dictpair(gen_const((yyvsp[-2].literal)), (yyvsp[0].blk)); - } -#line 3984 "src/parser.c" +} +#line 3836 "src/parser.c" break; - case 159: /* MkDictPair: Keyword ':' ExpD */ -#line 934 "src/parser.y" - { + case 157: /* DictPair: Keyword ':' DictExpr */ +#line 911 "src/parser.y" + { (yyval.blk) = gen_dictpair(gen_const((yyvsp[-2].literal)), (yyvsp[0].blk)); - } -#line 3992 "src/parser.c" +} +#line 3844 "src/parser.c" break; - case 160: /* MkDictPair: String ':' ExpD */ -#line 937 "src/parser.y" - { + case 158: /* DictPair: String ':' DictExpr */ +#line 914 "src/parser.y" + { (yyval.blk) = gen_dictpair((yyvsp[-2].blk), (yyvsp[0].blk)); - } -#line 4000 "src/parser.c" +} +#line 3852 "src/parser.c" break; - case 161: /* MkDictPair: String */ -#line 940 "src/parser.y" - { + case 159: /* DictPair: String */ +#line 917 "src/parser.y" + { (yyval.blk) = gen_dictpair((yyvsp[0].blk), BLOCK(gen_op_simple(POP), gen_op_simple(DUP2), gen_op_simple(DUP2), gen_op_simple(INDEX))); - } -#line 4009 "src/parser.c" +} +#line 3861 "src/parser.c" break; - case 162: /* MkDictPair: BINDING ':' ExpD */ -#line 944 "src/parser.y" - { + case 160: /* DictPair: BINDING ':' DictExpr */ +#line 921 "src/parser.y" + { (yyval.blk) = gen_dictpair(gen_location((yyloc), locations, gen_op_unbound(LOADV, jv_string_value((yyvsp[-2].literal)))), (yyvsp[0].blk)); jv_free((yyvsp[-2].literal)); - } -#line 4019 "src/parser.c" +} +#line 3871 "src/parser.c" break; - case 163: /* MkDictPair: BINDING */ -#line 949 "src/parser.y" - { + case 161: /* DictPair: BINDING */ +#line 926 "src/parser.y" + { (yyval.blk) = gen_dictpair(gen_const((yyvsp[0].literal)), gen_location((yyloc), locations, gen_op_unbound(LOADV, jv_string_value((yyvsp[0].literal))))); - } -#line 4028 "src/parser.c" +} +#line 3880 "src/parser.c" break; - case 164: /* MkDictPair: IDENT */ -#line 953 "src/parser.y" - { + case 162: /* DictPair: IDENT */ +#line 930 "src/parser.y" + { (yyval.blk) = gen_dictpair(gen_const(jv_copy((yyvsp[0].literal))), gen_index(gen_noop(), gen_const((yyvsp[0].literal)))); - } -#line 4037 "src/parser.c" +} +#line 3889 "src/parser.c" break; - case 165: /* MkDictPair: "$__loc__" */ -#line 957 "src/parser.y" - { + case 163: /* DictPair: "$__loc__" */ +#line 934 "src/parser.y" + { (yyval.blk) = gen_dictpair(gen_const(jv_string("__loc__")), gen_loc_object(&(yyloc), locations)); - } -#line 4046 "src/parser.c" +} +#line 3898 "src/parser.c" break; - case 166: /* MkDictPair: Keyword */ -#line 961 "src/parser.y" - { + case 164: /* DictPair: Keyword */ +#line 938 "src/parser.y" + { (yyval.blk) = gen_dictpair(gen_const(jv_copy((yyvsp[0].literal))), gen_index(gen_noop(), gen_const((yyvsp[0].literal)))); - } -#line 4055 "src/parser.c" +} +#line 3907 "src/parser.c" break; - case 167: /* MkDictPair: '(' Exp ')' ':' ExpD */ -#line 965 "src/parser.y" - { + case 165: /* DictPair: '(' Query ')' ':' DictExpr */ +#line 942 "src/parser.y" + { jv msg = check_object_key((yyvsp[-3].blk)); if (jv_is_valid(msg)) { FAIL((yyloc), jv_string_value(msg)); } jv_free(msg); (yyval.blk) = gen_dictpair((yyvsp[-3].blk), (yyvsp[0].blk)); - } -#line 4068 "src/parser.c" +} +#line 3920 "src/parser.c" break; - case 168: /* MkDictPair: error ':' ExpD */ -#line 973 "src/parser.y" - { + case 166: /* DictPair: error ':' DictExpr */ +#line 950 "src/parser.y" + { FAIL((yyloc), "May need parentheses around object key expression"); (yyval.blk) = (yyvsp[0].blk); - } -#line 4077 "src/parser.c" +} +#line 3929 "src/parser.c" + break; + + case 167: /* DictExpr: DictExpr '|' DictExpr */ +#line 956 "src/parser.y" + { + (yyval.blk) = block_join((yyvsp[-2].blk), (yyvsp[0].blk)); +} +#line 3937 "src/parser.c" + break; + + case 168: /* DictExpr: Expr */ +#line 959 "src/parser.y" + { + (yyval.blk) = (yyvsp[0].blk); +} +#line 3945 "src/parser.c" break; -#line 4081 "src/parser.c" +#line 3949 "src/parser.c" default: break; } @@ -4306,7 +4174,7 @@ YYLTYPE yylloc = yyloc_default; return yyresult; } -#line 977 "src/parser.y" +#line 962 "src/parser.y" int jq_parse(struct locfile* locations, block* answer) { diff --git a/src/parser.y b/src/parser.y index 075db4802e..297301716e 100644 --- a/src/parser.y +++ b/src/parser.y @@ -108,14 +108,14 @@ struct lexer_param; %left '+' '-' %left '*' '/' '%' %precedence NONOPT /* non-optional; rules for which a specialized - '?' rule should be preferred over Exp '?' */ -%precedence '?' '.' '[' FIELD "as" + '?' rule should be preferred over Expr '?' */ +%precedence '?' '.' '[' FIELD %precedence "try" %precedence "catch" -%type Exp Term -%type MkDict MkDictPair ExpD +%type Query Expr Term +%type DictPairs DictPair DictExpr %type ElseBody %type String QQString %type FuncDef FuncDefs @@ -287,7 +287,7 @@ static block gen_loc_object(location *loc, struct locfile *locations) { %% TopLevel: -Module Imports Exp { +Module Imports Query { *answer = BLOCK($1, $2, gen_op_simple(TOP), $3); } | Module Imports FuncDefs { @@ -298,7 +298,7 @@ Module: %empty { $$ = gen_noop(); } | -"module" Exp ';' { +"module" Query ';' { if (!block_is_const($2)) { FAIL(@$, "Module metadata must be constant"); $$ = gen_noop(); @@ -328,127 +328,108 @@ FuncDef FuncDefs { $$ = block_join($1, $2); } -Exp: -FuncDef Exp %prec FUNCDEF { + +Query: +FuncDef Query %prec FUNCDEF { $$ = block_bind_referenced($1, $2, OP_IS_CALL_PSEUDO); } | - -Term "as" Patterns '|' Exp { +Term "as" Patterns '|' Query { $$ = gen_destructure($1, $3, $5); } | - -"label" BINDING '|' Exp { +"label" BINDING '|' Query { jv v = jv_string_fmt("*label-%s", jv_string_value($2)); $$ = gen_location(@$, locations, gen_label(jv_string_value(v), $4)); jv_free($2); jv_free(v); } | +Query '|' Query { + $$ = block_join($1, $3); +} | +Query ',' Query { + $$ = gen_both($1, $3); +} | +Expr { + $$ = $1; +} -Exp '=' Exp { + +Expr: +Expr "//" Expr { + $$ = gen_definedor($1, $3); +} | +Expr '=' Expr { $$ = gen_call("_assign", BLOCK(gen_lambda($1), gen_lambda($3))); } | - -Exp "or" Exp { +Expr "or" Expr { $$ = gen_or($1, $3); } | - -Exp "and" Exp { +Expr "and" Expr { $$ = gen_and($1, $3); } | - -Exp "//" Exp { - $$ = gen_definedor($1, $3); -} | - -Exp "//=" Exp { +Expr "//=" Expr { $$ = gen_definedor_assign($1, $3); } | - -Exp "|=" Exp { +Expr "|=" Expr { $$ = gen_call("_modify", BLOCK(gen_lambda($1), gen_lambda($3))); } | - -Exp '|' Exp { - $$ = block_join($1, $3); -} | - -Exp ',' Exp { - $$ = gen_both($1, $3); -} | - -Exp '+' Exp { +Expr '+' Expr { $$ = gen_binop($1, $3, '+'); } | - -Exp "+=" Exp { +Expr "+=" Expr { $$ = gen_update($1, $3, '+'); } | - -Exp '-' Exp { +Expr '-' Expr { $$ = gen_binop($1, $3, '-'); } | - -Exp "-=" Exp { +Expr "-=" Expr { $$ = gen_update($1, $3, '-'); } | - -Exp '*' Exp { +Expr '*' Expr { $$ = gen_binop($1, $3, '*'); } | - -Exp "*=" Exp { +Expr "*=" Expr { $$ = gen_update($1, $3, '*'); } | - -Exp '/' Exp { +Expr '/' Expr { $$ = gen_binop($1, $3, '/'); } | - -Exp '%' Exp { +Expr '%' Expr { $$ = gen_binop($1, $3, '%'); } | - -Exp "/=" Exp { +Expr "/=" Expr { $$ = gen_update($1, $3, '/'); } | - -Exp SETMOD Exp { +Expr SETMOD Expr { $$ = gen_update($1, $3, '%'); } | - -Exp "==" Exp { +Expr "==" Expr { $$ = gen_binop($1, $3, EQ); } | - -Exp "!=" Exp { +Expr "!=" Expr { $$ = gen_binop($1, $3, NEQ); } | - -Exp '<' Exp { +Expr '<' Expr { $$ = gen_binop($1, $3, '<'); } | - -Exp '>' Exp { +Expr '>' Expr { $$ = gen_binop($1, $3, '>'); } | - -Exp "<=" Exp { +Expr "<=" Expr { $$ = gen_binop($1, $3, LESSEQ); } | - -Exp ">=" Exp { +Expr ">=" Expr { $$ = gen_binop($1, $3, GREATEREQ); } | - Term %prec NONOPT { $$ = $1; } + Import: ImportWhat ';' { $$ = $1; } | -ImportWhat Exp ';' { +ImportWhat Query ';' { if (!block_is_const($2)) { FAIL(@$, "Module metadata must be constant"); $$ = gen_noop(); @@ -500,12 +481,12 @@ String { } FuncDef: -"def" IDENT ':' Exp ';' { +"def" IDENT ':' Query ';' { $$ = gen_function(jv_string_value($2), gen_noop(), $4); jv_free($2); } | -"def" IDENT '(' Params ')' ':' Exp ';' { +"def" IDENT '(' Params ')' ':' Query ';' { $$ = gen_function(jv_string_value($2), $4, $7); jv_free($2); } @@ -552,30 +533,22 @@ QQString: QQString QQSTRING_TEXT { $$ = gen_binop($1, gen_const($2), '+'); } | -QQString QQSTRING_INTERP_START Exp QQSTRING_INTERP_END { +QQString QQSTRING_INTERP_START Query QQSTRING_INTERP_END { $$ = gen_binop($1, gen_format($3, jv_copy($0)), '+'); } ElseBody: -"elif" Exp "then" Exp ElseBody { +"elif" Query "then" Query ElseBody { $$ = gen_cond($2, $4, $5); } | -"else" Exp "end" { +"else" Query "end" { $$ = $2; } | "end" { $$ = gen_noop(); } -ExpD: -ExpD '|' ExpD { - $$ = block_join($1, $3); -} | -Term { - $$ = $1; -} - Term: '.' { @@ -630,16 +603,16 @@ Term '.' String %prec NONOPT { $$ = gen_noop(); } | /* FIXME: string literals */ -Term '[' Exp ']' '?' { +Term '[' Query ']' '?' { $$ = gen_index_opt($1, $3); } | -Term '[' Exp ']' %prec NONOPT { +Term '[' Query ']' %prec NONOPT { $$ = gen_index($1, $3); } | -Term '.' '[' Exp ']' '?' { +Term '.' '[' Query ']' '?' { $$ = gen_index_opt($1, $4); } | -Term '.' '[' Exp ']' %prec NONOPT { +Term '.' '[' Query ']' %prec NONOPT { $$ = gen_index($1, $4); } | Term '[' ']' '?' { @@ -654,22 +627,22 @@ Term '.' '[' ']' '?' { Term '.' '[' ']' %prec NONOPT { $$ = block_join($1, gen_op_simple(EACH)); } | -Term '[' Exp ':' Exp ']' '?' { +Term '[' Query ':' Query ']' '?' { $$ = gen_slice_index($1, $3, $5, INDEX_OPT); } | -Term '[' Exp ':' ']' '?' { +Term '[' Query ':' ']' '?' { $$ = gen_slice_index($1, $3, gen_const(jv_null()), INDEX_OPT); } | -Term '[' ':' Exp ']' '?' { +Term '[' ':' Query ']' '?' { $$ = gen_slice_index($1, gen_const(jv_null()), $4, INDEX_OPT); } | -Term '[' Exp ':' Exp ']' %prec NONOPT { +Term '[' Query ':' Query ']' %prec NONOPT { $$ = gen_slice_index($1, $3, $5, INDEX); } | -Term '[' Exp ':' ']' %prec NONOPT { +Term '[' Query ':' ']' %prec NONOPT { $$ = gen_slice_index($1, $3, gen_const(jv_null()), INDEX); } | -Term '[' ':' Exp ']' %prec NONOPT { +Term '[' ':' Query ']' %prec NONOPT { $$ = gen_slice_index($1, gen_const(jv_null()), $4, INDEX); } | Term '?' { @@ -687,46 +660,46 @@ FORMAT { '-' Term { $$ = BLOCK($2, gen_call("_negate", gen_noop())); } | -'(' Exp ')' { +'(' Query ')' { $$ = $2; } | -'[' Exp ']' { +'[' Query ']' { $$ = gen_collect($2); } | '[' ']' { $$ = gen_const(jv_array()); } | -'{' MkDict '}' { +'{' DictPairs '}' { block o = gen_const_object($2); if (o.first != NULL) $$ = o; else $$ = BLOCK(gen_subexp(gen_const(jv_object())), $2, gen_op_simple(POP)); } | -"reduce" Term "as" Patterns '(' Exp ';' Exp ')' { +"reduce" Expr "as" Patterns '(' Query ';' Query ')' { $$ = gen_reduce($2, $4, $6, $8); } | -"foreach" Term "as" Patterns '(' Exp ';' Exp ';' Exp ')' { +"foreach" Expr "as" Patterns '(' Query ';' Query ';' Query ')' { $$ = gen_foreach($2, $4, $6, $8, $10); } | -"foreach" Term "as" Patterns '(' Exp ';' Exp ')' { +"foreach" Expr "as" Patterns '(' Query ';' Query ')' { $$ = gen_foreach($2, $4, $6, $8, gen_noop()); } | -"if" Exp "then" Exp ElseBody { +"if" Query "then" Query ElseBody { $$ = gen_cond($2, $4, $5); } | -"if" Exp "then" error { +"if" Query "then" error { FAIL(@$, "Possibly unterminated 'if' statement"); $$ = $2; } | -"try" Exp "catch" Exp { +"try" Expr "catch" Expr { $$ = gen_try($2, $4); } | -"try" Exp "catch" error { +"try" Expr "catch" error { FAIL(@$, "Possibly unterminated 'try' statement"); $$ = $2; } | -"try" Exp { +"try" Expr { $$ = gen_try($2, gen_op_simple(BACKTRACK)); } | /* @@ -786,7 +759,7 @@ Args ';' Arg { } Arg: -Exp { +Query { $$ = gen_lambda($1); } @@ -850,7 +823,7 @@ Keyword ':' Pattern { String ':' Pattern { $$ = gen_object_matcher($1, $3); } | -'(' Exp ')' ':' Pattern { +'(' Query ')' ':' Pattern { jv msg = check_object_key($2); if (jv_is_valid(msg)) { FAIL(@$, jv_string_value(msg)); @@ -919,61 +892,73 @@ Keyword: $$ = jv_string("break"); } -MkDict: + +DictPairs: %empty { - $$=gen_noop(); + $$ = gen_noop(); } | - MkDictPair { $$ = $1; } -| MkDictPair ',' MkDict { $$=block_join($1, $3); } -| error ',' MkDict { $$ = $3; } +DictPair { + $$ = $1; +} | +DictPair ',' DictPairs { + $$ = block_join($1, $3); +} -MkDictPair: -IDENT ':' ExpD { +DictPair: +IDENT ':' DictExpr { $$ = gen_dictpair(gen_const($1), $3); - } -| Keyword ':' ExpD { +} | +Keyword ':' DictExpr { $$ = gen_dictpair(gen_const($1), $3); - } -| String ':' ExpD { +} | +String ':' DictExpr { $$ = gen_dictpair($1, $3); - } -| String { +} | +String { $$ = gen_dictpair($1, BLOCK(gen_op_simple(POP), gen_op_simple(DUP2), gen_op_simple(DUP2), gen_op_simple(INDEX))); - } -| BINDING ':' ExpD { +} | +BINDING ':' DictExpr { $$ = gen_dictpair(gen_location(@$, locations, gen_op_unbound(LOADV, jv_string_value($1))), $3); jv_free($1); - } -| BINDING { +} | +BINDING { $$ = gen_dictpair(gen_const($1), gen_location(@$, locations, gen_op_unbound(LOADV, jv_string_value($1)))); - } -| IDENT { +} | +IDENT { $$ = gen_dictpair(gen_const(jv_copy($1)), gen_index(gen_noop(), gen_const($1))); - } -| "$__loc__" { +} | +"$__loc__" { $$ = gen_dictpair(gen_const(jv_string("__loc__")), gen_loc_object(&@$, locations)); - } -| Keyword { +} | +Keyword { $$ = gen_dictpair(gen_const(jv_copy($1)), gen_index(gen_noop(), gen_const($1))); - } -| '(' Exp ')' ':' ExpD { +} | +'(' Query ')' ':' DictExpr { jv msg = check_object_key($2); if (jv_is_valid(msg)) { FAIL(@$, jv_string_value(msg)); } jv_free(msg); $$ = gen_dictpair($2, $5); - } -| error ':' ExpD { +} | +error ':' DictExpr { FAIL(@$, "May need parentheses around object key expression"); $$ = $3; - } +} + +DictExpr: +DictExpr '|' DictExpr { + $$ = block_join($1, $3); +} | +Expr { + $$ = $1; +} %% int jq_parse(struct locfile* locations, block* answer) { diff --git a/tests/jq.test b/tests/jq.test index 341361b74c..71c2b2992e 100644 --- a/tests/jq.test +++ b/tests/jq.test @@ -318,6 +318,14 @@ null [1,2,3] [1,3,6] +[foreach .[] / .[] as $i (0; . + $i)] +[1,2] +[1,3,3.5,4.5] + +[foreach .[] as $x (0; . + $x) as $x | $x] +[1,2,3] +[1,3,6] + [limit(3; .[])] [11,22,33,44,55,66,77,88,99] [11,22,33] @@ -783,6 +791,14 @@ null [1,2,3] [6] +[reduce .[] / .[] as $i (0; . + $i)] +[1,2] +[4.5] + +reduce .[] as $x (0; . + $x) as $x | $x +[1,2,3] +6 + # This, while useless, should still compile. reduce . as $n (.; .) null @@ -1218,6 +1234,10 @@ null null {"x":1} +if true then [.] else . end [] +null +null + [.[] | [.foo[] // .bar]] [{"foo":[1,2], "bar": 42}, {"foo":[1], "bar": null}, {"foo":[null,false,3], "bar": 18}, {"foo":[], "bar":42}, {"foo": [null,false,null], "bar": 41}] [[1,2], [1], [3], [42], [41]] @@ -1312,18 +1332,35 @@ null "foo" [] -try -.? catch . -"foo" -"string (\"foo\") cannot be negated" +try error(0) // 1 +null +1 + +1, try error(2), 3 +null +1 +3 + +1 + try 2 catch 3 + 4 +null +7 [-try .] 1 [-1] +try -.? catch . +"foo" +"string (\"foo\") cannot be negated" + {x: try 1, y: try error catch 2, z: if true then 3 end} null {"x":1,"y":2,"z":3} +{x: 1 + 2, y: false or true, z: null // 3} +null +{"x":3,"y":true,"z":3} + .[] | try error catch . [1,null,2] 1