diff options
author | Anatol Belski <ab@php.net> | 2014-07-02 10:27:59 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-07-02 10:27:59 +0200 |
commit | 84876850ff3e50ee7b85abc7261bdf9038d65e4b (patch) | |
tree | 091e7474679a1b6700459d6db2e36e0ac9272397 /sapi/phpdbg/phpdbg_parser.y | |
parent | 0e7bf92129f608c44f4d5bd51139ec2bd85fecc8 (diff) | |
parent | 96783bdfb79b33646dc916d4b93bc33b78d70c4c (diff) | |
download | php-git-84876850ff3e50ee7b85abc7261bdf9038d65e4b.tar.gz |
Merge remote-tracking branch 'origin/str_size_and_int64_56_backport' into str_size_and_int64
* origin/str_size_and_int64_56_backport: (178 commits)
fix integer overflow in {stream,file}_{get,put}_contents()
add some missing NEWS entries
NEWS block for 5.6.0RC3
Fix ext/pgsql builds with libpq < 7.3.
updated libs_version.txt
updated libs_version.txt
updated libmagic.patch in 5.6+
updated libmagic.patch
Fixed possible crash because of race conditions on modifying constants in shared memory
remove the NEWS entry for the reverted fpm fix
remove the NEWS entry for the reverted fpm fix
remove the NEWS entry for the reverted fpm fix
Revert "Fix Bug #67530 error_log=syslog ignored"
--enable-fpm for the travis build
fix the last fpm NEWS entry, the other bug is related, but not the same what we fixed here
NEWS
NEWS
Fix bug #67091: make install fails to install libphp5.so on FreeBSD 10.0
adding NEWS entry for the fix for bug #65641
Updated NEWS file for recent phpdbg fixes
...
Diffstat (limited to 'sapi/phpdbg/phpdbg_parser.y')
-rw-r--r-- | sapi/phpdbg/phpdbg_parser.y | 152 |
1 files changed, 84 insertions, 68 deletions
diff --git a/sapi/phpdbg/phpdbg_parser.y b/sapi/phpdbg/phpdbg_parser.y index 4a84504e2e..702bf78455 100644 --- a/sapi/phpdbg/phpdbg_parser.y +++ b/sapi/phpdbg/phpdbg_parser.y @@ -1,4 +1,3 @@ -%error-verbose %{ /* @@ -19,23 +18,15 @@ #include "phpdbg_parser.h" #include "phpdbg_lexer.h" +#undef yyerror +static int yyerror(void ***tsrm_ls, const char *msg); + ZEND_EXTERN_MODULE_GLOBALS(phpdbg); -int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) { - TSRMLS_FETCH(); - phpdbg_error("Parse Error: %s", msg); - { - const phpdbg_param_t *top = stack; - - while (top) { - phpdbg_param_debug( - top, "--> "); - top = top->next; - } - } - return 0; -} %} + +%pure-parser +%error-verbose %code requires { #include "phpdbg.h" @@ -44,59 +35,58 @@ int yyerror(phpdbg_param_t *stack, yyscan_t scanner, const char *msg) { typedef void* yyscan_t; #endif } + +%parse-param { void *tsrm_ls } + %output "sapi/phpdbg/phpdbg_parser.c" %defines "sapi/phpdbg/phpdbg_parser.h" - -%define api.pure -%lex-param { yyscan_t scanner } -%parse-param { phpdbg_param_t *stack } -%parse-param { yyscan_t scanner } - -%token T_EVAL "eval" -%token T_RUN "run" -%token T_SHELL "shell" -%token T_IF "if (condition)" -%token T_TRUTHY "truthy (true, on, yes or enabled)" -%token T_FALSY "falsy (false, off, no or disabled)" -%token T_STRING "string (some input, perhaps)" -%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" -%token T_OPCODE "opcode" -%token T_ID "identifier (command or function name)" -%token T_INPUT "input (input string or data)" -%token T_UNEXPECTED "input" -%% + +%token T_EVAL "eval" +%token T_RUN "run" +%token T_SHELL "shell" +%token T_IF "if (condition)" +%token T_TRUTHY "truthy (true, on, yes or enabled)" +%token T_FALSY "falsy (false, off, no or disabled)" +%token T_STRING "string (some input, perhaps)" +%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" +%token T_OPCODE "opcode" +%token T_ID "identifier (command or function name)" +%token T_INPUT "input (input string or data)" +%token T_UNEXPECTED "input" + +%% /* Rules */ input - : parameters - | /* nothing */ - ; + : parameters + | full_expression { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); } + | /* nothing */ + ; parameters - : parameter { phpdbg_stack_push(stack, &$1); } - | parameters parameter { phpdbg_stack_push(stack, &$2); } + : parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); } + | parameters parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$2); } ; parameter - : T_ID T_COLON T_DIGITS { + : T_ID T_COLON T_DIGITS { $$.type = FILE_PARAM; $$.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 { + | T_PROTO T_ID T_COLON T_DIGITS { $$.type = FILE_PARAM; - $$.file.name = malloc($1.len + - $2.len + 1); + $$.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); @@ -104,10 +94,9 @@ parameter } $$.file.line = $4.num; } - | T_PROTO T_ID T_COLON T_POUND T_DIGITS { + | T_PROTO T_ID T_COLON T_POUND T_DIGITS { $$.type = NUMERIC_FILE_PARAM; - $$.file.name = malloc($1.len + - $2.len + 1); + $$.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); @@ -115,54 +104,81 @@ parameter } $$.file.line = $5.num; } - | T_ID T_DCOLON T_ID { + | T_ID T_DCOLON T_ID { $$.type = METHOD_PARAM; $$.method.class = $1.str; $$.method.name = $3.str; } - | T_ID T_DCOLON T_ID T_POUND T_DIGITS { + | T_ID T_DCOLON T_ID T_POUND T_DIGITS { $$.type = NUMERIC_METHOD_PARAM; $$.method.class = $1.str; $$.method.name = $3.str; $$.num = $5.num; } - | T_ID T_POUND T_DIGITS { + | T_ID T_POUND T_DIGITS { $$.type = NUMERIC_FUNCTION_PARAM; $$.str = $1.str; $$.len = $1.len; $$.num = $3.num; } - | T_IF T_INPUT { + | T_IF T_INPUT { $$.type = COND_PARAM; $$.str = $2.str; $$.len = $2.len; } - | T_EVAL T_INPUT { + | T_OPCODE { $$ = $1; } + | T_ADDR { $$ = $1; } + | T_LITERAL { $$ = $1; } + | T_TRUTHY { $$ = $1; } + | T_FALSY { $$ = $1; } + | T_DIGITS { $$ = $1; } + | T_ID { $$ = $1; } + ; + +full_expression + : T_EVAL T_INPUT { $$.type = EVAL_PARAM; $$.str = $2.str; $$.len = $2.len; } - | T_SHELL T_INPUT { + | T_SHELL T_INPUT { $$.type = SHELL_PARAM; $$.str = $2.str; $$.len = $2.len; } - | T_RUN { + | T_RUN { $$.type = RUN_PARAM; $$.len = 0; } - | T_RUN T_INPUT { + | T_RUN T_INPUT { $$.type = RUN_PARAM; $$.str = $2.str; $$.len = $2.len; } - | T_OPCODE { $$ = $1; } - | T_ADDR { $$ = $1; } - | T_LITERAL { $$ = $1; } - | T_TRUTHY { $$ = $1; } - | T_FALSY { $$ = $1; } - | T_DIGITS { $$ = $1; } - | T_ID { $$ = $1; } ; %% + +static int yyerror(void ***tsrm_ls, const char *msg) { + phpdbg_error("Parse Error: %s", msg); + + { + const phpdbg_param_t *top = PHPDBG_G(parser_stack); + + while (top) { + phpdbg_param_debug(top, "--> "); + top = top->next; + } + } + return 0; +} + +int phpdbg_do_parse(phpdbg_param_t *stack, char *input TSRMLS_DC) { + phpdbg_init_lexer(stack, input TSRMLS_CC); + +#ifdef ZTS + return yyparse(TSRMLS_C); +#else + return yyparse(NULL); +#endif +} |