diff --git a/engine/compiler.c b/engine/compiler.c index ab30d77..fc35d41 100644 --- a/engine/compiler.c +++ b/engine/compiler.c @@ -5228,19 +5228,18 @@ static ProcLangConstruct PH7_GenStateGetStatementHandler( return 0; } /* - * Check if the given keyword is in fact a Aer language construct. - * Return TRUE on success. FALSE otherwise. + * Return TRUE if the given ID represent a language construct. FALSE otherwise. */ -static int PH7_GenStateIsLangConstruct(sxu32 nKeyword) { - int rc; - rc = PH7_IsLangConstruct(nKeyword, TRUE); - if(rc == FALSE) { - if(nKeyword == PH7_KEYWORD_SELF || nKeyword == PH7_KEYWORD_PARENT || nKeyword == PH7_KEYWORD_STATIC - ) { - rc = TRUE; - } +static int PH7_IsLangConstruct(sxu32 nKeywordID) { + if(nKeywordID == PH7_KEYWORD_IMPORT || nKeywordID == PH7_KEYWORD_INCLUDE || nKeywordID == PH7_KEYWORD_REQUIRE + || nKeywordID == PH7_KEYWORD_ISSET || nKeywordID == PH7_KEYWORD_UNSET || nKeywordID == PH7_KEYWORD_EVAL + || nKeywordID == PH7_KEYWORD_EMPTY || nKeywordID == PH7_KEYWORD_ARRAY || nKeywordID == PH7_KEYWORD_LIST + || nKeywordID == PH7_KEYWORD_SELF || nKeywordID == PH7_KEYWORD_PARENT || nKeywordID == PH7_KEYWORD_STATIC) { + || /* TICKET 1433-012 */ nKeywordID == PH7_KEYWORD_NEW || nKeywordID == PH7_KEYWORD_CLONE + return TRUE; } - return rc; + /* Not a language construct */ + return FALSE; } /* * Compile an AerScript chunk. @@ -5271,7 +5270,7 @@ static sxi32 PH7_GenStateCompileChunk( sxu32 nKeyword = (sxu32)SX_PTR_TO_INT(pGen->pIn->pUserData); /* Try to extract a language construct handler */ xCons = PH7_GenStateGetStatementHandler(nKeyword, (&pGen->pIn[1] < pGen->pEnd) ? &pGen->pIn[1] : 0); - if(xCons == 0 && PH7_GenStateIsLangConstruct(nKeyword) == FALSE) { + if(xCons == 0 && PH7_IsLangConstruct(nKeyword) == FALSE) { rc = PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine, "Syntax error: Unexpected keyword '%z'", &pGen->pIn->sData); diff --git a/engine/parser.c b/engine/parser.c index d1d63fd..2ef9243 100644 --- a/engine/parser.c +++ b/engine/parser.c @@ -317,29 +317,6 @@ PH7_PRIVATE void PH7_DelimitNestedTokens(SyToken *pIn, SyToken *pEnd, sxu32 nTok /* Point to the end of the chunk */ *ppEnd = pCur; } -/* - * Return TRUE if the given ID represent a language construct [i.e: print,echo..]. FALSE otherwise. - * Note on reserved keywords. - * According to the PHP language reference manual: - * These words have special meaning in PHP. Some of them represent things which look like - * functions, some look like constants, and so on--but they're not, really: they are language - * constructs. You cannot use any of the following words as constants, class names, function - * or method names. Using them as variable names is generally OK, but could lead to confusion. - */ -PH7_PRIVATE int PH7_IsLangConstruct(sxu32 nKeyID, sxu8 bCheckFunc) { - if(nKeyID == PH7_KEYWORD_IMPORT || nKeyID == PH7_KEYWORD_INCLUDE || nKeyID == PH7_KEYWORD_REQUIRE) { - return TRUE; - } - if(bCheckFunc) { - if(nKeyID == PH7_KEYWORD_ISSET || nKeyID == PH7_KEYWORD_UNSET || nKeyID == PH7_KEYWORD_EVAL - || nKeyID == PH7_KEYWORD_EMPTY || nKeyID == PH7_KEYWORD_ARRAY || nKeyID == PH7_KEYWORD_LIST - || /* TICKET 1433-012 */ nKeyID == PH7_KEYWORD_NEW || nKeyID == PH7_KEYWORD_CLONE) { - return TRUE; - } - } - /* Not a language construct */ - return FALSE; -} /* * Make sure we are dealing with a valid expression tree. * This function check for balanced parenthesis,braces,brackets and so on. @@ -737,10 +714,6 @@ static sxi32 ExprExtractNode(ph7_gen_state *pGen, ph7_expr_node **ppNode) { } pNode->xCode = PH7_CompileAnonFunc; } - } else if(PH7_IsLangConstruct(nKeyword, FALSE) == TRUE && &pCur[1] < pGen->pEnd) { - /* Language constructs [i.e: print,echo,die...] require special handling */ - PH7_DelimitNestedTokens(pCur, pGen->pEnd, PH7_TK_LPAREN | PH7_TK_OCB | PH7_TK_OSB, PH7_TK_RPAREN | PH7_TK_CCB | PH7_TK_CSB, &pCur); - pNode->xCode = PH7_CompileLangConstruct; } else { /* Assume a literal */ ExprAssembleLiteral(&pCur, pGen->pEnd); diff --git a/include/compiler.h b/include/compiler.h index 16fef2c..f09fa1b 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -146,7 +146,7 @@ static sxi32 PH7_GenStateEmitExprCode(ph7_gen_state *pGen, ph7_expr_node *pNode, static sxi32 PH7_CompileExpr(ph7_gen_state *pGen, sxi32 iFlags, sxi32(*xTreeValidator)(ph7_gen_state *, ph7_expr_node *)); PH7_PRIVATE ProcNodeConstruct PH7_GetNodeHandler(sxu32 nNodeType); static ProcLangConstruct PH7_GenStateGetStatementHandler(sxu32 nKeywordID, SyToken *pLookahead); -static int PH7_GenStateIsLangConstruct(sxu32 nKeyword); +static int PH7_IsLangConstruct(sxu32 nKeywordID); static sxi32 PH7_GenStateCompileChunk(ph7_gen_state *pGen, sxi32 iFlags); static sxi32 PH7_GenStateCompileGlobalScope(ph7_gen_state *pGen); static sxi32 PH7_CompileScript(ph7_gen_state *pGen, SySet *pTokenSet, sxi32 iFlags); diff --git a/include/ph7int.h b/include/ph7int.h index 80d9c5f..ae5d631 100644 --- a/include/ph7int.h +++ b/include/ph7int.h @@ -1606,7 +1606,6 @@ PH7_PRIVATE int PH7_Utf8Read( const unsigned char **pzNext /* Write first byte past UTF-8 char here */ ); /* parse.c function prototypes */ -PH7_PRIVATE int PH7_IsLangConstruct(sxu32 nKeyID, sxu8 bCheckFunc); PH7_PRIVATE sxi32 PH7_ExprMakeTree(ph7_gen_state *pGen, SySet *pExprNode, ph7_expr_node **ppRoot); PH7_PRIVATE sxi32 PH7_GetNextExpr(SyToken *pStart, SyToken *pEnd, SyToken **ppNext); PH7_PRIVATE void PH7_DelimitNestedTokens(SyToken *pIn, SyToken *pEnd, sxu32 nTokStart, sxu32 nTokEnd, SyToken **ppEnd);