summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2015-07-10 10:11:51 -0500
committerNicolas Williams <nico@cryptonector.com>2015-07-10 10:19:33 -0500
commit579518c78d0a277f487a03b03c450455089e6770 (patch)
treec9782e974e8e68d51373dddbdb4c0f310c7e4cce
parentfa45a5121c2b2af03190e88bfde0a35111786ba7 (diff)
Use `include` for import into namespace
-rw-r--r--docs/content/3.manual/manual.yml6
-rw-r--r--lexer.c384
-rw-r--r--lexer.h2
-rw-r--r--lexer.l1
-rw-r--r--parser.c2011
-rw-r--r--parser.h112
-rw-r--r--parser.y8
-rw-r--r--tests/jq.test6
8 files changed, 1275 insertions, 1255 deletions
diff --git a/docs/content/3.manual/manual.yml b/docs/content/3.manual/manual.yml
index 2fa890b5..a6bfae25 100644
--- a/docs/content/3.manual/manual.yml
+++ b/docs/content/3.manual/manual.yml
@@ -2737,8 +2737,8 @@ sections:
in `.jq`.
Modules imported by a program are searched for in a default search
- path (see below). The `import` directive allows the importer to
- alter this path.
+ path (see below). The `import` and `include` directives allow the
+ importer to alter this path.
Paths in the a search path are subject to various substitutions.
@@ -2795,7 +2795,7 @@ sections:
string or array value (array of strings); this is the search
path to be prefixed to the top-level search path.
- - title: "`import RelativePathString [<metadata>];`"
+ - title: "`include RelativePathString [<metadata>];`"
body: |
Imports a module found at the given path relative to a
diff --git a/lexer.c b/lexer.c
index c71dc234..1ff4cba6 100644
--- a/lexer.c
+++ b/lexer.c
@@ -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 48
-#define YY_END_OF_BUFFER 49
+#define YY_NUM_RULES 49
+#define YY_END_OF_BUFFER 50
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -367,24 +367,25 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
-static yyconst flex_int16_t yy_accept[148] =
+static yyconst flex_int16_t yy_accept[154] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 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,
-
- 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
+ 0, 0, 50, 48, 47, 47, 48, 39, 1, 34,
+ 34, 35, 36, 34, 34, 34, 34, 34, 38, 34,
+ 34, 34, 48, 45, 45, 45, 45, 45, 45, 45,
+ 45, 45, 45, 45, 45, 45, 45, 34, 43, 43,
+ 41, 44, 47, 2, 1, 29, 27, 25, 26, 33,
+ 38, 46, 46, 18, 28, 0, 31, 3, 32, 37,
+ 45, 0, 45, 45, 4, 45, 45, 45, 45, 45,
+ 45, 9, 45, 45, 45, 45, 14, 45, 45, 45,
+ 24, 43, 42, 40, 42, 46, 0, 38, 30, 38,
+
+ 0, 45, 13, 45, 45, 8, 45, 45, 15, 45,
+ 45, 45, 45, 45, 45, 45, 19, 0, 42, 45,
+ 45, 45, 45, 12, 11, 45, 45, 45, 45, 45,
+ 45, 10, 42, 45, 22, 20, 45, 45, 45, 21,
+ 45, 45, 42, 45, 45, 5, 45, 7, 16, 23,
+ 17, 6, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -429,49 +430,51 @@ static yyconst flex_int32_t yy_meta[54] =
1, 1, 1
} ;
-static yyconst flex_int16_t yy_base[161] =
+static yyconst flex_int16_t yy_base[167] =
{ 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 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,
-
- 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
+ 51, 52, 318, 319, 57, 59, 295, 319, 0, 319,
+ 294, 319, 319, 293, 292, 291, 47, 47, 50, 290,
+ 289, 288, 0, 290, 48, 51, 53, 52, 37, 59,
+ 57, 66, 56, 63, 68, 70, 72, 286, 0, 0,
+ 319, 80, 90, 319, 0, 319, 319, 319, 319, 95,
+ 99, 0, 106, 285, 319, 110, 319, 319, 319, 0,
+ 285, 281, 86, 77, 277, 97, 101, 111, 113, 115,
+ 117, 274, 119, 120, 118, 121, 270, 122, 123, 124,
+ 319, 0, 257, 319, 255, 0, 254, 249, 319, 245,
+
+ 0, 125, 239, 126, 127, 237, 128, 134, 234, 136,
+ 143, 147, 148, 149, 152, 154, 232, 165, 212, 210,
+ 157, 159, 158, 209, 208, 160, 161, 162, 163, 164,
+ 166, 207, 196, 171, 205, 204, 174, 167, 175, 201,
+ 170, 176, 190, 190, 184, 199, 194, 198, 197, 85,
+ 78, 76, 319, 230, 239, 245, 250, 255, 264, 273,
+ 278, 283, 285, 290, 294, 298
} ;
-static yyconst flex_int16_t yy_def[161] =
+static yyconst flex_int16_t yy_def[167] =
{ 0,
- 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,
-
- 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
+ 153, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 154, 154, 153, 153, 153, 153, 153, 153, 155, 153,
+ 153, 153, 153, 153, 153, 153, 156, 153, 153, 153,
+ 153, 153, 157, 158, 158, 158, 158, 158, 158, 158,
+ 158, 158, 158, 158, 158, 158, 158, 153, 159, 159,
+ 153, 160, 153, 153, 155, 153, 153, 153, 153, 153,
+ 153, 161, 161, 153, 153, 153, 153, 153, 153, 157,
+ 158, 153, 158, 158, 158, 158, 158, 158, 158, 158,
+ 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
+ 153, 159, 153, 153, 162, 161, 153, 161, 153, 153,
+
+ 163, 158, 158, 158, 158, 158, 158, 158, 158, 158,
+ 158, 158, 158, 158, 158, 158, 158, 160, 164, 158,
+ 158, 158, 158, 158, 158, 158, 158, 158, 158, 158,
+ 158, 158, 165, 158, 158, 158, 158, 158, 158, 158,
+ 158, 158, 166, 158, 158, 158, 158, 158, 158, 158,
+ 158, 158, 0, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153
} ;
-static yyconst flex_int16_t yy_nxt[361] =
+static yyconst flex_int16_t yy_nxt[373] =
{ 0,
14, 15, 16, 14, 17, 18, 19, 20, 21, 22,
23, 24, 25, 20, 26, 27, 28, 29, 20, 20,
@@ -481,40 +484,42 @@ static yyconst flex_int16_t yy_nxt[361] =
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,
-
- 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,
-
- 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,
-
- 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
+ 52, 72, 63, 77, 72, 66, 72, 85, 72, 94,
+ 72, 53, 53, 74, 72, 72, 72, 75, 76, 79,
+
+ 81, 80, 82, 72, 72, 88, 86, 83, 84, 89,
+ 61, 103, 61, 87, 61, 72, 61, 90, 97, 72,
+ 97, 66, 97, 98, 97, 66, 102, 100, 95, 72,
+ 66, 72, 104, 72, 66, 72, 72, 72, 72, 72,
+ 72, 72, 72, 72, 72, 72, 72, 106, 105, 109,
+ 113, 107, 72, 112, 72, 114, 115, 122, 116, 108,
+ 123, 72, 110, 111, 124, 72, 72, 72, 121, 125,
+ 72, 126, 72, 117, 153, 72, 72, 72, 72, 72,
+ 72, 72, 72, 129, 72, 72, 127, 128, 72, 72,
+ 134, 137, 72, 72, 72, 136, 132, 130, 135, 142,
+
+ 131, 144, 72, 140, 141, 148, 138, 145, 72, 147,
+ 139, 149, 72, 95, 146, 72, 72, 72, 118, 72,
+ 150, 151, 72, 72, 118, 72, 72, 72, 72, 152,
+ 49, 49, 49, 49, 49, 49, 49, 49, 49, 55,
+ 118, 55, 55, 55, 55, 55, 55, 55, 62, 62,
+ 72, 62, 72, 62, 70, 72, 70, 72, 70, 71,
+ 71, 71, 100, 71, 92, 92, 98, 92, 92, 92,
+ 92, 100, 92, 93, 93, 93, 93, 93, 93, 93,
+ 93, 93, 96, 118, 96, 118, 96, 119, 72, 119,
+ 119, 120, 72, 120, 133, 72, 133, 133, 143, 101,
+
+ 143, 143, 93, 72, 93, 93, 99, 91, 72, 69,
+ 68, 67, 59, 58, 57, 56, 54, 153, 13, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153
} ;
-static yyconst flex_int16_t yy_chk[361] =
+static yyconst flex_int16_t yy_chk[373] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -524,37 +529,39 @@ static yyconst flex_int16_t yy_chk[361] =
1, 1, 1, 11, 12, 39, 11, 12, 15, 15,
16, 16, 27, 28, 27, 29, 35, 29, 28, 36,
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,
-
- 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,
-
- 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,
-
- 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
+ 12, 44, 27, 38, 42, 29, 45, 43, 46, 52,
+ 47, 53, 53, 36, 152, 74, 151, 36, 37, 40,
+
+ 41, 40, 42, 150, 73, 46, 44, 42, 42, 47,
+ 60, 74, 60, 45, 61, 76, 61, 47, 63, 77,
+ 63, 60, 66, 63, 66, 61, 73, 66, 52, 78,
+ 60, 79, 76, 80, 61, 81, 85, 83, 84, 86,
+ 88, 89, 90, 102, 104, 105, 107, 78, 77, 80,
+ 85, 79, 108, 84, 110, 86, 88, 104, 89, 79,
+ 105, 111, 81, 83, 107, 112, 113, 114, 102, 108,
+ 115, 110, 116, 90, 118, 121, 123, 122, 126, 127,
+ 128, 129, 130, 113, 131, 138, 111, 112, 141, 134,
+ 121, 126, 137, 139, 142, 123, 116, 114, 122, 131,
+
+ 115, 134, 145, 129, 130, 141, 127, 137, 144, 139,
+ 128, 142, 147, 118, 138, 149, 148, 146, 143, 140,
+ 144, 145, 136, 135, 133, 132, 125, 124, 120, 147,
+ 154, 154, 154, 154, 154, 154, 154, 154, 154, 155,
+ 119, 155, 155, 155, 155, 155, 155, 155, 156, 156,
+ 117, 156, 109, 156, 157, 106, 157, 103, 157, 158,
+ 158, 158, 100, 158, 159, 159, 98, 159, 159, 159,
+ 159, 97, 159, 160, 160, 160, 160, 160, 160, 160,
+ 160, 160, 161, 95, 161, 93, 161, 162, 87, 162,
+ 162, 163, 82, 163, 164, 75, 164, 164, 165, 72,
+
+ 165, 165, 166, 71, 166, 166, 64, 48, 34, 32,
+ 31, 30, 26, 25, 24, 21, 17, 13, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153, 153, 153, 153, 153, 153, 153, 153, 153,
+ 153, 153
} ;
/* The intent behind this definition is that it'll catch
@@ -590,7 +597,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 594 "lexer.c"
+#line 601 "lexer.c"
#define INITIAL 0
#define IN_PAREN 1
@@ -846,7 +853,7 @@ YY_DECL
#line 38 "lexer.l"
-#line 850 "lexer.c"
+#line 857 "lexer.c"
yylval = yylval_param;
@@ -903,13 +910,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 >= 148 )
+ if ( yy_current_state >= 154 )
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] != 307 );
+ while ( yy_base[yy_current_state] != 319 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
@@ -961,199 +968,204 @@ YY_RULE_SETUP
case 6:
YY_RULE_SETUP
#line 46 "lexer.l"
-{ return MODULE; }
+{ return INCLUDE; }
YY_BREAK
case 7:
YY_RULE_SETUP
#line 47 "lexer.l"
-{ return DEF; }
+{ return MODULE; }
YY_BREAK
case 8:
YY_RULE_SETUP
#line 48 "lexer.l"
-{ return IF; }
+{ return DEF; }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 49 "lexer.l"
-{ return THEN; }
+{ return IF; }
YY_BREAK
case 10:
YY_RULE_SETUP
#line 50 "lexer.l"
-{ return ELSE; }
+{ return THEN; }
YY_BREAK
case 11:
YY_RULE_SETUP
#line 51 "lexer.l"
-{ return ELSE_IF; }
+{ return ELSE; }
YY_BREAK
case 12:
YY_RULE_SETUP
#line 52 "lexer.l"
-{ return AND; }
+{ return ELSE_IF; }
YY_BREAK
case 13:
YY_RULE_SETUP
#line 53 "lexer.l"
-{ return OR; }
+{ return AND; }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 54 "lexer.l"
-{ return END; }
+{ return OR; }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 55 "lexer.l"
-{ return REDUCE; }
+{ return END; }
YY_BREAK
case 16:
YY_RULE_SETUP
#line 56 "lexer.l"
-{ return FOREACH; }
+{ return REDUCE; }
YY_BREAK
case 17:
YY_RULE_SETUP
#line 57 "lexer.l"
-{ return DEFINEDOR; }
+{ return FOREACH; }
YY_BREAK
case 18:
YY_RULE_SETUP
#line 58 "lexer.l"
-{ return TRY; }
+{ return DEFINEDOR; }
YY_BREAK
case 19:
YY_RULE_SETUP
#line 59 "lexer.l"
-{ return CATCH; }
+{ return TRY; }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 60 "lexer.l"
-{ return LABEL; }
+{ return CATCH; }
YY_BREAK
case 21:
YY_RULE_SETUP
#line 61 "lexer.l"
-{ return BREAK; }
+{ return LABEL; }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 62 "lexer.l"
-{ return LOC; }
+{ return BREAK; }
YY_BREAK
case 23:
YY_RULE_SETUP
#line 63 "lexer.l"
-{ return SETPIPE; }
+{ return LOC; }
YY_BREAK
case 24:
YY_RULE_SETUP
#line 64 "lexer.l"
-{ return SETPLUS; }
+{ return SETPIPE; }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 65 "lexer.l"
-{ return SETMINUS; }
+{ return SETPLUS; }
YY_BREAK
case 26:
YY_RULE_SETUP
#line 66 "lexer.l"
-{ return SETMULT; }
+{ return SETMINUS; }
YY_BREAK
case 27:
YY_RULE_SETUP
#line 67 "lexer.l"
-{ return SETDIV; }
+{ return SETMULT; }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 68 "lexer.l"
-{ return SETMOD; }
+{ return SETDIV; }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 69 "lexer.l"
-{ return SETDEFINEDOR; }
+{ return SETMOD; }
YY_BREAK
case 30:
YY_RULE_SETUP
#line 70 "lexer.l"
-{ return LESSEQ; }
+{ return SETDEFINEDOR; }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 71 "lexer.l"
-{ return GREATEREQ; }
+{ return LESSEQ; }
YY_BREAK
case 32:
YY_RULE_SETUP
#line 72 "lexer.l"
-{ return REC; }
+{ return GREATEREQ; }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 73 "lexer.l"
-{ return yytext[0];}
+{ return REC; }
YY_BREAK
case 34:
YY_RULE_SETUP
-#line 75 "lexer.l"
+#line 74 "lexer.l"
+{ return yytext[0];}
+ YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 76 "lexer.l"
{
return enter(yytext[0], YY_START, yyscanner);
}
YY_BREAK
-case 35:
+case 36:
YY_RULE_SETUP
-#line 79 "lexer.l"
+#line 80 "lexer.l"
{
return try_exit(yytext[0], YY_START, yyscanner);
}
YY_BREAK
-case 36:
+case 37:
YY_RULE_SETUP
-#line 83 "lexer.l"
+#line 84 "lexer.l"
{
yylval->literal = jv_string_sized(yytext + 1, yyleng - 1); return FORMAT;
}
YY_BREAK
-case 37:
+case 38:
YY_RULE_SETUP
-#line 87 "lexer.l"
+#line 88 "lexer.l"
{
yylval->literal = jv_parse_sized(yytext, yyleng); return LITERAL;
}
YY_BREAK
-case 38:
+case 39:
YY_RULE_SETUP
-#line 91 "lexer.l"
+#line 92 "lexer.l"
{
yy_push_state(IN_QQSTRING, yyscanner);
return QQSTRING_START;
}
YY_BREAK
-case 39:
+case 40:
YY_RULE_SETUP
-#line 97 "lexer.l"
+#line 98 "lexer.l"
{
return enter(QQSTRING_INTERP_START, YY_START, yyscanner);
}
YY_BREAK
-case 40:
+case 41:
YY_RULE_SETUP
-#line 100 "lexer.l"
+#line 101 "lexer.l"
{
yy_pop_state(yyscanner);
return QQSTRING_END;
}
YY_BREAK
-case 41:
-/* rule 41 can match eol */
+case 42:
+/* rule 42 can match eol */
YY_RULE_SETUP
-#line 104 "lexer.l"
+#line 105 "lexer.l"
{
/* pass escapes to the json parser */
jv escapes = jv_string_fmt("\"%.*s\"", (int)yyleng, yytext);
@@ -1162,50 +1174,50 @@ YY_RULE_SETUP
return QQSTRING_TEXT;
}
YY_BREAK
-case 42:
-/* rule 42 can match eol */
+case 43:
+/* rule 43 can match eol */
YY_RULE_SETUP
-#line 111 "lexer.l"
+#line 112 "lexer.l"
{
yylval->literal = jv_string_sized(yytext, yyleng);
return QQSTRING_TEXT;
}
YY_BREAK
-case 43:
+case 44:
YY_RULE_SETUP
-#line 115 "lexer.l"
+#line 116 "lexer.l"
{
return INVALID_CHARACTER;
}
YY_BREAK
-case 44:
+case 45:
YY_RULE_SETUP
-#line 121 "lexer.l"
+#line 122 "lexer.l"
{ yylval->literal = jv_string(yytext); return IDENT;}
YY_BREAK
-case 45:
+case 46:
YY_RULE_SETUP
-#line 122 "lexer.l"
+#line 123 "lexer.l"
{ yylval->literal = jv_string(yytext+1); return FIELD;}
YY_BREAK
-case 46:
-/* rule 46 can match eol */
+case 47:
+/* rule 47 can match eol */
YY_RULE_SETUP
-#line 124 "lexer.l"
+#line 125 "lexer.l"
{}
YY_BREAK
-case 47:
+case 48:
YY_RULE_SETUP
-#line 126 "lexer.l"
+#line 127 "lexer.l"
{ return INVALID_CHARACTER; }
YY_BREAK
-case 48:
+case 49:
YY_RULE_SETUP
-#line 128 "lexer.l"
+#line 129 "lexer.l"
YY_FATAL_ERROR( "flex scanner jammed" );
YY_BREAK
-#line 1209 "lexer.c"
+#line 1221 "lexer.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(IN_PAREN):
case YY_STATE_EOF(IN_BRACKET):
@@ -1504,7 +1516,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 >= 148 )
+ if ( yy_current_state >= 154 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -1533,11 +1545,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 >= 148 )
+ if ( yy_current_state >= 154 )
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 == 147);
+ yy_is_jam = (yy_current_state == 153);
return yy_is_jam ? 0 : yy_current_state;
}
@@ -2369,7 +2381,7 @@ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
-#line 128 "lexer.l"
+#line 129 "lexer.l"
/* perhaps these should be calls... */
diff --git a/lexer.h b/lexer.h
index 9e0ecef8..0eb85067 100644
--- a/lexer.h
+++ b/lexer.h
@@ -354,7 +354,7 @@ extern int jq_yylex \
#undef YY_DECL
#endif
-#line 128 "lexer.l"
+#line 129 "lexer.l"
#line 361 "lexer.h"
diff --git a/lexer.l b/lexer.l
index 98ea9167..8e461810 100644
--- a/lexer.l
+++ b/lexer.l
@@ -43,6 +43,7 @@ struct lexer_param;
"==" { return EQ; }
"as" { return AS; }
"import" { return IMPORT; }
+"include" { return INCLUDE; }
"module" { return MODULE; }
"def" { return DEF; }
"if" { return IF; }
diff --git a/parser.c b/parser.c
index 75584b99..c210a758 100644
--- a/parser.c
+++ b/parser.c
@@ -142,33 +142,34 @@ struct lexer_param;
DEF = 269,
MODULE = 270,
IMPORT = 271,
- IF = 272,
- THEN = 273,
- ELSE = 274,
- ELSE_IF = 275,
- REDUCE = 276,
- FOREACH = 277,
- END = 278,
- AND = 279,
- OR = 280,
- TRY = 281,
- CATCH = 282,
- LABEL = 283,
- BREAK = 284,
- 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
+ INCLUDE = 272,
+ IF = 273,
+ THEN = 274,
+ ELSE = 275,
+ ELSE_IF = 276,
+ REDUCE = 277,
+ FOREACH = 278,
+ END = 279,
+ AND = 280,
+ OR = 281,
+ TRY = 282,
+ CATCH = 283,
+ LABEL = 284,
+ BREAK = 285,
+ LOC = 286,
+ SETPIPE = 287,
+ SETPLUS = 288,
+ SETMINUS = 289,
+ SETMULT = 290,
+ SETDIV = 291,
+ SETDEFINEDOR = 292,
+ LESSEQ = 293,
+ GREATEREQ = 294,
+ QQSTRING_START = 295,
+ QQSTRING_TEXT = 296,
+ QQSTRING_INTERP_START = 297,
+ QQSTRING_INTERP_END = 298,
+ QQSTRING_END = 299
};
#endif
/* Tokens. */
@@ -186,33 +187,34 @@ struct lexer_param;
#define DEF 269
#define MODULE 270
#define IMPORT 271
-#define IF 272
-#define THEN 273
-#define ELSE 274
-#define ELSE_IF 275
-#define REDUCE 276
-#define FOREACH 277
-#define END 278
-#define AND 279
-#define OR 280
-#define TRY 281
-#define CATCH 282
-#define LABEL 283
-#define BREAK 284
-#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
+#define INCLUDE 272
+#define IF 273
+#define THEN 274
+#define ELSE 275
+#define ELSE_IF 276
+#define REDUCE 277
+#define FOREACH 278
+#define END 279
+#define AND 280
+#define OR 281
+#define TRY 282
+#define CATCH 283
+#define LABEL 284
+#define BREAK 285
+#define LOC 286
+#define SETPIPE 287
+#define SETPLUS 288
+#define SETMINUS 289
+#define SETMULT 290
+#define SETDIV 291
+#define SETDEFINEDOR 292
+#define LESSEQ 293
+#define GREATEREQ 294
+#define QQSTRING_START 295
+#define QQSTRING_TEXT 296
+#define QQSTRING_INTERP_START 297
+#define QQSTRING_INTERP_END 298
+#define QQSTRING_END 299
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
@@ -224,7 +226,7 @@ union YYSTYPE
jv literal;
block blk;
-#line 228 "parser.c" /* yacc.c:355 */
+#line 230 "parser.c" /* yacc.c:355 */
};
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
@@ -251,7 +253,7 @@ int yyparse (block* answer, int* errors, struct locfile* locations, struct lexer
#endif /* !YY_YY_PARSER_H_INCLUDED */
/* Copy the second part of user declarations. */
-#line 113 "parser.y" /* yacc.c:358 */
+#line 114 "parser.y" /* yacc.c:358 */
#include "lexer.h"
struct lexer_param {
@@ -407,7 +409,7 @@ static block gen_update(block object, block val, int optype) {
}
-#line 411 "parser.c" /* yacc.c:358 */
+#line 413 "parser.c" /* yacc.c:358 */
#ifdef short
# undef short
@@ -651,21 +653,21 @@ union yyalloc
/* YYFINAL -- State number of the termination state. */
#define YYFINAL 27
/* YYLAST -- Last index in YYTABLE. */
-#define YYLAST 2061
+#define YYLAST 2015
/* YYNTOKENS -- Number of terminals. */
-#define YYNTOKENS 65
+#define YYNTOKENS 66
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS 26
/* YYNRULES -- Number of rules. */
-#define YYNRULES 155
+#define YYNRULES 156
/* YYNSTATES -- Number of states. */
-#define YYNSTATES 307
+#define YYNSTATES 310
/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
by yylex, with out-of-bounds checking. */
#define YYUNDEFTOK 2
-#define YYMAXUTOK 298
+#define YYMAXUTOK 299
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -677,16 +679,16 @@ static const yytype_uint8 yytranslate[] =
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 58, 53, 2, 2,
- 56, 57, 51, 49, 45, 50, 60, 52, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 59, 55,
- 47, 46, 48, 54, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 59, 54, 2, 2,
+ 57, 58, 52, 50, 46, 51, 61, 53, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 60, 56,
+ 48, 47, 49, 55, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 61, 2, 62, 2, 2, 2, 2, 2, 2,
+ 2, 62, 2, 63, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 63, 44, 64, 2, 2, 2, 2,
+ 2, 2, 2, 64, 45, 65, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -703,29 +705,29 @@ static const yytype_uint8 yytranslate[] =
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43
+ 35, 36, 37, 38, 39, 40, 41, 42, 43, 44
};
#if YYDEBUG
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 271, 271, 274, 279, 282, 292, 295, 300, 303,
- 308, 312, 316, 320, 324, 328, 331, 336, 340, 344,
- 349, 361, 365, 369, 373, 377, 381, 385, 389, 393,
- 397, 401, 405, 409, 413, 417, 421, 425, 431, 437,
- 441, 445, 449, 453, 457, 461, 465, 469, 474, 483,
- 490, 496, 508, 519, 533, 538, 544, 547, 552, 557,
- 564, 564, 568, 568, 575, 578, 581, 587, 590, 595,
- 598, 601, 607, 610, 613, 621, 625, 628, 631, 634,
- 637, 640, 643, 646, 649, 653, 659, 662, 665, 668,
- 671, 674, 677, 680, 683, 686, 689, 692, 695, 698,
- 701, 704, 707, 714, 718, 722, 734, 739, 740, 741,
- 742, 745, 748, 753, 758, 762, 765, 770, 773, 778,
- 781, 786, 789, 792, 795, 798, 803, 806, 809, 812,
- 815, 818, 821, 824, 827, 830, 833, 836, 839, 842,
- 845, 848, 851, 854, 859, 862, 863, 864, 867, 870,
- 873, 876, 880, 884, 888, 891
+ 0, 272, 272, 275, 280, 283, 293, 296, 301, 304,
+ 309, 313, 317, 321, 325, 329, 332, 337, 341, 345,
+ 350, 362, 366, 370, 374, 378, 382, 386, 390, 394,
+ 398, 402, 406, 410, 414, 418, 422, 426, 432, 438,
+ 442, 446, 450, 454, 458, 462, 466, 470, 475, 484,
+ 491, 497, 509, 520, 534, 539, 545, 548, 553, 558,
+ 565, 565, 569, 569, 576, 579, 582, 588, 591, 596,
+ 599, 602, 608, 611, 614, 622, 626, 629, 632, 635,
+ 638, 641, 644, 647, 650, 654, 660, 663, 666, 669,
+ 672, 675, 678, 681, 684, 687, 690, 693, 696, 699,
+ 702, 705, 708, 715, 719, 723, 735, 740, 741, 742,
+ 743, 746, 749, 754, 759, 763, 766, 771, 774, 779,
+ 782, 787, 790, 793, 796, 799, 804, 807, 810, 813,
+ 816, 819, 822, 825, 828, 831, 834, 837, 840, 843,
+ 846, 849, 852, 855, 858, 863, 866, 867, 868, 871,
+ 874, 877, 880, 884