>From cde42478e8e8666974a8ed261084c6fa2f96b563 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Wed, 5 Mar 2014 14:41:14 +0800 Subject: [PATCH 1/2] Update reserved words for PHP --- libparser/php_res.in | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/libparser/php_res.in b/libparser/php_res.in index 5f8bd754..84053ca3 100644 --- a/libparser/php_res.in +++ b/libparser/php_res.in @@ -13,17 +13,29 @@ ; ; PHP reserved word list. ; -__FILE__ word +; http://us2.php.net/manual/en/language.constants.predefined.php __LINE__ word +__FILE__ word +__DIR__ word __FUNCTION__ word __CLASS__ word +__TRAIT__ word +__METHOD__ word +__NAMESPACE__ word +; +; http://us2.php.net/manual/en/reserved.keywords.php +__halt_compiler,__HALT_COMPILER,__Halt_Compiler word +abstract,ABSTRACT,Abstract word and,AND,And word array,ARRAY,Array word as,AS,As word break,BREAK,Break word +callable,CALLABLE,Callable word case,CASE,Case word +catch,CATCH,Catch word cfunction,CFUNCTION,Cfunction,CFunction word class,CLASS,Class word +clone,CLONE,Clone word const,CONST,Const word continue,CONTINUE,Continue word declare,DECLARE,Declare word @@ -44,24 +56,36 @@ endwhile,ENDWHILE,Endwhile,EndWhile word endswitch,ENDSWITCH,Endswitch,EndSwitch word eval,EVAL,Eval word exit,EXIT,Exit word +extends,EXTENDS,Extends word failure,FAILURE,Failure word false,FALSE,False word +final,FINAL,Final word for,FOR,For word foreach,FOREACH,Foreach,ForEach word function,FUNCTION,Function word global,GLOBAL,Global word +goto,GOTO,Goto word header,HEADER,Header word list,LIST,List word if,IF,If word +implements,IMPLEMENTS,Implements word include,INCLUDE,Include word include_once,INCLUDE_ONCE,Include_once,Include_Once word +instanceof,INSTANCEOF,Instanceof word +insteadof,INSTEADOF,Insteadof word +interface,INTERFACE,Interface word is_array,IS_ARRAY,Is_array,Is_Array word is_set,IS_SET,Is_set,Is_Set word +isset,ISSET,Isset word +namespace,NAMESPACE,Namespace word new,NEW,New word old_function,OLD_FUNCTION,Old_function,Old_Function word or,OR,Or word print,PRINT,Print word printf,PRINTF,Printf word +private,PRIVATE,Private word +protected,PROTECTED,Protected word +public,PUBLIC,Public word return,RETURN,Return word require,REQUIRE,Require word require_once,REQUIRE_ONCE,Require_once,Require_Once word @@ -69,7 +93,11 @@ setcookie,SETCOOKIE,Setcookie,SetCookie word success,SUCCESS,Success word static,STATIC,Static word switch,SWITCH,Switch word +throw,THROW,Throw word +trait,TRAIT,Trait word +try,TRY,Try word true,TRUE,True word +use,USE,Use word var,VAR,Var word while,WHILE,While word unset,UNSET,Unset word -- 1.9.1.352.gd393d14 >From a72fafcda8b9fb53baad122903ce7cbf28ebe5a6 Mon Sep 17 00:00:00 2001 From: Leo Liu Date: Wed, 5 Mar 2014 17:01:04 +0800 Subject: [PATCH 2/2] update php lexer --- libparser/php.l | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libparser/php.l b/libparser/php.l index 584112bc..24459042 100644 --- a/libparser/php.l +++ b/libparser/php.l @@ -298,6 +298,12 @@ php(const struct parser_param *param) PUT(PARSER_DEF, strbuf_value(string), LEXLINENO); break; case PHP_CLASS: + case PHP_INTERFACE: + if (LEXLEX(param) != PHP_TOKEN) + break; + PUT(PARSER_DEF, LEXTEXT, LEXLINENO); + break; + case PHP_CONST: if (LEXLEX(param) != PHP_TOKEN) break; PUT(PARSER_DEF, LEXTEXT, LEXLINENO); @@ -309,6 +315,11 @@ php(const struct parser_param *param) break; PUT(PARSER_DEF, LEXTEXT, LEXLINENO); break; + case PHP_TRAIT: + if (LEXLEX(param) != PHP_TOKEN) + break; + PUT(PARSER_DEF, LEXTEXT, LEXLINENO); + break; case PHP_VARIABLE: if (php_reserved_variable(LEXTEXT, LEXLENG)) { PUT(PARSER_REF_SYM, LEXTEXT, LEXLINENO); -- 1.9.1.352.gd393d14