From a2d7e336e6f40556fc2e508cf2500907aaf5760b Mon Sep 17 00:00:00 2001 From: krakjoe Date: Fri, 28 Feb 2014 07:41:34 +0000 Subject: [PATCH] parse stream locations properly, bp.c still needs work for #82 --- dev/phpdbg_lexer.l | 12 +- dev/phpdbg_parser.y | 28 ++++- phpdbg_bp.c | 18 ++- phpdbg_lexer.c | 274 ++++++++++++++++++++++++-------------------- phpdbg_lexer.h | 2 +- phpdbg_parser.c | 203 +++++++++++++++++++------------- phpdbg_parser.h | 15 +-- 7 files changed, 325 insertions(+), 227 deletions(-) diff --git a/dev/phpdbg_lexer.l b/dev/phpdbg_lexer.l index a50360d249..fc63930e7e 100644 --- a/dev/phpdbg_lexer.l +++ b/dev/phpdbg_lexer.l @@ -51,9 +51,15 @@ OPCODE ?i:ZEND_([A-Za-z])+ INPUT [^\n]+ %% { - [#]{1} { return T_POUND; } - [:]{2} { return T_DCOLON; } - [:]{1} { return T_COLON; } + {ID}[:]{1}[//]{2} { + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + return T_PROTO; + } + [#]{1} { return T_POUND; } + [:]{2} { return T_DCOLON; } + [:]{1} { return T_COLON; } {T_EVAL} { BEGIN(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); diff --git a/dev/phpdbg_parser.y b/dev/phpdbg_parser.y index 37ecb9e860..9d31a5d3e7 100644 --- a/dev/phpdbg_parser.y +++ b/dev/phpdbg_parser.y @@ -61,7 +61,7 @@ typedef void* yyscan_t; %token T_COLON ": (colon)" %token T_DCOLON ":: (double colon)" %token T_POUND "# (pound sign)" - +%token T_PROTO "protocol (file://)" %token T_DIGITS "digits (numbers)" %token T_LITERAL "literal (string)" %token T_ADDR "address" @@ -84,14 +84,36 @@ parameters parameter : T_ID T_COLON T_DIGITS { $$.type = FILE_PARAM; - $$.file.name = $1.str; + $$.file.name = $2.str; $$.file.line = $3.num; } - | T_ID T_COLON T_POUND T_DIGITS { + | T_ID T_COLON T_POUND T_DIGITS { $$.type = NUMERIC_FILE_PARAM; $$.file.name = $1.str; $$.file.line = $4.num; } + | T_PROTO T_ID T_COLON T_DIGITS { + $$.type = FILE_PARAM; + $$.file.name = malloc($1.len + + $2.len + 1); + if ($$.file.name) { + memcpy(&$$.file.name[0], $1.str, $1.len); + memcpy(&$$.file.name[$1.len], $2.str, $2.len); + $$.file.name[$1.len + $2.len] = '\0'; + } + $$.file.line = $4.num; + } + | T_PROTO T_ID T_COLON T_POUND T_DIGITS { + $$.type = NUMERIC_FILE_PARAM; + $$.file.name = malloc($1.len + + $2.len + 1); + if ($$.file.name) { + memcpy(&$$.file.name[0], $1.str, $1.len); + memcpy(&$$.file.name[$1.len], $2.str, $2.len); + $$.file.name[$1.len + $2.len] = '\0'; + } + $$.file.line = $5.num; + } | T_ID T_DCOLON T_ID { $$.type = METHOD_PARAM; $$.method.class = $1.str; diff --git a/phpdbg_bp.c b/phpdbg_bp.c index e3e9b8f245..111d5ca1c9 100644 --- a/phpdbg_bp.c +++ b/phpdbg_bp.c @@ -221,14 +221,20 @@ PHPDBG_API void phpdbg_export_breakpoints(FILE *handle TSRMLS_DC) /* {{{ */ PHPDBG_API void phpdbg_set_breakpoint_file(const char *path, long line_num TSRMLS_DC) /* {{{ */ { - struct stat sb; - - if (VCWD_STAT(path, &sb) != FAILURE) { - if (sb.st_mode & (S_IFREG|S_IFLNK)) { + php_stream_statbuf ssb; + char realpath[MAXPATHLEN]; + + if (php_stream_stat_path(path, &ssb) != FAILURE) { + if (ssb.sb.st_mode & (S_IFREG|S_IFLNK)) { HashTable *broken; phpdbg_breakfile_t new_break; - size_t path_len = strlen(path); - + size_t path_len = 0L; + + if (VCWD_REALPATH(path, realpath)) { + path = realpath; + } + path_len = strlen(path); + if (zend_hash_find(&PHPDBG_G(bp)[PHPDBG_BREAK_FILE], path, path_len, (void**)&broken) == FAILURE) { HashTable breaks; diff --git a/phpdbg_lexer.c b/phpdbg_lexer.c index 880403775e..7e29e1d661 100644 --- a/phpdbg_lexer.c +++ b/phpdbg_lexer.c @@ -350,8 +350,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 15 -#define YY_END_OF_BUFFER 16 +#define YY_NUM_RULES 16 +#define YY_END_OF_BUFFER 17 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -359,15 +359,15 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[67] = +static yyconst flex_int16_t yy_accept[70] = { 0, - 0, 0, 0, 0, 16, 12, 14, 1, 9, 9, - 3, 12, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 13, 13, 12, 14, 9, 12, 2, 12, 12, - 4, 12, 6, 8, 12, 7, 5, 12, 12, 12, - 13, 13, 10, 12, 12, 12, 8, 12, 7, 12, - 12, 12, 12, 7, 12, 12, 12, 8, 12, 12, - 12, 11, 12, 7, 8, 0 + 0, 0, 0, 0, 17, 13, 15, 2, 10, 10, + 4, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 14, 14, 13, 0, 15, 10, 13, 3, 13, + 13, 5, 13, 7, 9, 13, 8, 6, 13, 13, + 13, 14, 14, 0, 11, 13, 13, 13, 9, 13, + 8, 13, 1, 13, 13, 13, 8, 13, 13, 13, + 9, 13, 13, 13, 12, 13, 8, 9, 0 } ; static yyconst flex_int32_t yy_ec[256] = @@ -376,16 +376,16 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 5, 1, 6, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 8, 1, 1, - 1, 1, 1, 1, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 15, 15, 18, 15, 19, 20, 15, - 15, 21, 22, 23, 24, 25, 15, 15, 26, 27, - 1, 1, 1, 1, 28, 1, 29, 30, 11, 31, - - 32, 33, 15, 34, 35, 15, 15, 36, 15, 37, - 38, 15, 15, 39, 40, 41, 42, 43, 15, 44, - 45, 46, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 5, 6, 7, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 9, 1, 1, + 1, 1, 1, 1, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 16, 16, 19, 16, 20, 21, 16, + 16, 22, 23, 24, 25, 26, 16, 16, 27, 28, + 1, 1, 1, 1, 29, 1, 30, 31, 12, 32, + + 33, 34, 16, 35, 36, 16, 16, 37, 16, 38, + 39, 16, 16, 40, 41, 42, 43, 44, 16, 45, + 46, 47, 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, @@ -402,93 +402,107 @@ static yyconst flex_int32_t yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst flex_int32_t yy_meta[47] = +static yyconst flex_int32_t yy_meta[48] = { 0, - 1, 2, 3, 2, 1, 1, 1, 2, 1, 1, + 1, 2, 3, 2, 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 } ; -static yyconst flex_int16_t yy_base[71] = +static yyconst flex_int16_t yy_base[74] = { 0, - 0, 0, 45, 47, 148, 0, 49, 184, 48, 51, - 138, 42, 41, 52, 49, 42, 50, 51, 47, 57, - 58, 0, 70, 0, 72, 86, 90, 184, 54, 79, - 0, 80, 0, 0, 91, 0, 0, 83, 87, 91, - 0, 109, 0, 97, 103, 92, 0, 102, 0, 105, - 108, 111, 117, 0, 117, 117, 118, 0, 136, 126, - 128, 150, 132, 0, 0, 184, 178, 78, 181, 64 + 0, 0, 46, 48, 213, 198, 50, 238, 49, 54, + 197, 46, 51, 56, 58, 59, 63, 67, 65, 61, + 76, 0, 101, 187, 186, 104, 103, 106, 238, 118, + 113, 182, 115, 178, 176, 116, 171, 148, 117, 121, + 126, 0, 126, 142, 0, 123, 136, 140, 91, 142, + 87, 145, 238, 157, 146, 160, 84, 161, 152, 164, + 82, 193, 170, 163, 203, 173, 79, 72, 238, 232, + 78, 235, 68 } ; -static yyconst flex_int16_t yy_def[71] = +static yyconst flex_int16_t yy_def[74] = { 0, - 66, 1, 67, 67, 66, 68, 66, 66, 68, 68, - 66, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 68, 69, 69, 68, 66, 68, 68, 66, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, - 69, 69, 27, 68, 68, 68, 68, 68, 68, 68, - 68, 68, 68, 68, 68, 68, 68, 68, 70, 68, - 68, 70, 68, 68, 68, 0, 66, 66, 66, 66 + 69, 1, 70, 70, 69, 71, 69, 69, 71, 71, + 69, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 72, 72, 71, 69, 69, 71, 71, 69, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 72, 72, 69, 28, 71, 71, 71, 71, 71, + 71, 71, 69, 71, 71, 71, 71, 71, 71, 71, + 71, 73, 71, 71, 73, 71, 71, 71, 0, 69, + 69, 69, 69 } ; -static yyconst flex_int16_t yy_nxt[231] = +static yyconst flex_int16_t yy_nxt[286] = { 0, - 6, 7, 7, 8, 9, 10, 9, 11, 6, 6, - 6, 12, 13, 14, 6, 6, 15, 6, 16, 17, - 6, 18, 19, 6, 6, 20, 21, 6, 6, 6, - 12, 13, 14, 6, 15, 6, 16, 17, 6, 18, - 19, 6, 6, 6, 20, 21, 23, 7, 23, 7, - 25, 25, 26, 26, 26, 26, 26, 26, 29, 30, - 32, 34, 33, 35, 62, 31, 37, 38, 36, 39, - 40, 42, 25, 25, 25, 44, 29, 30, 24, 34, - 32, 33, 35, 31, 37, 38, 36, 45, 39, 40, - 26, 26, 26, 44, 27, 43, 43, 46, 43, 43, - - 43, 43, 43, 43, 47, 51, 48, 45, 49, 50, - 42, 25, 52, 53, 54, 46, 55, 56, 43, 43, - 43, 43, 43, 47, 48, 51, 49, 50, 57, 58, - 61, 53, 52, 54, 60, 55, 24, 56, 63, 64, - 24, 24, 24, 65, 59, 28, 57, 66, 58, 61, - 24, 66, 60, 66, 24, 24, 24, 63, 64, 66, - 66, 66, 65, 24, 66, 66, 66, 66, 66, 66, - 66, 66, 66, 66, 66, 66, 66, 24, 22, 22, - 22, 41, 41, 5, 66, 66, 66, 66, 66, 66, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, - - 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 66 + 6, 7, 7, 8, 9, 6, 10, 9, 11, 6, + 6, 6, 12, 13, 14, 6, 6, 15, 6, 16, + 17, 6, 18, 19, 6, 6, 20, 21, 6, 6, + 6, 12, 13, 14, 6, 15, 6, 16, 17, 6, + 18, 19, 6, 6, 6, 20, 21, 23, 7, 23, + 7, 26, 26, 27, 25, 27, 27, 25, 27, 25, + 27, 27, 25, 30, 25, 33, 25, 25, 65, 25, + 31, 25, 34, 25, 40, 25, 32, 36, 24, 35, + 25, 30, 37, 38, 25, 33, 39, 25, 31, 41, + 25, 34, 25, 40, 32, 25, 36, 35, 28, 25, + + 37, 38, 43, 26, 39, 26, 26, 27, 41, 27, + 27, 25, 45, 45, 25, 45, 45, 45, 45, 45, + 45, 25, 47, 25, 25, 25, 25, 43, 26, 25, + 49, 25, 54, 48, 25, 45, 45, 45, 45, 45, + 46, 50, 47, 51, 25, 52, 55, 53, 25, 49, + 25, 48, 54, 25, 25, 57, 25, 58, 46, 50, + 25, 51, 56, 52, 60, 25, 55, 59, 25, 25, + 63, 25, 25, 61, 57, 67, 58, 64, 25, 25, + 56, 25, 60, 66, 25, 68, 25, 59, 63, 62, + 25, 44, 61, 24, 67, 25, 64, 24, 24, 24, + + 24, 25, 66, 24, 68, 29, 25, 24, 24, 24, + 24, 25, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 24, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 24, 22, 22, 22, 42, 42, 5, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69 } ; -static yyconst flex_int16_t yy_chk[231] = +static yyconst flex_int16_t yy_chk[286] = { 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, 3, 3, 4, 4, - 7, 7, 9, 9, 9, 10, 10, 10, 12, 13, - 14, 16, 15, 17, 70, 13, 18, 19, 17, 20, - 21, 23, 23, 25, 25, 29, 12, 13, 68, 16, - 14, 15, 17, 13, 18, 19, 17, 30, 20, 21, - 26, 26, 26, 29, 10, 27, 27, 32, 27, 27, - - 27, 27, 27, 27, 35, 44, 38, 30, 39, 40, - 42, 42, 45, 46, 48, 32, 50, 51, 27, 27, - 27, 27, 27, 35, 38, 44, 39, 40, 52, 53, - 57, 46, 45, 48, 56, 50, 59, 51, 60, 61, - 59, 59, 59, 63, 55, 11, 52, 5, 53, 57, - 62, 0, 56, 0, 62, 62, 62, 60, 61, 0, - 0, 0, 63, 59, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 62, 67, 67, - 67, 69, 69, 66, 66, 66, 66, 66, 66, 66, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, - - 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, - 66, 66, 66, 66, 66, 66, 66, 66, 66, 66 + 1, 1, 1, 1, 1, 1, 1, 3, 3, 4, + 4, 7, 7, 9, 12, 9, 9, 9, 10, 13, + 10, 10, 10, 12, 14, 14, 15, 16, 73, 20, + 13, 17, 15, 19, 20, 18, 13, 17, 71, 16, + 68, 12, 17, 18, 21, 14, 19, 67, 13, 21, + 61, 15, 57, 20, 13, 51, 17, 16, 10, 49, + + 17, 18, 23, 23, 19, 26, 26, 27, 21, 27, + 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 31, 31, 33, 36, 39, 30, 43, 43, 40, + 36, 46, 46, 33, 41, 28, 28, 28, 28, 28, + 30, 39, 31, 40, 47, 41, 47, 44, 48, 36, + 50, 33, 46, 52, 55, 50, 38, 52, 30, 39, + 59, 40, 48, 41, 55, 54, 47, 54, 56, 58, + 59, 64, 60, 56, 50, 64, 52, 60, 63, 37, + 48, 66, 55, 63, 35, 66, 34, 54, 59, 58, + 32, 25, 56, 62, 64, 24, 60, 62, 62, 62, + + 62, 62, 63, 65, 66, 11, 6, 65, 65, 65, + 65, 65, 5, 0, 0, 0, 0, 0, 0, 0, + 0, 62, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 65, 70, 70, 70, 72, 72, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, + 69, 69, 69, 69, 69 } ; /* The intent behind this definition is that it'll catch @@ -524,7 +538,7 @@ static inline void phpdbg_append_string(phpdbg_param_t *param, const char *strin } #define YY_NO_UNISTD_H 1 -#line 528 "sapi/phpdbg/phpdbg_lexer.c" +#line 542 "sapi/phpdbg/phpdbg_lexer.c" #define INITIAL 0 #define RAW 1 @@ -764,7 +778,7 @@ YY_DECL #line 52 "sapi/phpdbg/dev/phpdbg_lexer.l" -#line 768 "sapi/phpdbg/phpdbg_lexer.c" +#line 782 "sapi/phpdbg/phpdbg_lexer.c" yylval = yylval_param; @@ -819,13 +833,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 >= 67 ) + if ( yy_current_state >= 70 ) 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_current_state != 66 ); + while ( yy_current_state != 69 ); yy_cp = yyg->yy_last_accepting_cpos; yy_current_state = yyg->yy_last_accepting_state; @@ -848,84 +862,94 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP #line 54 "sapi/phpdbg/dev/phpdbg_lexer.l" -{ return T_POUND; } +{ + phpdbg_init_param(yylval, STR_PARAM); + yylval->str = strndup(yytext, yyleng); + yylval->len = yyleng; + return T_PROTO; + } YY_BREAK case 2: YY_RULE_SETUP -#line 55 "sapi/phpdbg/dev/phpdbg_lexer.l" -{ return T_DCOLON; } +#line 60 "sapi/phpdbg/dev/phpdbg_lexer.l" +{ return T_POUND; } YY_BREAK case 3: YY_RULE_SETUP -#line 56 "sapi/phpdbg/dev/phpdbg_lexer.l" -{ return T_COLON; } +#line 61 "sapi/phpdbg/dev/phpdbg_lexer.l" +{ return T_DCOLON; } YY_BREAK case 4: YY_RULE_SETUP -#line 57 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 62 "sapi/phpdbg/dev/phpdbg_lexer.l" +{ return T_COLON; } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 63 "sapi/phpdbg/dev/phpdbg_lexer.l" { BEGIN(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_EVAL; } YY_BREAK -case 5: +case 6: YY_RULE_SETUP -#line 62 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 68 "sapi/phpdbg/dev/phpdbg_lexer.l" { BEGIN(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_SHELL; } YY_BREAK -case 6: +case 7: YY_RULE_SETUP -#line 67 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 73 "sapi/phpdbg/dev/phpdbg_lexer.l" { BEGIN(RAW); phpdbg_init_param(yylval, EMPTY_PARAM); return T_IF; } YY_BREAK -case 7: +case 8: YY_RULE_SETUP -#line 72 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 78 "sapi/phpdbg/dev/phpdbg_lexer.l" { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = 1; return T_TRUTHY; } YY_BREAK -case 8: +case 9: YY_RULE_SETUP -#line 77 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 83 "sapi/phpdbg/dev/phpdbg_lexer.l" { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = 0; return T_FALSY; } YY_BREAK -case 9: +case 10: YY_RULE_SETUP -#line 82 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 88 "sapi/phpdbg/dev/phpdbg_lexer.l" { phpdbg_init_param(yylval, NUMERIC_PARAM); yylval->num = atoi(yytext); return T_DIGITS; } YY_BREAK -case 10: +case 11: YY_RULE_SETUP -#line 87 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 93 "sapi/phpdbg/dev/phpdbg_lexer.l" { phpdbg_init_param(yylval, ADDR_PARAM); yylval->addr = strtoul(yytext, NULL, 10); return T_ADDR; } YY_BREAK -case 11: +case 12: YY_RULE_SETUP -#line 92 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 98 "sapi/phpdbg/dev/phpdbg_lexer.l" { phpdbg_init_param(yylval, OP_PARAM); yylval->str = strndup(yytext, yyleng); @@ -933,9 +957,9 @@ YY_RULE_SETUP return T_OPCODE; } YY_BREAK -case 12: +case 13: YY_RULE_SETUP -#line 98 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 104 "sapi/phpdbg/dev/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); yylval->str = strndup(yytext, yyleng); @@ -944,9 +968,9 @@ YY_RULE_SETUP } YY_BREAK -case 13: +case 14: YY_RULE_SETUP -#line 106 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 112 "sapi/phpdbg/dev/phpdbg_lexer.l" { phpdbg_init_param(yylval, STR_PARAM); yylval->str = strndup(yytext, yyleng); @@ -955,18 +979,18 @@ YY_RULE_SETUP return T_INPUT; } YY_BREAK -case 14: -/* rule 14 can match eol */ +case 15: +/* rule 15 can match eol */ YY_RULE_SETUP -#line 114 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 120 "sapi/phpdbg/dev/phpdbg_lexer.l" { /* ignore whitespace */ } YY_BREAK -case 15: +case 16: YY_RULE_SETUP -#line 115 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 121 "sapi/phpdbg/dev/phpdbg_lexer.l" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 970 "sapi/phpdbg/phpdbg_lexer.c" +#line 994 "sapi/phpdbg/phpdbg_lexer.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(RAW): yyterminate(); @@ -1262,7 +1286,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 >= 67 ) + if ( yy_current_state >= 70 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1291,11 +1315,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 >= 67 ) + if ( yy_current_state >= 70 ) 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 == 66); + yy_is_jam = (yy_current_state == 69); (void)yyg; return yy_is_jam ? 0 : yy_current_state; @@ -2132,7 +2156,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 115 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 121 "sapi/phpdbg/dev/phpdbg_lexer.l" diff --git a/phpdbg_lexer.h b/phpdbg_lexer.h index c143d007fd..14dc12ef5a 100644 --- a/phpdbg_lexer.h +++ b/phpdbg_lexer.h @@ -339,7 +339,7 @@ extern int yylex \ #undef YY_DECL #endif -#line 115 "sapi/phpdbg/dev/phpdbg_lexer.l" +#line 121 "sapi/phpdbg/dev/phpdbg_lexer.l" #line 346 "sapi/phpdbg/phpdbg_lexer.h" diff --git a/phpdbg_parser.c b/phpdbg_parser.c index 1f6a151587..6ea96d84d5 100644 --- a/phpdbg_parser.c +++ b/phpdbg_parser.c @@ -160,13 +160,14 @@ typedef void* yyscan_t; T_COLON = 264, T_DCOLON = 265, T_POUND = 266, - T_DIGITS = 267, - T_LITERAL = 268, - T_ADDR = 269, - T_OPCODE = 270, - T_ID = 271, - T_INPUT = 272, - T_UNEXPECTED = 273 + T_PROTO = 267, + T_DIGITS = 268, + T_LITERAL = 269, + T_ADDR = 270, + T_OPCODE = 271, + T_ID = 272, + T_INPUT = 273, + T_UNEXPECTED = 274 }; #endif @@ -198,7 +199,7 @@ int yyparse (); /* Copy the second part of user declarations. */ /* Line 390 of yacc.c */ -#line 202 "sapi/phpdbg/phpdbg_parser.c" +#line 203 "sapi/phpdbg/phpdbg_parser.c" #ifdef short # undef short @@ -416,22 +417,22 @@ union yyalloc #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 20 +#define YYFINAL 22 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 25 +#define YYLAST 31 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 19 +#define YYNTOKENS 20 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 4 /* YYNRULES -- Number of rules. */ -#define YYNRULES 20 +#define YYNRULES 22 /* YYNRULES -- Number of states. */ -#define YYNSTATES 29 +#define YYNSTATES 35 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 273 +#define YYMAXUTOK 274 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -466,7 +467,7 @@ static const yytype_uint8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18 + 15, 16, 17, 18, 19 }; #if YYDEBUG @@ -474,28 +475,29 @@ static const yytype_uint8 yytranslate[] = YYRHS. */ static const yytype_uint8 yyprhs[] = { - 0, 0, 3, 5, 6, 8, 11, 15, 20, 24, - 30, 34, 37, 40, 43, 45, 47, 49, 51, 53, - 55 + 0, 0, 3, 5, 6, 8, 11, 15, 20, 25, + 31, 35, 41, 45, 48, 51, 54, 56, 58, 60, + 62, 64, 66 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { - 20, 0, -1, 21, -1, -1, 22, -1, 21, 22, - -1, 16, 9, 12, -1, 16, 9, 11, 12, -1, - 16, 10, 16, -1, 16, 10, 16, 11, 12, -1, - 16, 11, 12, -1, 5, 17, -1, 3, 17, -1, - 4, 17, -1, 15, -1, 14, -1, 13, -1, 6, - -1, 7, -1, 12, -1, 16, -1 + 21, 0, -1, 22, -1, -1, 23, -1, 22, 23, + -1, 17, 9, 13, -1, 17, 9, 11, 13, -1, + 12, 17, 9, 13, -1, 12, 17, 9, 11, 13, + -1, 17, 10, 17, -1, 17, 10, 17, 11, 13, + -1, 17, 11, 13, -1, 5, 18, -1, 3, 18, + -1, 4, 18, -1, 16, -1, 15, -1, 14, -1, + 6, -1, 7, -1, 13, -1, 17, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { - 0, 75, 75, 76, 80, 81, 85, 90, 95, 100, - 106, 112, 117, 122, 127, 128, 129, 130, 131, 132, - 133 + 0, 75, 75, 76, 80, 81, 85, 90, 95, 106, + 117, 122, 128, 134, 139, 144, 149, 150, 151, 152, + 153, 154, 155 }; #endif @@ -508,9 +510,9 @@ static const char *const yytname[] = "\"if (condition)\"", "\"truthy (true, on, yes or enabled)\"", "\"falsy (false, off, no or disabled)\"", "\"string (some input, perhaps)\"", "\": (colon)\"", - "\":: (double colon)\"", "\"# (pound sign)\"", "\"digits (numbers)\"", - "\"literal (string)\"", "\"address\"", "\"opcode\"", - "\"identifier (command or function name)\"", + "\":: (double colon)\"", "\"# (pound sign)\"", "\"protocol (file://)\"", + "\"digits (numbers)\"", "\"literal (string)\"", "\"address\"", + "\"opcode\"", "\"identifier (command or function name)\"", "\"input (input string or data)\"", "\"input\"", "$accept", "input", "parameters", "parameter", YY_NULL }; @@ -522,24 +524,24 @@ static const char *const yytname[] = static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, - 265, 266, 267, 268, 269, 270, 271, 272, 273 + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 19, 20, 20, 21, 21, 22, 22, 22, 22, - 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, - 22 + 0, 20, 21, 21, 22, 22, 23, 23, 23, 23, + 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, + 23, 23, 23 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 1, 0, 1, 2, 3, 4, 3, 5, - 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, - 1 + 0, 2, 1, 0, 1, 2, 3, 4, 4, 5, + 3, 5, 3, 2, 2, 2, 1, 1, 1, 1, + 1, 1, 1 }; /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. @@ -547,31 +549,33 @@ static const yytype_uint8 yyr2[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 3, 0, 0, 0, 17, 18, 19, 16, 15, 14, - 20, 0, 2, 4, 12, 13, 11, 0, 0, 0, - 1, 5, 0, 6, 8, 10, 7, 0, 9 + 3, 0, 0, 0, 19, 20, 0, 21, 18, 17, + 16, 22, 0, 2, 4, 14, 15, 13, 0, 0, + 0, 0, 1, 5, 0, 0, 6, 10, 12, 0, + 8, 7, 0, 9, 11 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - -1, 11, 12, 13 + -1, 12, 13, 14 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ -#define YYPACT_NINF -10 +#define YYPACT_NINF -11 static const yytype_int8 yypact[] = { - -3, -9, -1, 0, -10, -10, -10, -10, -10, -10, - -4, 18, -3, -10, -10, -10, -10, 3, 4, 7, - -10, -10, 9, -10, 11, -10, -10, 12, -10 + -3, -10, 1, 2, -11, -11, 6, -11, -11, -11, + -11, -4, 21, -3, -11, -11, -11, -11, 13, 4, + 7, 12, -11, -11, 5, 14, -11, 15, -11, 16, + -11, -11, 17, -11, -11 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -10, -10, -10, 13 + -11, -11, -11, 18 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If @@ -580,22 +584,24 @@ static const yytype_int8 yypgoto[] = #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { - 1, 2, 3, 4, 5, 17, 18, 19, 14, 6, - 7, 8, 9, 10, 22, 23, 15, 16, 20, 25, - 24, 26, 27, 0, 28, 21 + 1, 2, 3, 4, 5, 19, 20, 21, 15, 6, + 7, 8, 9, 10, 11, 25, 29, 26, 30, 16, + 17, 22, 24, 18, 27, 28, 32, 31, 0, 33, + 34, 23 }; #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-10))) + (!!((Yystate) == (-11))) #define yytable_value_is_error(Yytable_value) \ YYID (0) static const yytype_int8 yycheck[] = { - 3, 4, 5, 6, 7, 9, 10, 11, 17, 12, - 13, 14, 15, 16, 11, 12, 17, 17, 0, 12, - 16, 12, 11, -1, 12, 12 + 3, 4, 5, 6, 7, 9, 10, 11, 18, 12, + 13, 14, 15, 16, 17, 11, 11, 13, 13, 18, + 18, 0, 9, 17, 17, 13, 11, 13, -1, 13, + 13, 13 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing @@ -603,8 +609,9 @@ static const yytype_int8 yycheck[] = static const yytype_uint8 yystos[] = { 0, 3, 4, 5, 6, 7, 12, 13, 14, 15, - 16, 20, 21, 22, 17, 17, 17, 9, 10, 11, - 0, 22, 11, 12, 16, 12, 12, 11, 12 + 16, 17, 21, 22, 23, 18, 18, 18, 17, 9, + 10, 11, 0, 23, 9, 11, 13, 17, 13, 11, + 13, 13, 11, 13, 13 }; #define yyerrok (yyerrstatus = 0) @@ -1447,7 +1454,7 @@ yyreduce: #line 85 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval).type = FILE_PARAM; - (yyval).file.name = (yyvsp[(1) - (3)]).str; + (yyval).file.name = (yyvsp[(2) - (3)]).str; (yyval).file.line = (yyvsp[(3) - (3)]).num; } break; @@ -1465,6 +1472,38 @@ yyreduce: case 8: /* Line 1792 of yacc.c */ #line 95 "sapi/phpdbg/dev/phpdbg_parser.y" + { + (yyval).type = FILE_PARAM; + (yyval).file.name = malloc((yyvsp[(1) - (4)]).len + + (yyvsp[(2) - (4)]).len + 1); + if ((yyval).file.name) { + memcpy(&(yyval).file.name[0], (yyvsp[(1) - (4)]).str, (yyvsp[(1) - (4)]).len); + memcpy(&(yyval).file.name[(yyvsp[(1) - (4)]).len], (yyvsp[(2) - (4)]).str, (yyvsp[(2) - (4)]).len); + (yyval).file.name[(yyvsp[(1) - (4)]).len + (yyvsp[(2) - (4)]).len] = '\0'; + } + (yyval).file.line = (yyvsp[(4) - (4)]).num; + } + break; + + case 9: +/* Line 1792 of yacc.c */ +#line 106 "sapi/phpdbg/dev/phpdbg_parser.y" + { + (yyval).type = NUMERIC_FILE_PARAM; + (yyval).file.name = malloc((yyvsp[(1) - (5)]).len + + (yyvsp[(2) - (5)]).len + 1); + if ((yyval).file.name) { + memcpy(&(yyval).file.name[0], (yyvsp[(1) - (5)]).str, (yyvsp[(1) - (5)]).len); + memcpy(&(yyval).file.name[(yyvsp[(1) - (5)]).len], (yyvsp[(2) - (5)]).str, (yyvsp[(2) - (5)]).len); + (yyval).file.name[(yyvsp[(1) - (5)]).len + (yyvsp[(2) - (5)]).len] = '\0'; + } + (yyval).file.line = (yyvsp[(5) - (5)]).num; + } + break; + + case 10: +/* Line 1792 of yacc.c */ +#line 117 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval).type = METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (3)]).str; @@ -1472,9 +1511,9 @@ yyreduce: } break; - case 9: + case 11: /* Line 1792 of yacc.c */ -#line 100 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 122 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval).type = NUMERIC_METHOD_PARAM; (yyval).method.class = (yyvsp[(1) - (5)]).str; @@ -1483,9 +1522,9 @@ yyreduce: } break; - case 10: + case 12: /* Line 1792 of yacc.c */ -#line 106 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 128 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval).type = NUMERIC_FUNCTION_PARAM; (yyval).str = (yyvsp[(1) - (3)]).str; @@ -1494,9 +1533,9 @@ yyreduce: } break; - case 11: + case 13: /* Line 1792 of yacc.c */ -#line 112 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 134 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval).type = COND_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1504,9 +1543,9 @@ yyreduce: } break; - case 12: + case 14: /* Line 1792 of yacc.c */ -#line 117 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 139 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval).type = EVAL_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1514,9 +1553,9 @@ yyreduce: } break; - case 13: + case 15: /* Line 1792 of yacc.c */ -#line 122 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 144 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval).type = SHELL_PARAM; (yyval).str = (yyvsp[(2) - (2)]).str; @@ -1524,51 +1563,51 @@ yyreduce: } break; - case 14: + case 16: /* Line 1792 of yacc.c */ -#line 127 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 149 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 15: + case 17: /* Line 1792 of yacc.c */ -#line 128 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 150 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 16: + case 18: /* Line 1792 of yacc.c */ -#line 129 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 151 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 17: + case 19: /* Line 1792 of yacc.c */ -#line 130 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 152 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 18: + case 20: /* Line 1792 of yacc.c */ -#line 131 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 153 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 19: + case 21: /* Line 1792 of yacc.c */ -#line 132 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 154 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; - case 20: + case 22: /* Line 1792 of yacc.c */ -#line 133 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 155 "sapi/phpdbg/dev/phpdbg_parser.y" { (yyval) = (yyvsp[(1) - (1)]); } break; /* Line 1792 of yacc.c */ -#line 1572 "sapi/phpdbg/phpdbg_parser.c" +#line 1611 "sapi/phpdbg/phpdbg_parser.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1800,5 +1839,5 @@ yyreturn: /* Line 2055 of yacc.c */ -#line 136 "sapi/phpdbg/dev/phpdbg_parser.y" +#line 158 "sapi/phpdbg/dev/phpdbg_parser.y" diff --git a/phpdbg_parser.h b/phpdbg_parser.h index a9eea7a56b..3a57a5e54f 100644 --- a/phpdbg_parser.h +++ b/phpdbg_parser.h @@ -68,13 +68,14 @@ typedef void* yyscan_t; T_COLON = 264, T_DCOLON = 265, T_POUND = 266, - T_DIGITS = 267, - T_LITERAL = 268, - T_ADDR = 269, - T_OPCODE = 270, - T_ID = 271, - T_INPUT = 272, - T_UNEXPECTED = 273 + T_PROTO = 267, + T_DIGITS = 268, + T_LITERAL = 269, + T_ADDR = 270, + T_OPCODE = 271, + T_ID = 272, + T_INPUT = 273, + T_UNEXPECTED = 274 }; #endif -- 2.40.0