Add $__loc__ (fix #740)

This commit is contained in:
Nicolas Williams committed 2015-03-30 22:36:04 -05:00
1 parent 1dcfc2f547
commit 24005287f4
10 files changed
+1163 -1137

No files matched your search

+12
View File
@@ -804,6 +804,18 @@ sections:
null and objects would, but with the given message as the
error's value.
- title: "`$__loc__`"
body: |
Produces an object with a "file" key and a "line" key, with
the filename and line number where `$__loc__` occurs, as
values.
examples:
- program: 'try error("\($__loc__)") catch .'
input: 'null'
output: ['"{\"file\":\"<top-level>\",\"line\":1}"']
- title: "`map(x)`, `map_values(x)`"
body: |
+173 -165
View File
@@ -358,8 +358,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
#define YY_NUM_RULES 47
#define YY_END_OF_BUFFER 48
#define YY_NUM_RULES 48
#define YY_END_OF_BUFFER 49
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -367,23 +367,24 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static yyconst flex_int16_t yy_accept[141] =
static yyconst flex_int16_t yy_accept[148] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 48, 46, 45, 45, 46, 37, 1, 32,
32, 33, 34, 32, 32, 32, 32, 32, 36, 32,
32, 32, 46, 43, 43, 43, 43, 43, 43, 43,
43, 43, 43, 43, 43, 43, 32, 41, 41, 39,
42, 45, 2, 1, 27, 25, 23, 24, 31, 36,
44, 44, 17, 26, 0, 29, 3, 30, 35, 43,
0, 43, 4, 43, 43, 43, 43, 43, 43, 8,
43, 43, 43, 13, 43, 43, 43, 22, 41, 40,
38, 40, 44, 0, 36, 28, 36, 0, 12, 43,
0, 0, 49, 47, 46, 46, 47, 38, 1, 33,
33, 34, 35, 33, 33, 33, 33, 33, 37, 33,
33, 33, 47, 44, 44, 44, 44, 44, 44, 44,
44, 44, 44, 44, 44, 44, 44, 33, 42, 42,
40, 43, 46, 2, 1, 28, 26, 24, 25, 32,
37, 45, 45, 17, 27, 0, 30, 3, 31, 36,
44, 0, 44, 44, 4, 44, 44, 44, 44, 44,
44, 8, 44, 44, 44, 13, 44, 44, 44, 23,
42, 41, 39, 41, 45, 0, 37, 29, 37, 0,
43, 7, 43, 43, 14, 43, 43, 43, 43, 43,
43, 18, 0, 40, 43, 43, 43, 11, 10, 43,
43, 43, 43, 43, 9, 40, 21, 19, 43, 43,
20, 43, 43, 40, 43, 5, 6, 15, 16, 0
44, 12, 44, 44, 7, 44, 44, 14, 44, 44,
44, 44, 44, 44, 18, 0, 41, 44, 44, 44,
44, 11, 10, 44, 44, 44, 44, 44, 9, 41,
44, 21, 19, 44, 44, 20, 44, 44, 41, 44,
44, 5, 6, 15, 22, 16, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -428,130 +429,132 @@ static yyconst flex_int32_t yy_meta[54] =
1, 1, 1
} ;
static yyconst flex_int16_t yy_base[154] =
static yyconst flex_int16_t yy_base[161] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
51, 52, 293, 294, 57, 59, 270, 294, 0, 294,
269, 294, 294, 268, 267, 266, 47, 47, 50, 265,
264, 263, 0, 265, 48, 51, 52, 37, 53, 56,
66, 57, 60, 59, 63, 68, 261, 0, 0, 294,
78, 90, 294, 0, 294, 294, 294, 294, 93, 94,
0, 100, 260, 294, 104, 294, 294, 294, 0, 262,
259, 88, 255, 97, 83, 105, 106, 109, 113, 251,
107, 115, 116, 248, 119, 120, 117, 294, 0, 234,
294, 231, 0, 240, 228, 294, 223, 0, 218, 118,
51, 52, 306, 307, 57, 59, 283, 307, 0, 307,
282, 307, 307, 281, 280, 279, 47, 47, 50, 278,
277, 276, 0, 278, 48, 51, 53, 52, 37, 59,
57, 66, 56, 63, 68, 70, 71, 274, 0, 0,
307, 81, 90, 307, 0, 307, 307, 307, 307, 95,
100, 0, 97, 273, 307, 106, 307, 307, 307, 0,
275, 274, 85, 104, 273, 101, 77, 109, 110, 113,
114, 272, 116, 119, 115, 271, 121, 122, 123, 307,
0, 258, 307, 254, 0, 261, 258, 307, 254, 0,
121, 213, 124, 122, 211, 127, 128, 130, 138, 141,
143, 208, 154, 196, 196, 149, 146, 183, 182, 150,
151, 152, 154, 157, 181, 165, 169, 166, 158, 156,
164, 160, 162, 149, 161, 155, 82, 79, 71, 294,
204, 213, 219, 224, 229, 238, 247, 252, 257, 259,
264, 268, 272
124, 250, 132, 125, 248, 126, 134, 236, 135, 128,
143, 136, 146, 147, 231, 157, 217, 222, 150, 156,
155, 220, 217, 157, 158, 159, 161, 163, 215, 195,
167, 193, 192, 169, 162, 188, 172, 173, 176, 168,
175, 182, 164, 86, 78, 76, 307, 213, 222, 228,
233, 238, 247, 256, 261, 266, 268, 273, 277, 281
} ;
static yyconst flex_int16_t yy_def[154] =
static yyconst flex_int16_t yy_def[161] =
{ 0,
140, 1, 1, 1, 1, 1, 1, 1, 1, 1,
141, 141, 140, 140, 140, 140, 140, 140, 142, 140,
140, 140, 140, 140, 140, 140, 143, 140, 140, 140,
140, 140, 144, 145, 145, 145, 145, 145, 145, 145,
145, 145, 145, 145, 145, 145, 140, 146, 146, 140,
147, 140, 140, 142, 140, 140, 140, 140, 140, 140,
148, 148, 140, 140, 140, 140, 140, 140, 144, 145,
140, 145, 145, 145, 145, 145, 145, 145, 145, 145,
145, 145, 145, 145, 145, 145, 145, 140, 146, 140,
140, 149, 148, 140, 148, 140, 140, 150, 145, 145,
147, 1, 1, 1, 1, 1, 1, 1, 1, 1,
148, 148, 147, 147, 147, 147, 147, 147, 149, 147,
147, 147, 147, 147, 147, 147, 150, 147, 147, 147,
147, 147, 151, 152, 152, 152, 152, 152, 152, 152,
152, 152, 152, 152, 152, 152, 152, 147, 153, 153,
147, 154, 147, 147, 149, 147, 147, 147, 147, 147,
147, 155, 155, 147, 147, 147, 147, 147, 147, 151,
152, 147, 152, 152, 152, 152, 152, 152, 152, 152,
152, 152, 152, 152, 152, 152, 152, 152, 152, 147,
153, 147, 147, 156, 155, 147, 155, 147, 147, 157,
145, 145, 145, 145, 145, 145, 145, 145, 145, 145,
145, 145, 147, 151, 145, 145, 145, 145, 145, 145,
145, 145, 145, 145, 145, 152, 145, 145, 145, 145,
145, 145, 145, 153, 145, 145, 145, 145, 145, 0,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140
152, 152, 152, 152, 152, 152, 152, 152, 152, 152,
152, 152, 152, 152, 152, 154, 158, 152, 152, 152,
152, 152, 152, 152, 152, 152, 152, 152, 152, 159,
152, 152, 152, 152, 152, 152, 152, 152, 160, 152,
152, 152, 152, 152, 152, 152, 0, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147
} ;
static yyconst flex_int16_t yy_nxt[348] =
static yyconst flex_int16_t yy_nxt[361] =
{ 0,
14, 15, 16, 14, 17, 18, 19, 20, 21, 22,
23, 24, 25, 20, 26, 27, 28, 29, 20, 20,
30, 31, 32, 20, 33, 34, 34, 22, 14, 23,
34, 35, 36, 37, 38, 39, 40, 34, 41, 34,
42, 43, 34, 44, 34, 45, 34, 46, 34, 34,
22, 47, 23, 49, 49, 71, 50, 50, 52, 52,
52, 52, 59, 63, 60, 60, 71, 60, 64, 71,
71, 71, 76, 62, 71, 71, 65, 71, 71, 51,
51, 71, 62, 75, 71, 65, 71, 91, 82, 71,
72, 52, 52, 77, 73, 78, 74, 71, 85, 79,
35, 36, 37, 38, 39, 40, 41, 34, 42, 34,
43, 44, 34, 45, 34, 46, 34, 47, 34, 34,
22, 48, 23, 50, 50, 72, 51, 51, 53, 53,
53, 53, 60, 64, 61, 61, 72, 61, 65, 72,
72, 72, 78, 63, 72, 72, 66, 72, 73, 52,
52, 72, 63, 77, 72, 66, 72, 84, 72, 72,
93, 53, 53, 74, 72, 72, 72, 75, 76, 79,
71, 71, 80, 83, 84, 86, 71, 81, 60, 60,
60, 60, 94, 87, 94, 71, 94, 95, 94, 65,
65, 97, 99, 71, 71, 71, 92, 71, 65, 65,
101, 71, 100, 71, 71, 71, 71, 71, 71, 71,
71, 102, 71, 105, 103, 71, 71, 108, 71, 116,
109, 107, 104, 110, 117, 111, 71, 119, 106, 71,
118, 71, 120, 140, 71, 122, 112, 71, 71, 71,
71, 121, 71, 71, 71, 71, 71, 113, 71, 71,
71, 129, 71, 128, 71, 125, 123, 71, 127, 124,
133, 135, 131, 113, 132, 137, 130, 138, 139, 71,
81, 80, 82, 72, 72, 87, 85, 83, 88, 96,
61, 96, 61, 86, 97, 61, 89, 61, 96, 72,
96, 66, 72, 99, 104, 101, 66, 72, 72, 94,
66, 72, 72, 72, 72, 66, 103, 72, 102, 72,
72, 72, 72, 72, 72, 105, 72, 108, 106, 112,
72, 111, 72, 72, 72, 113, 107, 114, 121, 109,
110, 72, 122, 120, 72, 72, 147, 119, 72, 123,
124, 125, 115, 72, 72, 72, 72, 72, 126, 72,
72, 72, 72, 131, 127, 72, 72, 72, 134, 129,
72, 72, 133, 72, 128, 132, 138, 140, 145, 136,
71, 71, 92, 136, 48, 48, 48, 48, 48, 48,
48, 48, 48, 54, 71, 54, 54, 54, 54, 54,
54, 54, 61, 61, 113, 61, 71, 61, 69, 71,
69, 71, 69, 70, 70, 70, 71, 70, 89, 89,
97, 89, 89, 89, 89, 95, 89, 90, 90, 90,
90, 90, 90, 90, 90, 90, 93, 97, 93, 113,
93, 114, 113, 114, 114, 115, 71, 115, 126, 71,
126, 126, 134, 71, 134, 134, 90, 98, 90, 90,
71, 96, 88, 71, 68, 67, 66, 58, 57, 56,
55, 53, 140, 13, 140, 140, 140, 140, 140, 140,
72, 137, 141, 135, 116, 94, 72, 143, 144, 142,
72, 72, 146, 49, 49, 49, 49, 49, 49, 49,
49, 49, 55, 116, 55, 55, 55, 55, 55, 55,
55, 62, 62, 72, 62, 72, 62, 70, 72, 70,
72, 70, 71, 71, 71, 116, 71, 91, 91, 72,
91, 91, 91, 91, 72, 91, 92, 92, 92, 92,
92, 92, 92, 92, 92, 95, 72, 95, 72, 95,
117, 99, 117, 117, 118, 97, 118, 130, 99, 130,
130, 139, 116, 139, 139, 92, 116, 92, 92, 72,
72, 72, 100, 72, 98, 90, 72, 69, 68, 67,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140
59, 58, 57, 56, 54, 147, 13, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147
} ;
static yyconst flex_int16_t yy_chk[348] =
static yyconst flex_int16_t yy_chk[361] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 11, 12, 38, 11, 12, 15, 15,
1, 1, 1, 11, 12, 39, 11, 12, 15, 15,
16, 16, 27, 28, 27, 29, 35, 29, 28, 36,
37, 39, 38, 27, 40, 42, 29, 44, 43, 11,
12, 45, 27, 37, 41, 29, 46, 51, 42, 139,
35, 52, 52, 39, 35, 39, 36, 138, 45, 40,
38, 37, 39, 27, 43, 41, 29, 40, 35, 11,
12, 44, 27, 38, 42, 29, 45, 43, 46, 47,
52, 53, 53, 36, 146, 77, 145, 36, 37, 40,
137, 75, 41, 43, 44, 46, 72, 41, 59, 60,
59, 60, 62, 46, 62, 74, 65, 62, 65, 59,
60, 65, 72, 76, 77, 81, 51, 78, 59, 60,
75, 79, 74, 82, 83, 87, 100, 85, 86, 101,
104, 76, 103, 78, 77, 106, 107, 82, 108, 100,
83, 81, 77, 85, 101, 86, 109, 104, 79, 110,
103, 111, 106, 113, 117, 108, 87, 116, 120, 121,
122, 107, 123, 136, 130, 124, 129, 134, 132, 135,
133, 120, 131, 117, 128, 111, 109, 127, 116, 110,
124, 129, 122, 126, 123, 132, 121, 133, 135, 125,
41, 40, 42, 73, 144, 46, 44, 42, 47, 63,
60, 63, 60, 45, 63, 61, 47, 61, 66, 76,
66, 60, 74, 66, 77, 73, 61, 78, 79, 52,
60, 80, 81, 85, 83, 61, 76, 84, 74, 87,
88, 89, 101, 104, 106, 78, 110, 80, 79, 85,
103, 84, 107, 109, 112, 87, 79, 88, 104, 81,
83, 111, 106, 103, 113, 114, 116, 101, 119, 107,
109, 110, 89, 121, 120, 124, 125, 126, 111, 127,
135, 128, 143, 119, 112, 131, 140, 134, 124, 114,
137, 138, 121, 141, 113, 120, 128, 131, 140, 126,
119, 118, 113, 130, 141, 141, 141, 141, 141, 141,
141, 141, 141, 142, 115, 142, 142, 142, 142, 142,
142, 142, 143, 143, 114, 143, 112, 143, 144, 105,
144, 102, 144, 145, 145, 145, 99, 145, 146, 146,
97, 146, 146, 146, 146, 95, 146, 147, 147, 147,
147, 147, 147, 147, 147, 147, 148, 94, 148, 92,
148, 149, 90, 149, 149, 150, 84, 150, 151, 80,
151, 151, 152, 73, 152, 152, 153, 71, 153, 153,
70, 63, 47, 34, 32, 31, 30, 26, 25, 24,
21, 17, 13, 140, 140, 140, 140, 140, 140, 140,
142, 127, 134, 125, 139, 116, 136, 137, 138, 135,
133, 132, 141, 148, 148, 148, 148, 148, 148, 148,
148, 148, 149, 130, 149, 149, 149, 149, 149, 149,
149, 150, 150, 129, 150, 123, 150, 151, 122, 151,
118, 151, 152, 152, 152, 117, 152, 153, 153, 115,
153, 153, 153, 153, 108, 153, 154, 154, 154, 154,
154, 154, 154, 154, 154, 155, 105, 155, 102, 155,
156, 99, 156, 156, 157, 97, 157, 158, 96, 158,
158, 159, 94, 159, 159, 160, 92, 160, 160, 86,
82, 75, 72, 71, 64, 48, 34, 32, 31, 30,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
140, 140, 140, 140, 140, 140, 140
26, 25, 24, 21, 17, 13, 147, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
147, 147, 147, 147, 147, 147, 147, 147, 147, 147
} ;
/* The intent behind this definition is that it'll catch
@@ -587,7 +590,7 @@ struct lexer_param;
static int enter(int opening, int state, yyscan_t yyscanner);
static int try_exit(int closing, int state, yyscan_t yyscanner);
#define YY_NO_INPUT 1
#line 591 "lexer.c"
#line 594 "lexer.c"
#define INITIAL 0
#define IN_PAREN 1
@@ -843,7 +846,7 @@ YY_DECL
#line 38 "lexer.l"
#line 847 "lexer.c"
#line 850 "lexer.c"
yylval = yylval_param;
@@ -900,13 +903,13 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 141 )
if ( yy_current_state >= 148 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
while ( yy_base[yy_current_state] != 294 );
while ( yy_base[yy_current_state] != 307 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -1038,114 +1041,119 @@ YY_RULE_SETUP
case 22:
YY_RULE_SETUP
#line 62 "lexer.l"
{ return SETPIPE; }
{ return LOC; }
YY_BREAK
case 23:
YY_RULE_SETUP
#line 63 "lexer.l"
{ return SETPLUS; }
{ return SETPIPE; }
YY_BREAK
case 24:
YY_RULE_SETUP
#line 64 "lexer.l"
{ return SETMINUS; }
{ return SETPLUS; }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 65 "lexer.l"
{ return SETMULT; }
{ return SETMINUS; }
YY_BREAK
case 26:
YY_RULE_SETUP
#line 66 "lexer.l"
{ return SETDIV; }
{ return SETMULT; }
YY_BREAK
case 27:
YY_RULE_SETUP
#line 67 "lexer.l"
{ return SETMOD; }
{ return SETDIV; }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 68 "lexer.l"
{ return SETDEFINEDOR; }
{ return SETMOD; }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 69 "lexer.l"
{ return LESSEQ; }
{ return SETDEFINEDOR; }
YY_BREAK
case 30:
YY_RULE_SETUP
#line 70 "lexer.l"
{ return GREATEREQ; }
{ return LESSEQ; }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 71 "lexer.l"
{ return REC; }
{ return GREATEREQ; }
YY_BREAK
case 32:
YY_RULE_SETUP
#line 72 "lexer.l"
{ return yytext[0];}
{ return REC; }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 74 "lexer.l"
#line 73 "lexer.l"
{ return yytext[0];}
YY_BREAK
case 34:
YY_RULE_SETUP
#line 75 "lexer.l"
{
return enter(yytext[0], YY_START, yyscanner);
}
YY_BREAK
case 34:
case 35:
YY_RULE_SETUP
#line 78 "lexer.l"
#line 79 "lexer.l"
{
return try_exit(yytext[0], YY_START, yyscanner);
}
YY_BREAK
case 35:
case 36:
YY_RULE_SETUP
#line 82 "lexer.l"
#line 83 "lexer.l"
{
yylval->literal = jv_string_sized(yytext + 1, yyleng - 1); return FORMAT;
}
YY_BREAK
case 36:
case 37:
YY_RULE_SETUP
#line 86 "lexer.l"
#line 87 "lexer.l"
{
yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;
}
YY_BREAK
case 37:
case 38:
YY_RULE_SETUP
#line 90 "lexer.l"
#line 91 "lexer.l"
{
yy_push_state(IN_QQSTRING, yyscanner);
return QQSTRING_START;
}
YY_BREAK
case 38:
case 39:
YY_RULE_SETUP
#line 96 "lexer.l"
#line 97 "lexer.l"
{
return enter(QQSTRING_INTERP_START, YY_START, yyscanner);
}
YY_BREAK
case 39:
case 40:
YY_RULE_SETUP
#line 99 "lexer.l"
#line 100 "lexer.l"
{
yy_pop_state(yyscanner);
return QQSTRING_END;
}
YY_BREAK
case 40:
/* rule 40 can match eol */
case 41:
/* rule 41 can match eol */
YY_RULE_SETUP
#line 103 "lexer.l"
#line 104 "lexer.l"
{
/* pass escapes to the json parser */
jv escapes = jv_string_fmt("\"%.*s\"", (int)yyleng, yytext);
@@ -1154,50 +1162,50 @@ YY_RULE_SETUP
return QQSTRING_TEXT;
}
YY_BREAK
case 41:
/* rule 41 can match eol */
case 42:
/* rule 42 can match eol */
YY_RULE_SETUP
#line 110 "lexer.l"
#line 111 "lexer.l"
{
yylval->literal = jv_string_sized(yytext, yyleng);
return QQSTRING_TEXT;
}
YY_BREAK
case 42:
case 43:
YY_RULE_SETUP
#line 114 "lexer.l"
#line 115 "lexer.l"
{
return INVALID_CHARACTER;
}
YY_BREAK
case 43:
YY_RULE_SETUP
#line 120 "lexer.l"
{ yylval->literal = jv_string(yytext); return IDENT;}
YY_BREAK
case 44:
YY_RULE_SETUP
#line 121 "lexer.l"
{ yylval->literal = jv_string(yytext+1); return FIELD;}
{ yylval->literal = jv_string(yytext); return IDENT;}
YY_BREAK
case 45:
/* rule 45 can match eol */
YY_RULE_SETUP
#line 123 "lexer.l"
{}
#line 122 "lexer.l"
{ yylval->literal = jv_string(yytext+1); return FIELD;}
YY_BREAK
case 46:
/* rule 46 can match eol */
YY_RULE_SETUP
#line 125 "lexer.l"
{ return INVALID_CHARACTER; }
#line 124 "lexer.l"
{}
YY_BREAK
case 47:
YY_RULE_SETUP
#line 127 "lexer.l"
#line 126 "lexer.l"
{ return INVALID_CHARACTER; }
YY_BREAK
case 48:
YY_RULE_SETUP
#line 128 "lexer.l"
YY_FATAL_ERROR( "flex scanner jammed" );
YY_BREAK
#line 1201 "lexer.c"
#line 1209 "lexer.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(IN_PAREN):
case YY_STATE_EOF(IN_BRACKET):
@@ -1496,7 +1504,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 141 )
if ( yy_current_state >= 148 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1525,11 +1533,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 141 )
if ( yy_current_state >= 148 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 140);
yy_is_jam = (yy_current_state == 147);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -2361,7 +2369,7 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
#line 127 "lexer.l"
#line 128 "lexer.l"
/* perhaps these should be calls... */
+1 -1
View File
@@ -354,7 +354,7 @@ extern int jq_yylex \
#undef YY_DECL
#endif
#line 127 "lexer.l"
#line 128 "lexer.l"
#line 361 "lexer.h"
+1
View File
@@ -59,6 +59,7 @@ struct lexer_param;
"catch" { return CATCH; }
"label" { return LABEL; }
"break" { return BREAK; }
"__loc__" { return LOC; }
"|=" { return SETPIPE; }
"+=" { return SETPLUS; }
"-=" { return SETMINUS; }
+1 -1
View File
@@ -47,7 +47,7 @@ void locfile_free(struct locfile* l) {
}
}
static int locfile_get_line(struct locfile* l, int pos) {
int locfile_get_line(struct locfile* l, int pos) {
assert(pos < l->length);
int line = 1;
while (l->linemap[line] <= pos) line++; // == if pos at start (before, never ==, because pos never on \n)
+1
View File
@@ -22,6 +22,7 @@ struct locfile {
struct locfile* locfile_init(jq_state *, const char *, const char *, int);
struct locfile* locfile_retain(struct locfile *);
int locfile_get_line(struct locfile *, int);
void locfile_free(struct locfile *);
void locfile_locate(struct locfile *, location, const char *, ...);
+936 -943
View File
File diff suppressed because it is too large. Load diff
+29 -27
View File
@@ -92,19 +92,20 @@ struct lexer_param;
CATCH = 282,
LABEL = 283,
BREAK = 284,
SETPIPE = 285,
SETPLUS = 286,
SETMINUS = 287,
SETMULT = 288,
SETDIV = 289,
SETDEFINEDOR = 290,
LESSEQ = 291,
GREATEREQ = 292,
QQSTRING_START = 293,
QQSTRING_TEXT = 294,
QQSTRING_INTERP_START = 295,
QQSTRING_INTERP_END = 296,
QQSTRING_END = 297
LOC = 285,
SETPIPE = 286,
SETPLUS = 287,
SETMINUS = 288,
SETMULT = 289,
SETDIV = 290,
SETDEFINEDOR = 291,
LESSEQ = 292,
GREATEREQ = 293,
QQSTRING_START = 294,
QQSTRING_TEXT = 295,
QQSTRING_INTERP_START = 296,
QQSTRING_INTERP_END = 297,
QQSTRING_END = 298
};
#endif
/* Tokens. */
@@ -135,19 +136,20 @@ struct lexer_param;
#define CATCH 282
#define LABEL 283
#define BREAK 284
#define SETPIPE 285
#define SETPLUS 286
#define SETMINUS 287
#define SETMULT 288
#define SETDIV 289
#define SETDEFINEDOR 290
#define LESSEQ 291
#define GREATEREQ 292
#define QQSTRING_START 293
#define QQSTRING_TEXT 294
#define QQSTRING_INTERP_START 295
#define QQSTRING_INTERP_END 296
#define QQSTRING_END 297
#define LOC 285
#define SETPIPE 286
#define SETPLUS 287
#define SETMINUS 288
#define SETMULT 289
#define SETDIV 290
#define SETDEFINEDOR 291
#define LESSEQ 292
#define GREATEREQ 293
#define QQSTRING_START 294
#define QQSTRING_TEXT 295
#define QQSTRING_INTERP_START 296
#define QQSTRING_INTERP_END 297
#define QQSTRING_END 298
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -159,7 +161,7 @@ union YYSTYPE
jv literal;
block blk;
#line 163 "parser.h" /* yacc.c:1909 */
#line 165 "parser.h" /* yacc.c:1909 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
+5
View File
@@ -72,6 +72,7 @@ struct lexer_param;
%token CATCH "catch"
%token LABEL "label"
%token BREAK "break"
%token LOC "__loc__"
%token SETPIPE "|="
%token SETPLUS "+="
%token SETMINUS "-="
@@ -691,6 +692,10 @@ FORMAT {
else
$$ = BLOCK(gen_subexp(gen_const(jv_object())), $2, gen_op_simple(POP));
} |
'$' LOC {
$$ = gen_const(JV_OBJECT(jv_string("file"), jv_copy(locations->fname),
jv_string("line"), jv_number(locfile_get_line(locations, @$.start) + 1)));
} |
'$' IDENT {
$$ = gen_location(@$, locations, gen_op_unbound(LOADV, jv_string_value($2)));
jv_free($2);
+4
View File
@@ -814,6 +814,10 @@ def inc(x): x |= .+1; inc(.[].a)
[null,true,{"a":1}]
[]
try error("\($__loc__)") catch .
null
"{\"file\":\"<top-level>\",\"line\":1}"
# string operations
[.[]|startswith("foo")]
["fo", "foo", "barfoo", "foobar", "barfoob"]