php-src/dev/phpdbg_lexer.l

106 lines
2.0 KiB
Plaintext
Raw Normal View History

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-15 19:51:39 +00:00
%s RAW
%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"
T_EVAL ?i:"eval"
T_SHELL ?i:"shell"
T_IF ?i:"if"
2014-02-15 04:52:04 +00:00
WS [ \r\n\t]+
DIGITS [0-9\.]+
2014-02-21 14:44:16 +00:00
ID [^ \r\n\t:#]+
OPLINE 0x[a-fA-F0-9]+
LITERAL \"(\\.|[^\\"])*\"
INPUT [^\n]+
2014-02-15 04:52:04 +00:00
%%
2014-02-15 19:51:39 +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} {
BEGIN(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
2014-02-21 14:44:16 +00:00
return T_EVAL;
}
2014-02-21 14:44:16 +00:00
{T_SHELL} {
BEGIN(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
2014-02-21 14:44:16 +00:00
return T_SHELL;
}
2014-02-21 14:44:16 +00:00
{T_IF} {
BEGIN(RAW);
phpdbg_init_param(yylval, EMPTY_PARAM);
2014-02-21 14:44:16 +00:00
return T_IF;
}
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
}
{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;
}
{OPLINE} {
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);
return T_OPLINE;
}
2014-02-16 19:25:15 +00:00
{LITERAL} {
phpdbg_init_param(yylval, STR_PARAM);
2014-02-15 19:51:39 +00:00
yylval->str = strndup(yytext, yyleng);
yylval->len = yyleng;
return T_LITERAL;
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);
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-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-16 19:25:15 +00:00
{WS} { /* ignore whitespace */ }
2014-02-15 04:52:04 +00:00
%%