summaryrefslogtreecommitdiff
path: root/sapi/phpdbg
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-02-01 07:07:28 +0100
committerkocsismate <kocsismate@woohoolabs.com>2020-02-01 14:21:53 +0100
commit4cbffd89d9e82d81a26746aadca27ad061cab43a (patch)
tree5758a2142048208443671c486f0855cd2c72855c /sapi/phpdbg
parent2127a37b833a863e28a4692e7394613b89c89290 (diff)
downloadphp-git-4cbffd89d9e82d81a26746aadca27ad061cab43a.tar.gz
Clean up the generation of the parsers
Prefer '%define api.value.type' to '#define YYSTYPE', so that Bison know the type. Use '%code requires' to declare what is needed to define the api.value.type (that code is output in the generated header before the generated definition of YYSTYPE). Prefer '%define api.prefix' inside the grammar file to '-p' outside, as anyway the functions defined in the file actually use this prefix. Prefer `%param` to both `%parse-param` and `%lex-param`. Closes GH-5138
Diffstat (limited to 'sapi/phpdbg')
-rw-r--r--sapi/phpdbg/Makefile.frag2
-rw-r--r--sapi/phpdbg/phpdbg_cmd.h4
-rw-r--r--sapi/phpdbg/phpdbg_parser.y25
3 files changed, 13 insertions, 18 deletions
diff --git a/sapi/phpdbg/Makefile.frag b/sapi/phpdbg/Makefile.frag
index 448cc3676b..1572bfd9f0 100644
--- a/sapi/phpdbg/Makefile.frag
+++ b/sapi/phpdbg/Makefile.frag
@@ -18,7 +18,7 @@ $(srcdir)/phpdbg_lexer.c: $(srcdir)/phpdbg_lexer.l
$(srcdir)/phpdbg_parser.h: $(srcdir)/phpdbg_parser.c
$(srcdir)/phpdbg_parser.c: $(srcdir)/phpdbg_parser.y
- @$(YACC) $(YFLAGS) -p phpdbg_ -v -d $(srcdir)/phpdbg_parser.y -o $@
+ @$(YACC) $(YFLAGS) -v -d $(srcdir)/phpdbg_parser.y -o $@
install-phpdbg: $(BUILD_BINARY)
@echo "Installing phpdbg binary: $(INSTALL_ROOT)$(bindir)/"
diff --git a/sapi/phpdbg/phpdbg_cmd.h b/sapi/phpdbg/phpdbg_cmd.h
index 56c8681c59..dd80e61db3 100644
--- a/sapi/phpdbg/phpdbg_cmd.h
+++ b/sapi/phpdbg/phpdbg_cmd.h
@@ -81,10 +81,6 @@ struct _phpdbg_param {
(v)->top = NULL; \
} while(0)
-#ifndef YYSTYPE
-#define YYSTYPE phpdbg_param_t
-#endif
-
#define PHPDBG_ASYNC_SAFE 1
typedef int (*phpdbg_command_handler_t)(const phpdbg_param_t*);
diff --git a/sapi/phpdbg/phpdbg_parser.y b/sapi/phpdbg/phpdbg_parser.y
index 1384abe6fb..f776586810 100644
--- a/sapi/phpdbg/phpdbg_parser.y
+++ b/sapi/phpdbg/phpdbg_parser.y
@@ -1,19 +1,24 @@
%require "3.0"
-%{
-
/*
* phpdbg_parser.y
* (from php-src root)
*/
+%code requires {
#include "phpdbg.h"
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+}
+
+%code {
+
#include "phpdbg_cmd.h"
#include "phpdbg_utils.h"
#include "phpdbg_cmd.h"
#include "phpdbg_prompt.h"
-#define YYSTYPE phpdbg_param_t
-
#include "phpdbg_parser.h"
#include "phpdbg_lexer.h"
@@ -27,19 +32,13 @@ ZEND_EXTERN_MODULE_GLOBALS(phpdbg)
#define YYFREE free
#endif
-%}
+}
+%define api.prefix {phpdbg_}
%define api.pure full
+%define api.value.type {phpdbg_param_t}
%define parse.error verbose
-%code requires {
-#include "phpdbg.h"
-#ifndef YY_TYPEDEF_YY_SCANNER_T
-#define YY_TYPEDEF_YY_SCANNER_T
-typedef void* yyscan_t;
-#endif
-}
-
%token T_EVAL "eval"
%token T_RUN "run"
%token T_SHELL "shell"