2014-02-15 04:52:04 +00:00
|
|
|
%{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* phpdbg_lexer.l
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "phpdbg.h"
|
|
|
|
#include "phpdbg_cmd.h"
|
|
|
|
#define YYSTYPE phpdbg_param_t
|
|
|
|
|
|
|
|
#include "phpdbg_parser.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2014-02-24 22:30:46 +00:00
|
|
|
|
2014-02-27 19:10:59 +00:00
|
|
|
static inline void phpdbg_append_string(phpdbg_param_t *param, const char *string, size_t length TSRMLS_DC) {
|
|
|
|
if (!param->str) {
|
|
|
|
param->str = malloc(length+1);
|
|
|
|
} else param->str = realloc(param->str, param->len + (length+1));
|
|
|
|
|
|
|
|
memcpy(¶m->str[param->len], string, length);
|
|
|
|
param->len += length;
|
|
|
|
param->str[param->len] = 0;
|
2014-02-24 22:30:46 +00:00
|
|
|
}
|
2014-02-15 04:52:04 +00:00
|
|
|
%}
|
|
|
|
|
2014-02-27 19:10:59 +00:00
|
|
|
%s RAW
|
2014-02-15 19:51:39 +00:00
|
|
|
|
2014-02-16 22:47:20 +00:00
|
|
|
%option outfile="sapi/phpdbg/phpdbg_lexer.c" header-file="sapi/phpdbg/phpdbg_lexer.h"
|
2014-02-15 04:52:04 +00:00
|
|
|
%option warn nodefault
|
|
|
|
|
|
|
|
%option reentrant noyywrap never-interactive nounistd
|
|
|
|
%option bison-bridge
|
|
|
|
|
2014-02-21 14:44:16 +00:00
|
|
|
T_TRUE ?i:"true"
|
|
|
|
T_YES ?i:"yes"
|
|
|
|
T_ON ?i:"on"
|
|
|
|
T_ENABLED ?i:"enabled"
|
|
|
|
T_FALSE ?i:"false"
|
|
|
|
T_NO ?i:"no"
|
|
|
|
T_OFF ?i:"off"
|
|
|
|
T_DISABLED ?i:"disabled"
|
2014-02-21 21:31:01 +00:00
|
|
|
T_EVAL ?i:"ev"
|
|
|
|
T_SHELL ?i:"sh"
|
2014-02-21 14:44:16 +00:00
|
|
|
T_IF ?i:"if"
|
2014-02-15 04:52:04 +00:00
|
|
|
|
2014-02-19 20:18:49 +00:00
|
|
|
WS [ \r\n\t]+
|
|
|
|
DIGITS [0-9\.]+
|
2014-02-21 16:29:09 +00:00
|
|
|
ID [^ \r\n\t:#]+
|
2014-02-21 16:18:46 +00:00
|
|
|
ADDR 0x[a-fA-F0-9]+
|
2014-02-21 17:47:02 +00:00
|
|
|
OPCODE ?i:ZEND_([A-Za-z])+
|
2014-02-17 22:43:53 +00:00
|
|
|
INPUT [^\n]+
|
2014-02-15 04:52:04 +00:00
|
|
|
%%
|
2014-02-27 19:10:59 +00:00
|
|
|
<INITIAL>{
|
2014-02-21 14:44:16 +00:00
|
|
|
[#]{1} { return T_POUND; }
|
|
|
|
[:]{2} { return T_DCOLON; }
|
|
|
|
[:]{1} { return T_COLON; }
|
|
|
|
{T_EVAL} {
|
2014-02-17 08:53:47 +00:00
|
|
|
BEGIN(RAW);
|
|
|
|
phpdbg_init_param(yylval, EMPTY_PARAM);
|
2014-02-21 14:44:16 +00:00
|
|
|
return T_EVAL;
|
2014-02-17 08:53:47 +00:00
|
|
|
}
|
2014-02-21 14:44:16 +00:00
|
|
|
{T_SHELL} {
|
2014-02-17 08:53:47 +00:00
|
|
|
BEGIN(RAW);
|
|
|
|
phpdbg_init_param(yylval, EMPTY_PARAM);
|
2014-02-21 14:44:16 +00:00
|
|
|
return T_SHELL;
|
2014-02-17 08:53:47 +00:00
|
|
|
}
|
2014-02-21 14:44:16 +00:00
|
|
|
{T_IF} {
|
2014-02-17 08:53:47 +00:00
|
|
|
BEGIN(RAW);
|
|
|
|
phpdbg_init_param(yylval, EMPTY_PARAM);
|
2014-02-21 14:44:16 +00:00
|
|
|
return T_IF;
|
2014-02-17 08:53:47 +00:00
|
|
|
}
|
2014-02-21 14:44:16 +00:00
|
|
|
{T_YES}|{T_ON}|{T_ENABLED}|{T_TRUE} {
|
2014-02-16 19:25:15 +00:00
|
|
|
phpdbg_init_param(yylval, NUMERIC_PARAM);
|
2014-02-15 19:51:39 +00:00
|
|
|
yylval->num = 1;
|
2014-02-21 14:44:16 +00:00
|
|
|
return T_TRUTHY;
|
2014-02-15 19:51:39 +00:00
|
|
|
}
|
2014-02-21 14:44:16 +00:00
|
|
|
{T_NO}|{T_OFF}|{T_DISABLED}|{T_FALSE} {
|
2014-02-16 19:25:15 +00:00
|
|
|
phpdbg_init_param(yylval, NUMERIC_PARAM);
|
2014-02-15 19:51:39 +00:00
|
|
|
yylval->num = 0;
|
2014-02-21 14:44:16 +00:00
|
|
|
return T_FALSY;
|
2014-02-15 19:51:39 +00:00
|
|
|
}
|
2014-02-16 22:47:20 +00:00
|
|
|
{DIGITS} {
|
2014-02-16 19:25:15 +00:00
|
|
|
phpdbg_init_param(yylval, NUMERIC_PARAM);
|
2014-02-15 19:51:39 +00:00
|
|
|
yylval->num = atoi(yytext);
|
|
|
|
return T_DIGITS;
|
|
|
|
}
|
2014-02-21 16:18:46 +00:00
|
|
|
{ADDR} {
|
2014-02-16 19:25:15 +00:00
|
|
|
phpdbg_init_param(yylval, ADDR_PARAM);
|
2014-02-15 19:51:39 +00:00
|
|
|
yylval->addr = strtoul(yytext, NULL, 10);
|
2014-02-21 16:18:46 +00:00
|
|
|
return T_ADDR;
|
|
|
|
}
|
|
|
|
{OPCODE} {
|
|
|
|
phpdbg_init_param(yylval, OP_PARAM);
|
|
|
|
yylval->str = strndup(yytext, yyleng);
|
|
|
|
yylval->len = yyleng;
|
|
|
|
return T_OPCODE;
|
2014-02-15 19:51:39 +00:00
|
|
|
}
|
2014-02-21 14:44:16 +00:00
|
|
|
{ID} {
|
2014-02-16 19:25:15 +00:00
|
|
|
phpdbg_init_param(yylval, STR_PARAM);
|
2014-02-15 23:34:35 +00:00
|
|
|
yylval->str = strndup(yytext, yyleng);
|
|
|
|
yylval->len = yyleng;
|
|
|
|
return T_ID;
|
2014-02-15 22:53:20 +00:00
|
|
|
}
|
2014-02-15 04:52:04 +00:00
|
|
|
}
|
2014-02-27 19:10:59 +00:00
|
|
|
|
2014-02-15 19:51:39 +00:00
|
|
|
<RAW>{INPUT} {
|
2014-02-16 19:25:15 +00:00
|
|
|
phpdbg_init_param(yylval, STR_PARAM);
|
2014-02-15 04:52:04 +00:00
|
|
|
yylval->str = strndup(yytext, yyleng);
|
|
|
|
yylval->len = yyleng;
|
2014-02-15 19:51:39 +00:00
|
|
|
BEGIN(INITIAL);
|
|
|
|
return T_INPUT;
|
2014-02-15 04:52:04 +00:00
|
|
|
}
|
2014-02-27 19:10:59 +00:00
|
|
|
|
2014-02-16 19:25:15 +00:00
|
|
|
{WS} { /* ignore whitespace */ }
|
2014-02-15 04:52:04 +00:00
|
|
|
%%
|