summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_parser.y
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2014-04-26 00:32:51 +0400
committerDmitry Stogov <dmitry@zend.com>2014-04-26 00:32:51 +0400
commitf9927a6c97208c60d922f9a4e98feb8079c57d1f (patch)
tree35815b69d1bf7d47fb41e857ff8d2b024ddac153 /sapi/phpdbg/phpdbg_parser.y
parent4e7cbf3f5842abe6688c11ce3cc11d2eabf0695f (diff)
parentb82d077f988606580e5c06a9da18fe4f60ddb7cb (diff)
downloadphp-git-f9927a6c97208c60d922f9a4e98feb8079c57d1f.tar.gz
Merge mainstream 'master' branch into refactoring
During merge I had to revert: Nikita's patch for php_splice() (it probably needs to be applyed again) Bob Weinand's patches related to constant expression handling (we need to review them carefully) I also reverted all our attempts to support sapi/phpdbg (we didn't test it anyway) Conflicts: Zend/zend.h Zend/zend_API.c Zend/zend_ast.c Zend/zend_compile.c Zend/zend_compile.h Zend/zend_constants.c Zend/zend_exceptions.c Zend/zend_execute.c Zend/zend_execute.h Zend/zend_execute_API.c Zend/zend_hash.c Zend/zend_highlight.c Zend/zend_language_parser.y Zend/zend_language_scanner.c Zend/zend_language_scanner_defs.h Zend/zend_variables.c Zend/zend_vm_def.h Zend/zend_vm_execute.h ext/date/php_date.c ext/dom/documenttype.c ext/hash/hash.c ext/iconv/iconv.c ext/mbstring/tests/zend_multibyte-10.phpt ext/mbstring/tests/zend_multibyte-11.phpt ext/mbstring/tests/zend_multibyte-12.phpt ext/mysql/php_mysql.c ext/mysqli/mysqli.c ext/mysqlnd/mysqlnd_reverse_api.c ext/mysqlnd/php_mysqlnd.c ext/opcache/ZendAccelerator.c ext/opcache/zend_accelerator_util_funcs.c ext/opcache/zend_persist.c ext/opcache/zend_persist_calc.c ext/pcre/php_pcre.c ext/pdo/pdo_dbh.c ext/pdo/pdo_stmt.c ext/pdo_pgsql/pgsql_driver.c ext/pgsql/pgsql.c ext/reflection/php_reflection.c ext/session/session.c ext/spl/spl_array.c ext/spl/spl_observer.c ext/standard/array.c ext/standard/basic_functions.c ext/standard/html.c ext/standard/mail.c ext/standard/php_array.h ext/standard/proc_open.c ext/standard/streamsfuncs.c ext/standard/user_filters.c ext/standard/var_unserializer.c ext/standard/var_unserializer.re main/php_variables.c sapi/phpdbg/phpdbg.c sapi/phpdbg/phpdbg_bp.c sapi/phpdbg/phpdbg_frame.c sapi/phpdbg/phpdbg_help.c sapi/phpdbg/phpdbg_list.c sapi/phpdbg/phpdbg_print.c sapi/phpdbg/phpdbg_prompt.c
Diffstat (limited to 'sapi/phpdbg/phpdbg_parser.y')
-rw-r--r--sapi/phpdbg/phpdbg_parser.y168
1 files changed, 168 insertions, 0 deletions
diff --git a/sapi/phpdbg/phpdbg_parser.y b/sapi/phpdbg/phpdbg_parser.y
new file mode 100644
index 0000000000..4a84504e2e
--- /dev/null
+++ b/sapi/phpdbg/phpdbg_parser.y
@@ -0,0 +1,168 @@
+%error-verbose
+%{
+
+/*
+ * phpdbg_parser.y
+ * (from php-src root)
+ * flex sapi/phpdbg/dev/phpdbg_lexer.l
+ * bison sapi/phpdbg/dev/phpdbg_parser.y
+ */
+
+#include "phpdbg.h"
+#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"
+
+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;
+}
+%}
+
+%code requires {
+#include "phpdbg.h"
+#ifndef YY_TYPEDEF_YY_SCANNER_T
+#define YY_TYPEDEF_YY_SCANNER_T
+typedef void* yyscan_t;
+#endif
+}
+%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"
+%%
+
+input
+ : parameters
+ | /* nothing */
+ ;
+
+parameters
+ : parameter { phpdbg_stack_push(stack, &$1); }
+ | parameters parameter { phpdbg_stack_push(stack, &$2); }
+ ;
+
+parameter
+ : 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 {
+ $$.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;
+ $$.method.name = $3.str;
+ }
+ | 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 {
+ $$.type = NUMERIC_FUNCTION_PARAM;
+ $$.str = $1.str;
+ $$.len = $1.len;
+ $$.num = $3.num;
+ }
+ | T_IF T_INPUT {
+ $$.type = COND_PARAM;
+ $$.str = $2.str;
+ $$.len = $2.len;
+ }
+ | T_EVAL T_INPUT {
+ $$.type = EVAL_PARAM;
+ $$.str = $2.str;
+ $$.len = $2.len;
+ }
+ | T_SHELL T_INPUT {
+ $$.type = SHELL_PARAM;
+ $$.str = $2.str;
+ $$.len = $2.len;
+ }
+ | T_RUN {
+ $$.type = RUN_PARAM;
+ $$.len = 0;
+ }
+ | 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; }
+ ;
+
+%%