summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_lexer.l
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-07-01 09:10:36 +0200
committerAnatol Belski <ab@php.net>2014-07-01 09:10:36 +0200
commit1a50c27f998769c5b3472d35c39852286900db69 (patch)
tree3c83075a87d566d3d2cac23523ce3f737805aa32 /sapi/phpdbg/phpdbg_lexer.l
parentd4cfc15514285d42f113facc1c296d32a818ccf2 (diff)
parent2330be5641c907b7edd7cffdd3074e85d0091df5 (diff)
downloadphp-git-1a50c27f998769c5b3472d35c39852286900db69.tar.gz
Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport
* origin/PHP-5.6: (170 commits) 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 Fixed issue krakjoe/phpdbg#94 - List behavior is inconsistent Fix issue krakjoe/phpdbg#97 - list now appends a newline if there is none The prompt should always ensure it is on a newline Fixed test Inform about back command existence in help - Fixes krakjoe/phpdbg#100 No way to list the current stack/frames Fix issue krakjoe/phpdbg#98 break if does not seem to work Fix issue krakjoe/phpdbg#99 register function has the same behavior as run Fix readline/libedit (Thanks to @remicollet) Replace incorrect `E` command with `ev` in watch help ... Conflicts: Zend/zend_compile.c ext/standard/basic_functions.c ext/standard/http_fopen_wrapper.c ext/standard/var.c ext/tokenizer/tokenizer_data.c sapi/phpdbg/phpdbg_list.c
Diffstat (limited to 'sapi/phpdbg/phpdbg_lexer.l')
-rw-r--r--sapi/phpdbg/phpdbg_lexer.l270
1 files changed, 154 insertions, 116 deletions
diff --git a/sapi/phpdbg/phpdbg_lexer.l b/sapi/phpdbg/phpdbg_lexer.l
index b3536feab8..7b3ce38c47 100644
--- a/sapi/phpdbg/phpdbg_lexer.l
+++ b/sapi/phpdbg/phpdbg_lexer.l
@@ -1,131 +1,169 @@
-%{
-
/*
* phpdbg_lexer.l
*/
#include "phpdbg.h"
#include "phpdbg_cmd.h"
-#define YYSTYPE phpdbg_param_t
#include "phpdbg_parser.h"
-%}
-
-%s RAW
-%s NORMAL
-
-%option outfile="sapi/phpdbg/phpdbg_lexer.c" header-file="sapi/phpdbg/phpdbg_lexer.h"
-%option warn nodefault
-
-%option reentrant noyywrap never-interactive nounistd
-%option bison-bridge
-
-T_TRUE "true"
-T_YES "yes"
-T_ON "on"
-T_ENABLED "enabled"
-T_FALSE "false"
-T_NO "no"
-T_OFF "off"
-T_DISABLED "disabled"
-T_EVAL "ev"
-T_SHELL "sh"
-T_IF "if"
-T_RUN "run"
-T_RUN_SHORT "r"
-
-WS [ \r\n\t]+
-DIGITS [0-9\.]+
-ID [^ \r\n\t:#]+
-ADDR 0x[a-fA-F0-9]+
-OPCODE (ZEND_|zend_)([A-Za-z])+
-INPUT [^\n]+
-%%
-
-<INITIAL>{
- {T_EVAL} {
- BEGIN(RAW);
- phpdbg_init_param(yylval, EMPTY_PARAM);
- return T_EVAL;
- }
- {T_SHELL} {
- BEGIN(RAW);
- phpdbg_init_param(yylval, EMPTY_PARAM);
- return T_SHELL;
- }
- {T_RUN}|{T_RUN_SHORT} {
- BEGIN(RAW);
- phpdbg_init_param(yylval, EMPTY_PARAM);
- return T_RUN;
- }
-
- .+ {
- BEGIN(NORMAL);
- REJECT;
- }
-}
-
-<NORMAL>{
- {T_IF} {
- BEGIN(RAW);
- phpdbg_init_param(yylval, EMPTY_PARAM);
- return T_IF;
- }
-}
-
-<INITIAL,NORMAL>{
- {ID}[:]{1}[//]{2} {
- phpdbg_init_param(yylval, STR_PARAM);
- yylval->str = zend_strndup(yytext, yyleng);
- yylval->len = yyleng;
- return T_PROTO;
- }
- [#]{1} { return T_POUND; }
- [:]{2} { return T_DCOLON; }
- [:]{1} { return T_COLON; }
-
- {T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE} {
- phpdbg_init_param(yylval, NUMERIC_PARAM);
- yylval->num = 1;
- return T_TRUTHY;
- }
- {T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE} {
- phpdbg_init_param(yylval, NUMERIC_PARAM);
- yylval->num = 0;
- return T_FALSY;
- }
- {DIGITS} {
- phpdbg_init_param(yylval, NUMERIC_PARAM);
- yylval->num = atoi(yytext);
- return T_DIGITS;
- }
- {ADDR} {
- phpdbg_init_param(yylval, ADDR_PARAM);
- yylval->addr = strtoul(yytext, 0, 16);
- return T_ADDR;
- }
- {OPCODE} {
- phpdbg_init_param(yylval, OP_PARAM);
- yylval->str = zend_strndup(yytext, yyleng);
- yylval->len = yyleng;
- return T_OPCODE;
- }
- {ID} {
- phpdbg_init_param(yylval, STR_PARAM);
- yylval->str = zend_strndup(yytext, yyleng);
- yylval->len = yyleng;
- return T_ID;
- }
-}
-
-<RAW>{INPUT} {
+#define LEX(v) (PHPDBG_G(lexer).v)
+
+#define YYCTYPE unsigned char
+#define YYSETCONDITION(x) LEX(state) = x;
+#define YYGETCONDITION() LEX(state)
+#define YYCURSOR LEX(cursor)
+#define YYMARKER LEX(marker)
+#define yyleng LEX(len)
+#define yytext ((char*) LEX(text))
+#undef YYDEBUG
+#define YYDEBUG(a, b)
+#define YYFILL(n)
+
+#define NORMAL 0
+#define RAW 1
+#define INITIAL 2
+
+ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
+
+void phpdbg_init_lexer (phpdbg_param_t *stack, char *input TSRMLS_DC) {
+ PHPDBG_G(parser_stack) = stack;
+
+ YYSETCONDITION(INITIAL);
+
+ LEX(text) = YYCURSOR = (unsigned char *) input;
+ LEX(len) = strlen(input);
+}
+
+int phpdbg_lex (phpdbg_param_t* yylval) {
+ TSRMLS_FETCH(); /* Slow, but this is not a major problem here. TODO: Use TSRMLS_DC */
+
+restart:
+ LEX(text) = YYCURSOR;
+
+/*!re2c
+re2c:yyfill:check = 0;
+T_TRUE 'true'
+T_YES 'yes'
+T_ON 'on'
+T_ENABLED 'enabled'
+T_FALSE 'false'
+T_NO 'no'
+T_OFF 'off'
+T_DISABLED 'disabled'
+T_EVAL 'ev'
+T_SHELL 'sh'
+T_IF 'if'
+T_RUN 'run'
+T_RUN_SHORT "r"
+WS [ \r\n\t]+
+DIGITS [-]?[0-9\.]+
+ID [^ \r\n\t:#\000]+
+ADDR [0][x][a-fA-F0-9]+
+OPCODE (ZEND_|zend_)([A-Za-z])+
+INPUT [^\n\000]+
+
+<!*> := yyleng = (size_t) YYCURSOR - (size_t) yytext;
+
+<*>[\n\000] {
+ return 0;
+}
+
+<NORMAL>{T_IF}{WS} {
+ YYSETCONDITION(RAW);
+ phpdbg_init_param(yylval, EMPTY_PARAM);
+ return T_IF;
+}
+
+<NORMAL>{ID}[:]{1}[//]{2} {
+ phpdbg_init_param(yylval, STR_PARAM);
+ yylval->str = zend_strndup(yytext, yyleng);
+ yylval->len = yyleng;
+ return T_PROTO;
+}
+<NORMAL>[#]{1} {
+ return T_POUND;
+}
+<NORMAL>[:]{2} {
+ return T_DCOLON;
+}
+<NORMAL>[:]{1} {
+ return T_COLON;
+}
+
+<NORMAL>({T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE}){WS} {
+ phpdbg_init_param(yylval, NUMERIC_PARAM);
+ yylval->num = 1;
+ return T_TRUTHY;
+}
+
+<NORMAL>({T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE}){WS} {
+ phpdbg_init_param(yylval, NUMERIC_PARAM);
+ yylval->num = 0;
+ return T_FALSY;
+}
+
+<NORMAL>{DIGITS} {
+ phpdbg_init_param(yylval, NUMERIC_PARAM);
+ yylval->num = atoi(yytext);
+ return T_DIGITS;
+}
+
+<NORMAL>{ADDR} {
+ phpdbg_init_param(yylval, ADDR_PARAM);
+ yylval->addr = strtoul(yytext, 0, 16);
+ return T_ADDR;
+}
+
+<NORMAL>{OPCODE} {
+ phpdbg_init_param(yylval, OP_PARAM);
+ yylval->str = zend_strndup(yytext, yyleng);
+ yylval->len = yyleng;
+ return T_OPCODE;
+}
+
+<NORMAL>{ID} {
+ phpdbg_init_param(yylval, STR_PARAM);
+ yylval->str = zend_strndup(yytext, yyleng);
+ yylval->len = yyleng;
+ return T_ID;
+}
+
+<RAW>{INPUT} {
phpdbg_init_param(yylval, STR_PARAM);
yylval->str = zend_strndup(yytext, yyleng);
yylval->len = yyleng;
- BEGIN(INITIAL);
return T_INPUT;
}
-{WS} { /* ignore whitespace */ }
-%%
+<*>{WS} {
+ /* ignore whitespace */
+
+ goto restart;
+}
+
+<INITIAL>{T_EVAL}{WS} {
+ YYSETCONDITION(RAW);
+ phpdbg_init_param(yylval, EMPTY_PARAM);
+ return T_EVAL;
+}
+<INITIAL>{T_SHELL}{WS} {
+ YYSETCONDITION(RAW);
+ phpdbg_init_param(yylval, EMPTY_PARAM);
+ return T_SHELL;
+}
+<INITIAL>({T_RUN}|{T_RUN_SHORT}){WS} {
+ YYSETCONDITION(RAW);
+ phpdbg_init_param(yylval, EMPTY_PARAM);
+ return T_RUN;
+}
+
+<INITIAL>. {
+ YYSETCONDITION(NORMAL);
+
+ YYCURSOR = LEX(text);
+ goto restart;
+}
+
+*/
+}