From 361f9e7f8d72d98319e1d2a061e2aa1310fe4254 Mon Sep 17 00:00:00 2001 From: "Thomas G. Lockhart" Date: Sun, 30 Nov 1997 23:05:39 +0000 Subject: [PATCH] Add comments and move a few declaration blocks to help readability. No functional changes this time! --- src/backend/parser/scan.c | 386 ++++++++++++++++++++------------------ src/backend/parser/scan.l | 82 ++++---- 2 files changed, 247 insertions(+), 221 deletions(-) diff --git a/src/backend/parser/scan.c b/src/backend/parser/scan.c index cc9aaac646..646dac830e 100644 --- a/src/backend/parser/scan.c +++ b/src/backend/parser/scan.c @@ -1,7 +1,7 @@ /* A lexical scanner generated by flex */ /* Scanner skeleton version: - * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.3 1997/11/26 01:11:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.4 1997/11/30 23:05:39 thomas Exp $ */ #define FLEX_SCANNER @@ -288,20 +288,20 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); #define YY_END_OF_BUFFER 41 static yyconst short int yy_acclist[163] = { 0, - 10, 10, 6, 6, 24, 24, 9, 9, 18, 18, - 25, 25, 41, 39, 40, 38, 39, 40, 38, 40, + 10, 10, 6, 6, 24, 24, 9, 9, 25, 25, + 18, 18, 41, 39, 40, 38, 39, 40, 38, 40, 31, 39, 40, 22, 39, 40, 29, 31, 39, 40, 15, 39, 40, 29, 39, 40, 29, 31, 39, 40, 29, 31, 39, 40, 29, 31, 39, 40, 35, 39, 40,16417, 29, 31, 39, 40, 37, 39, 40, 37, 39, 40, 37, 39, 40, 10, 40, 8, 40, 3, 6, 40, 3, 6, 40, 3, 40, 6, 40, 24, - 40, 23, 40, 9, 40, 14, 40, 18, 40, 16, - 40, 40, 40, 25, 40, 26, 40, 31, 31, 31, + 40, 23, 40, 9, 40, 14, 40, 40, 25, 40, + 26, 40, 18, 40, 16, 40, 40, 31, 31, 31, 32, 31, 31, 35,16417, 4, 31, 31, 27, 31, - 37, 7, 13, 10, 6, 6, 5, 24, 9, 18, - 17, 20, 19, 20, 25, 30, 28, 30, 28, 30, + 37, 7, 13, 10, 6, 6, 5, 24, 9, 25, + 18, 17, 20, 19, 20, 30, 28, 30, 28, 30, 32, 28, 1, 31, 31, 28, 30, 4, 31, 4, 31, 4, 31, 8225, 36,16418, 12, 5, 11, 21, 30, 2, 4, 31, 30, 2, 2, 2, 8226, 36, @@ -314,11 +314,11 @@ static yyconst short int yy_accept[125] = 9, 10, 11, 12, 13, 14, 16, 19, 21, 24, 27, 31, 34, 37, 41, 45, 49, 53, 57, 60, 63, 66, 68, 70, 73, 76, 78, 80, 82, 84, - 86, 88, 90, 92, 93, 94, 96, 98, 99, 100, + 86, 88, 89, 91, 93, 95, 97, 98, 99, 100, 101, 102, 102, 103, 104, 106, 108, 109, 109, 109, 109, 111, 112, 113, 114, 115, 115, 115, 116, 117, - 117, 117, 118, 119, 120, 120, 120, 121, 121, 121, - 122, 123, 125, 126, 127, 129, 132, 133, 133, 134, + 117, 117, 118, 119, 120, 120, 120, 121, 122, 122, + 122, 123, 124, 126, 127, 129, 132, 133, 133, 134, 135, 136, 138, 138, 140, 142, 144, 145, 147, 147, 147, 148, 149, 149, 149, 150, 150, 150, 151, 152, @@ -367,22 +367,22 @@ static yyconst int yy_meta[22] = static yyconst short int yy_base[142] = { 0, - 0, 0, 323, 311, 18, 31, 304, 303, 232, 224, - 18, 29, 46, 49, 221, 401, 401, 401, 204, 401, - 12, 401, 196, 189, 42, 50, 62, 43, 0, 186, - 164, 0, 64, 0, 73, 59, 0, 0, 401, 0, - 67, 0, 78, 154, 401, 88, 401, 144, 81, 18, - 135, 31, 129, 95, 0, 113, 106, 128, 0, 120, - 110, 0, 401, 401, 0, 130, 133, 0, 0, 62, - 85, 135, 0, 0, 139, 143, 0, 145, 149, 401, - 401, 401, 151, 401, 401, 73, 401, 153, 401, 166, - 113, 0, 69, 179, 49, 146, 401, 194, 171, 184, - - 401, 196, 199, 207, 401, 209, 215, 401, 0, 171, - 201, 46, 217, 0, 213, 223, 227, 231, 401, 24, - 221, 235, 401, 240, 251, 262, 273, 284, 295, 304, - 303, 313, 324, 333, 340, 351, 362, 372, 383, 388, - 391 + 0, 0, 355, 344, 18, 31, 334, 328, 325, 318, + 46, 48, 18, 31, 313, 396, 396, 396, 293, 396, + 12, 396, 292, 203, 42, 49, 61, 21, 0, 199, + 196, 0, 52, 0, 72, 52, 0, 0, 396, 0, + 64, 396, 66, 396, 0, 77, 192, 181, 78, 31, + 169, 79, 165, 93, 0, 111, 104, 126, 0, 156, + 135, 0, 396, 396, 0, 68, 128, 0, 0, 110, + 129, 130, 0, 0, 138, 140, 142, 0, 146, 148, + 396, 396, 396, 396, 396, 111, 396, 152, 396, 165, + 122, 0, 77, 178, 64, 140, 396, 193, 170, 183, + + 396, 157, 195, 198, 396, 206, 208, 396, 0, 144, + 214, 65, 216, 0, 210, 220, 223, 228, 396, 16, + 214, 232, 396, 235, 246, 257, 268, 279, 290, 299, + 298, 308, 319, 328, 335, 346, 357, 367, 378, 383, + 386 } ; static yyconst short int yy_def[142] = @@ -391,10 +391,10 @@ static yyconst short int yy_def[142] = 128, 128, 129, 129, 123, 123, 123, 123, 130, 123, 130, 123, 123, 130, 130, 130, 123, 130, 131, 131, 131, 132, 123, 133, 133, 134, 35, 135, 123, 136, - 123, 137, 123, 138, 123, 123, 123, 130, 130, 49, + 123, 123, 123, 123, 137, 123, 138, 130, 130, 49, 123, 123, 50, 123, 27, 139, 54, 123, 140, 123, 130, 131, 123, 123, 132, 123, 123, 133, 35, 134, - 134, 134, 135, 136, 123, 123, 137, 123, 123, 123, + 134, 134, 135, 136, 123, 123, 123, 137, 123, 123, 123, 123, 123, 123, 123, 123, 123, 54, 123, 88, 90, 88, 139, 139, 94, 94, 123, 123, 123, 123, @@ -405,106 +405,104 @@ static yyconst short int yy_def[142] = 123 } ; -static yyconst short int yy_nxt[423] = +static yyconst short int yy_nxt[418] = { 0, 16, 17, 18, 19, 20, 21, 22, 23, 24, 24, 25, 23, 26, 27, 28, 24, 29, 30, 29, 31, - 16, 35, 50, 35, 43, 51, 36, 35, 35, 85, - 37, 86, 35, 35, 35, 43, 35, 121, 44, 36, - 35, 35, 87, 37, 87, 35, 35, 46, 46, 44, - 46, 46, 54, 53, 110, 55, 47, 61, 56, 47, - 53, 111, 57, 58, 58, 66, 67, 70, 75, 76, - 70, 72, 59, 60, 72, 55, 69, 110, 69, 78, - 79, 70, 69, 69, 80, 69, 51, 69, 69, 83, - 83, 49, 84, 70, 84, 88, 88, 89, 90, 88, - - 90, 88, 88, 90, 90, 91, 92, 90, 92, 90, - 90, 88, 88, 88, 88, 88, 94, 88, 94, 88, - 49, 95, 94, 96, 109, 94, 109, 94, 94, 58, - 58, 66, 67, 98, 99, 100, 102, 102, 59, 101, - 75, 76, 85, 70, 103, 104, 78, 79, 51, 105, - 106, 107, 83, 83, 49, 108, 88, 112, 88, 112, - 82, 88, 88, 88, 88, 88, 88, 88, 88, 90, - 64, 90, 99, 100, 90, 90, 91, 101, 90, 110, - 90, 90, 94, 116, 94, 99, 100, 95, 94, 96, - 101, 94, 63, 94, 94, 113, 113, 102, 102, 53, - - 103, 104, 117, 118, 114, 105, 52, 98, 103, 104, - 106, 107, 115, 105, 49, 108, 106, 107, 113, 113, - 123, 108, 120, 120, 117, 118, 121, 114, 117, 118, - 41, 110, 122, 118, 121, 110, 122, 118, 41, 123, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 34, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 38, 38, 40, 40, 40, 40, 40, 40, 40, - 40, 40, 40, 40, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 45, 45, 45, 45, 45, - - 45, 45, 45, 45, 45, 45, 48, 39, 39, 48, - 48, 62, 62, 65, 65, 65, 65, 33, 65, 65, - 65, 65, 65, 65, 68, 68, 68, 68, 68, 33, - 68, 68, 68, 68, 68, 71, 123, 123, 71, 71, - 73, 73, 73, 123, 73, 73, 73, 73, 73, 73, - 73, 74, 74, 74, 74, 123, 74, 74, 74, 74, - 74, 74, 77, 77, 77, 77, 123, 77, 77, 77, - 77, 77, 81, 81, 81, 81, 81, 81, 81, 81, - 81, 81, 81, 93, 123, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 97, 97, 97, 119, 119, 119, - - 15, 123, 123, 123, 123, 123, 123, 123, 123, 123, + 16, 35, 50, 35, 46, 51, 36, 35, 35, 121, + 37, 53, 35, 35, 35, 61, 35, 46, 47, 36, + 35, 35, 85, 37, 86, 35, 35, 43, 43, 43, + 43, 47, 54, 66, 67, 55, 44, 56, 44, 53, + 70, 57, 58, 58, 72, 75, 76, 77, 77, 66, + 67, 59, 60, 110, 55, 69, 111, 69, 79, 80, + 70, 69, 69, 81, 69, 110, 69, 69, 49, 84, + 87, 84, 87, 88, 88, 89, 90, 88, 90, 88, + + 88, 90, 90, 91, 92, 90, 92, 90, 90, 88, + 88, 88, 88, 88, 94, 88, 94, 88, 70, 95, + 94, 96, 72, 94, 51, 94, 94, 58, 58, 99, + 100, 102, 102, 109, 101, 109, 59, 70, 70, 75, + 76, 103, 104, 77, 77, 49, 105, 79, 80, 106, + 107, 112, 110, 112, 108, 88, 116, 88, 102, 102, + 88, 88, 88, 88, 88, 88, 88, 88, 90, 98, + 90, 99, 100, 90, 90, 91, 101, 90, 85, 90, + 90, 94, 51, 94, 99, 100, 95, 94, 96, 101, + 94, 49, 94, 94, 113, 113, 103, 104, 83, 103, + + 104, 105, 64, 114, 105, 63, 98, 106, 107, 106, + 107, 115, 108, 53, 108, 117, 118, 113, 113, 120, + 120, 117, 118, 121, 117, 118, 114, 121, 110, 122, + 118, 110, 123, 122, 118, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 40, 40, + 40, 40, 40, 40, 40, 40, 40, 40, 40, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, + + 45, 48, 52, 49, 48, 48, 62, 62, 65, 65, + 65, 65, 123, 65, 65, 65, 65, 65, 65, 68, + 68, 68, 68, 68, 41, 68, 68, 68, 68, 68, + 71, 41, 39, 71, 71, 73, 73, 73, 39, 73, + 73, 73, 73, 73, 73, 73, 74, 74, 74, 74, + 33, 74, 74, 74, 74, 74, 74, 78, 78, 78, + 78, 33, 78, 78, 78, 78, 78, 82, 82, 82, + 82, 82, 82, 82, 82, 82, 82, 82, 93, 123, + 93, 93, 93, 93, 93, 93, 93, 93, 93, 97, + 97, 97, 119, 119, 119, 15, 123, 123, 123, 123, + 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123 + 123, 123, 123, 123, 123, 123, 123 } ; -static yyconst short int yy_chk[423] = +static yyconst short int yy_chk[418] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 5, 21, 5, 11, 21, 5, 5, 5, 50, - 5, 50, 5, 5, 6, 12, 6, 120, 11, 6, - 6, 6, 52, 6, 52, 6, 6, 13, 13, 12, - 14, 14, 25, 28, 112, 25, 13, 28, 26, 14, - 26, 95, 26, 27, 27, 33, 33, 36, 41, 41, - 70, 36, 27, 27, 70, 27, 35, 93, 35, 43, - 43, 35, 35, 35, 43, 35, 86, 35, 35, 46, - 46, 49, 49, 71, 49, 54, 54, 54, 54, 54, + 1, 5, 21, 5, 13, 21, 5, 5, 5, 120, + 5, 28, 5, 5, 6, 28, 6, 14, 13, 6, + 6, 6, 50, 6, 50, 6, 6, 11, 11, 12, + 12, 14, 25, 33, 33, 25, 11, 26, 12, 26, + 36, 26, 27, 27, 36, 41, 41, 43, 43, 66, + 66, 27, 27, 112, 27, 35, 95, 35, 46, 46, + 35, 35, 35, 46, 35, 93, 35, 35, 49, 49, + 52, 49, 52, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, - 54, 54, 54, 54, 54, 54, 56, 57, 56, 57, - 61, 56, 56, 56, 91, 56, 91, 56, 56, 58, - 58, 66, 66, 60, 67, 67, 72, 72, 58, 67, - 75, 75, 53, 72, 76, 76, 78, 78, 51, 76, - 79, 79, 83, 83, 48, 79, 88, 96, 88, 96, - 44, 88, 88, 88, 88, 88, 88, 88, 88, 90, - 31, 90, 99, 99, 90, 90, 90, 99, 90, 110, - 90, 90, 94, 110, 94, 100, 100, 94, 94, 94, - 100, 94, 30, 94, 94, 98, 98, 102, 102, 24, - - 103, 103, 111, 111, 98, 103, 23, 98, 104, 104, - 106, 106, 98, 104, 19, 106, 107, 107, 113, 113, - 15, 107, 115, 115, 116, 116, 115, 113, 117, 117, - 10, 116, 118, 118, 121, 117, 122, 122, 9, 121, - 124, 124, 124, 124, 124, 124, 124, 124, 124, 124, - 124, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 126, 126, 126, 126, 126, 126, 126, 126, - 126, 126, 126, 127, 127, 127, 127, 127, 127, 127, - 127, 127, 127, 127, 128, 128, 128, 128, 128, 128, - 128, 128, 128, 128, 128, 129, 129, 129, 129, 129, - - 129, 129, 129, 129, 129, 129, 130, 8, 7, 130, - 130, 131, 131, 132, 132, 132, 132, 4, 132, 132, - 132, 132, 132, 132, 133, 133, 133, 133, 133, 3, - 133, 133, 133, 133, 133, 134, 0, 0, 134, 134, - 135, 135, 135, 0, 135, 135, 135, 135, 135, 135, - 135, 136, 136, 136, 136, 0, 136, 136, 136, 136, - 136, 136, 137, 137, 137, 137, 0, 137, 137, 137, - 137, 137, 138, 138, 138, 138, 138, 138, 138, 138, - 138, 138, 138, 139, 0, 139, 139, 139, 139, 139, - 139, 139, 139, 139, 140, 140, 140, 141, 141, 141, + 54, 54, 54, 54, 56, 57, 56, 57, 70, 56, + 56, 56, 70, 56, 86, 56, 56, 58, 58, 67, + 67, 72, 72, 91, 67, 91, 58, 71, 72, 75, + 75, 76, 76, 77, 77, 61, 76, 79, 79, 80, + 80, 96, 110, 96, 80, 88, 110, 88, 102, 102, + 88, 88, 88, 88, 88, 88, 88, 88, 90, 60, + 90, 99, 99, 90, 90, 90, 99, 90, 53, 90, + 90, 94, 51, 94, 100, 100, 94, 94, 94, 100, + 94, 48, 94, 94, 98, 98, 103, 103, 47, 104, + + 104, 103, 31, 98, 104, 30, 98, 106, 106, 107, + 107, 98, 106, 24, 107, 111, 111, 113, 113, 115, + 115, 116, 116, 115, 117, 117, 113, 121, 116, 118, + 118, 117, 121, 122, 122, 124, 124, 124, 124, 124, + 124, 124, 124, 124, 124, 124, 125, 125, 125, 125, + 125, 125, 125, 125, 125, 125, 125, 126, 126, 126, + 126, 126, 126, 126, 126, 126, 126, 126, 127, 127, + 127, 127, 127, 127, 127, 127, 127, 127, 127, 128, + 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, + 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, + + 129, 130, 23, 19, 130, 130, 131, 131, 132, 132, + 132, 132, 15, 132, 132, 132, 132, 132, 132, 133, + 133, 133, 133, 133, 10, 133, 133, 133, 133, 133, + 134, 9, 8, 134, 134, 135, 135, 135, 7, 135, + 135, 135, 135, 135, 135, 135, 136, 136, 136, 136, + 4, 136, 136, 136, 136, 136, 136, 137, 137, 137, + 137, 3, 137, 137, 137, 137, 137, 138, 138, 138, + 138, 138, 138, 138, 138, 138, 138, 138, 139, 0, + 139, 139, 139, 139, 139, 139, 139, 139, 139, 140, + 140, 140, 141, 141, 141, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123, 123, 123, 123, 123, 123, 123, 123, 123, - 123, 123 + 123, 123, 123, 123, 123, 123, 123 } ; static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr; @@ -541,7 +539,7 @@ char *yytext; * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.3 1997/11/26 01:11:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/Attic/scan.c,v 1.4 1997/11/30 23:05:39 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -593,28 +591,28 @@ int llen; char literal[MAX_PARSE_BUFFER]; /* OK, here is a short description of lex/flex rules behavior. -* The longest pattern which matches an input string is always chosen. -* For equal-length patterns, the first occurring in the rules list is chosen. -* INITIAL is the starting condition, to which all non-conditional rules apply. -* When in an exclusive condition, only those rules defined for that condition apply. -* -* Exclusive states change parsing rules while the state is active. -* There are exclusive states for quoted strings, extended comments, -* and to eliminate parsing troubles for numeric strings. -* Exclusive states: -* binary numeric string - thomas 1997-11-16 -* hexadecimal numeric string - thomas 1997-11-16 -* extended C-style comments - tgl 1997-07-12 -* quoted strings - tgl 1997-07-30 -* numeric strings with embedded minus sign - tgl 1997-09-05 -* delimited identifiers (double-quoted identifiers) - tgl 1997-10-27 -* -* The "extended comment" syntax closely resembles allowable operator syntax. -* So, when in condition , only strings which would terminate the -* "extended comment" trigger any action other than "ignore". -* Be sure to match _any_ candidate comment, including those with appended -* operator-like symbols. - thomas 1997-07-14 -*/ + * The longest pattern which matches an input string is always chosen. + * For equal-length patterns, the first occurring in the rules list is chosen. + * INITIAL is the starting condition, to which all non-conditional rules apply. + * When in an exclusive condition, only those rules defined for that condition apply. + * + * Exclusive states change parsing rules while the state is active. + * There are exclusive states for quoted strings, extended comments, + * and to eliminate parsing troubles for numeric strings. + * Exclusive states: + * binary numeric string - thomas 1997-11-16 + * extended C-style comments - tgl 1997-07-12 + * delimited identifiers (double-quoted identifiers) - tgl 1997-10-27 + * hexadecimal numeric string - thomas 1997-11-16 + * numeric strings with embedded minus sign - tgl 1997-09-05 + * quoted strings - tgl 1997-07-30 + * + * The "extended comment" syntax closely resembles allowable operator syntax. + * So, when in condition , only strings which would terminate the + * "extended comment" trigger any action other than "ignore". + * Be sure to match _any_ candidate comment, including those with appended + * operator-like symbols. - thomas 1997-07-14 + */ #define xb 1 #define xc 2 @@ -623,10 +621,24 @@ char literal[MAX_PARSE_BUFFER]; #define xh 4 -#define xq 5 +#define xm 5 -#define xm 6 +#define xq 6 +/* Binary number + */ +/* Hexadecimal number + */ +/* Extended quote + * xqdouble implements SQL92 embedded quote + * xqcat allows strings to cross input lines + */ +/* Delimited quote + * Allows embedded spaces and other special characters into identifiers. + */ +/* Comments + * Ignored by the scanner and parser. + */ /* DO NOT PUT ANY COMMENTS IN THE FOLLOWING SECTION. * AT&T lex does not properly handle C-style comments in this second lex block. * So, put comments here. tgl - 1997-09-08 @@ -639,7 +651,7 @@ char literal[MAX_PARSE_BUFFER]; * Other embedded escaped characters are matched explicitly and the leading * backslash is dropped from the string. - thomas 1997-09-24 */ -#line 643 "lex.yy.c" +#line 655 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -790,9 +802,9 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 164 "scan.l" +#line 178 "scan.l" -#line 796 "lex.yy.c" +#line 808 "lex.yy.c" if ( yy_init ) { @@ -847,7 +859,7 @@ yy_match: *yy_state_ptr++ = yy_current_state; ++yy_cp; } - while ( yy_base[yy_current_state] != 401 ); + while ( yy_base[yy_current_state] != 396 ); yy_find_action: yy_current_state = *--yy_state_ptr; @@ -898,34 +910,34 @@ do_action: /* This label is used only to access EOF actions. */ { /* beginning of action switch */ case 1: YY_RULE_SETUP -#line 165 "scan.l" +#line 179 "scan.l" { /* ignore */ } YY_BREAK case 2: YY_RULE_SETUP -#line 167 "scan.l" +#line 181 "scan.l" { /* ignore */ } YY_BREAK case 3: -#line 170 "scan.l" +#line 184 "scan.l" case 4: YY_RULE_SETUP -#line 170 "scan.l" +#line 184 "scan.l" { BEGIN(xc); } YY_BREAK case 5: YY_RULE_SETUP -#line 172 "scan.l" +#line 186 "scan.l" { BEGIN(INITIAL); } YY_BREAK case 6: YY_RULE_SETUP -#line 174 "scan.l" +#line 188 "scan.l" { /* ignore */ } YY_BREAK case 7: YY_RULE_SETUP -#line 176 "scan.l" +#line 190 "scan.l" { BEGIN(xb); llen = 0; @@ -934,7 +946,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 181 "scan.l" +#line 195 "scan.l" { char* endptr; @@ -947,10 +959,10 @@ YY_RULE_SETUP } YY_BREAK case 9: -#line 192 "scan.l" +#line 206 "scan.l" case 10: YY_RULE_SETUP -#line 192 "scan.l" +#line 206 "scan.l" { if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1)) elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER); @@ -959,16 +971,16 @@ YY_RULE_SETUP } YY_BREAK case 11: -#line 199 "scan.l" +#line 213 "scan.l" case 12: YY_RULE_SETUP -#line 199 "scan.l" +#line 213 "scan.l" { } YY_BREAK case 13: YY_RULE_SETUP -#line 202 "scan.l" +#line 216 "scan.l" { BEGIN(xh); llen = 0; @@ -977,7 +989,7 @@ YY_RULE_SETUP YY_BREAK case 14: YY_RULE_SETUP -#line 207 "scan.l" +#line 221 "scan.l" { char* endptr; @@ -991,7 +1003,7 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 218 "scan.l" +#line 232 "scan.l" { BEGIN(xq); llen = 0; @@ -1000,7 +1012,7 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 223 "scan.l" +#line 237 "scan.l" { BEGIN(INITIAL); yylval.str = pstrdup(scanstr(literal)); @@ -1008,10 +1020,10 @@ YY_RULE_SETUP } YY_BREAK case 17: -#line 229 "scan.l" +#line 243 "scan.l" case 18: YY_RULE_SETUP -#line 229 "scan.l" +#line 243 "scan.l" { if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1)) elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER); @@ -1021,7 +1033,7 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 235 "scan.l" +#line 249 "scan.l" { if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1)) elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER); @@ -1032,7 +1044,7 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 243 "scan.l" +#line 257 "scan.l" { if ((llen+yyleng-1) > (MAX_PARSE_BUFFER - 1)) elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER); @@ -1042,13 +1054,13 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 249 "scan.l" +#line 263 "scan.l" { } YY_BREAK case 22: YY_RULE_SETUP -#line 253 "scan.l" +#line 267 "scan.l" { BEGIN(xd); llen = 0; @@ -1057,7 +1069,7 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 258 "scan.l" +#line 272 "scan.l" { BEGIN(INITIAL); yylval.str = pstrdup(literal); @@ -1066,7 +1078,7 @@ YY_RULE_SETUP YY_BREAK case 24: YY_RULE_SETUP -#line 263 "scan.l" +#line 277 "scan.l" { if ((llen+yyleng) > (MAX_PARSE_BUFFER - 1)) elog(WARN,"quoted string parse buffer of %d chars exceeded",MAX_PARSE_BUFFER); @@ -1076,12 +1088,12 @@ YY_RULE_SETUP YY_BREAK case 25: YY_RULE_SETUP -#line 271 "scan.l" +#line 285 "scan.l" { /* ignore */ } YY_BREAK case 26: YY_RULE_SETUP -#line 272 "scan.l" +#line 286 "scan.l" { BEGIN(INITIAL); return (yytext[0]); @@ -1089,7 +1101,7 @@ YY_RULE_SETUP YY_BREAK case 27: YY_RULE_SETUP -#line 278 "scan.l" +#line 292 "scan.l" { return TYPECAST; } YY_BREAK case 28: @@ -1097,14 +1109,14 @@ case 28: yy_c_buf_p = yy_cp = yy_bp + 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 280 "scan.l" +#line 294 "scan.l" { return (yytext[0]); } YY_BREAK case 29: YY_RULE_SETUP -#line 283 "scan.l" +#line 297 "scan.l" { return (yytext[0]); } YY_BREAK case 30: @@ -1112,7 +1124,7 @@ case 30: yy_c_buf_p = yy_cp -= 2; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 284 "scan.l" +#line 298 "scan.l" { yylval.str = pstrdup((char*)yytext); return (Op); @@ -1120,7 +1132,7 @@ YY_RULE_SETUP YY_BREAK case 31: YY_RULE_SETUP -#line 288 "scan.l" +#line 302 "scan.l" { if (strcmp((char*)yytext,"!=") == 0) yylval.str = pstrdup("<>"); /* compatability */ @@ -1131,7 +1143,7 @@ YY_RULE_SETUP YY_BREAK case 32: YY_RULE_SETUP -#line 295 "scan.l" +#line 309 "scan.l" { yylval.ival = atoi((char*)&yytext[1]); return (PARAM); @@ -1139,7 +1151,7 @@ YY_RULE_SETUP YY_BREAK case 33: YY_RULE_SETUP -#line 300 "scan.l" +#line 314 "scan.l" { char* endptr; @@ -1153,7 +1165,7 @@ YY_RULE_SETUP YY_BREAK case 34: YY_RULE_SETUP -#line 310 "scan.l" +#line 324 "scan.l" { char* endptr; @@ -1168,7 +1180,7 @@ YY_RULE_SETUP YY_BREAK case 35: YY_RULE_SETUP -#line 321 "scan.l" +#line 335 "scan.l" { char* endptr; @@ -1181,7 +1193,7 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 330 "scan.l" +#line 344 "scan.l" { char* endptr; @@ -1195,7 +1207,7 @@ YY_RULE_SETUP YY_BREAK case 37: YY_RULE_SETUP -#line 340 "scan.l" +#line 354 "scan.l" { int i; ScanKeyword *keyword; @@ -1217,27 +1229,27 @@ YY_RULE_SETUP YY_BREAK case 38: YY_RULE_SETUP -#line 358 "scan.l" +#line 372 "scan.l" { /* ignore */ } YY_BREAK case 39: YY_RULE_SETUP -#line 360 "scan.l" +#line 374 "scan.l" { return (yytext[0]); } YY_BREAK case 40: YY_RULE_SETUP -#line 362 "scan.l" +#line 376 "scan.l" ECHO; YY_BREAK -#line 1234 "lex.yy.c" +#line 1246 "lex.yy.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(xb): case YY_STATE_EOF(xc): case YY_STATE_EOF(xd): case YY_STATE_EOF(xh): - case YY_STATE_EOF(xq): case YY_STATE_EOF(xm): + case YY_STATE_EOF(xq): yyterminate(); case YY_END_OF_BUFFER: @@ -2116,7 +2128,7 @@ int main() return 0; } #endif -#line 362 "scan.l" +#line 376 "scan.l" void yyerror(char message[]) diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l index daa2faa9d5..1c5db68ad6 100644 --- a/src/backend/parser/scan.l +++ b/src/backend/parser/scan.l @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.30 1997/11/20 23:22:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.31 1997/11/30 23:05:36 thomas Exp $ * *------------------------------------------------------------------------- */ @@ -60,61 +60,75 @@ int llen; char literal[MAX_PARSE_BUFFER]; %} - /* OK, here is a short description of lex/flex rules behavior. - * The longest pattern which matches an input string is always chosen. - * For equal-length patterns, the first occurring in the rules list is chosen. - * INITIAL is the starting condition, to which all non-conditional rules apply. - * When in an exclusive condition, only those rules defined for that condition apply. - * - * Exclusive states change parsing rules while the state is active. - * There are exclusive states for quoted strings, extended comments, - * and to eliminate parsing troubles for numeric strings. - * Exclusive states: - * binary numeric string - thomas 1997-11-16 - * hexadecimal numeric string - thomas 1997-11-16 - * extended C-style comments - tgl 1997-07-12 - * quoted strings - tgl 1997-07-30 - * numeric strings with embedded minus sign - tgl 1997-09-05 - * delimited identifiers (double-quoted identifiers) - tgl 1997-10-27 - * - * The "extended comment" syntax closely resembles allowable operator syntax. - * So, when in condition , only strings which would terminate the - * "extended comment" trigger any action other than "ignore". - * Be sure to match _any_ candidate comment, including those with appended - * operator-like symbols. - thomas 1997-07-14 - */ +/* OK, here is a short description of lex/flex rules behavior. + * The longest pattern which matches an input string is always chosen. + * For equal-length patterns, the first occurring in the rules list is chosen. + * INITIAL is the starting condition, to which all non-conditional rules apply. + * When in an exclusive condition, only those rules defined for that condition apply. + * + * Exclusive states change parsing rules while the state is active. + * There are exclusive states for quoted strings, extended comments, + * and to eliminate parsing troubles for numeric strings. + * Exclusive states: + * binary numeric string - thomas 1997-11-16 + * extended C-style comments - tgl 1997-07-12 + * delimited identifiers (double-quoted identifiers) - tgl 1997-10-27 + * hexadecimal numeric string - thomas 1997-11-16 + * numeric strings with embedded minus sign - tgl 1997-09-05 + * quoted strings - tgl 1997-07-30 + * + * The "extended comment" syntax closely resembles allowable operator syntax. + * So, when in condition , only strings which would terminate the + * "extended comment" trigger any action other than "ignore". + * Be sure to match _any_ candidate comment, including those with appended + * operator-like symbols. - thomas 1997-07-14 + */ %x xb %x xc %x xd %x xh -%x xq %x xm +%x xq -quote ' -xqstart {quote} -xqstop {quote} -xqdouble {quote}{quote} -xqinside [^\\']* -xqembedded "\\'" -xqliteral [\\](.|\n) -xqcat {quote}{space}*\n{space}*{quote} - +/* Binary number + */ xbstart [bB]{quote} xbstop {quote} xbinside [^']* xbcat {quote}{space}*\n{space}*{quote} +/* Hexadecimal number + */ xhstart [xX]{quote} xhstop {quote} xhinside [^']* xhcat {quote}{space}*\n{space}*{quote} +/* Extended quote + * xqdouble implements SQL92 embedded quote + * xqcat allows strings to cross input lines + */ +quote ' +xqstart {quote} +xqstop {quote} +xqdouble {quote}{quote} +xqinside [^\\']* +xqembedded "\\'" +xqliteral [\\](.|\n) +xqcat {quote}{space}*\n{space}*{quote} + +/* Delimited quote + * Allows embedded spaces and other special characters into identifiers. + */ dquote \" xdstart {dquote} xdstop {dquote} xdinside [^"]* +/* Comments + * Ignored by the scanner and parser. + */ xcline [\/][\*].*[\*][\/]{space}*\n* xcstart [\/][\*]{op_and_self}* xcstop {op_and_self}*[\*][\/]({space}*|\n) -- GitLab