summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_parser.y
diff options
context:
space:
mode:
Diffstat (limited to 'sapi/phpdbg/phpdbg_parser.y')
-rw-r--r--sapi/phpdbg/phpdbg_parser.y32
1 files changed, 26 insertions, 6 deletions
diff --git a/sapi/phpdbg/phpdbg_parser.y b/sapi/phpdbg/phpdbg_parser.y
index 8b3ab27f85..527c321f4c 100644
--- a/sapi/phpdbg/phpdbg_parser.y
+++ b/sapi/phpdbg/phpdbg_parser.y
@@ -21,7 +21,12 @@
#undef yyerror
static int yyerror(const char *msg);
-ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
+ZEND_EXTERN_MODULE_GLOBALS(phpdbg)
+
+#ifdef _MSC_VER
+#define YYMALLOC malloc
+#define YYFREE free
+#endif
%}
@@ -48,7 +53,8 @@ typedef void* yyscan_t;
%token T_STRING "string (some input, perhaps)"
%token T_COLON ": (colon)"
%token T_DCOLON ":: (double colon)"
-%token T_POUND "# (pound sign)"
+%token T_POUND "# (pound sign followed by digits)"
+%token T_SEPARATOR "# (pound sign)"
%token T_PROTO "protocol (file://)"
%token T_DIGITS "digits (numbers)"
%token T_LITERAL "literal (string)"
@@ -62,14 +68,19 @@ typedef void* yyscan_t;
%% /* Rules */
input
- : parameters
- | full_expression { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); }
+ : command { $$ = $1; }
+ | input T_SEPARATOR command { phpdbg_stack_separate($1.top); $$ = $3; }
| /* nothing */
;
+command
+ : parameters { $$.top = PHPDBG_G(parser_stack)->top; }
+ | full_expression { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); $$.top = PHPDBG_G(parser_stack)->top; }
+ ;
+
parameters
- : parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); }
- | parameters parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$2); }
+ : parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); $$.top = PHPDBG_G(parser_stack)->top; }
+ | parameters parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$2); $$.top = PHPDBG_G(parser_stack)->top; }
| parameters req_id { $$ = $1; }
;
@@ -179,6 +190,15 @@ static int yyerror(const char *msg) {
}
int phpdbg_do_parse(phpdbg_param_t *stack, char *input) {
+ if (!*input) {
+ return 0;
+ }
+
+ if (PHPDBG_G(cur_command)) {
+ free(PHPDBG_G(cur_command));
+ }
+ PHPDBG_G(cur_command) = strdup(input);
+
phpdbg_init_lexer(stack, input);
return yyparse();