Browse Source

P# is not going to derive namespace syntax from PHP, but from C++.

pull/44/head
Rafal Kupiec 3 years ago
parent
commit
b7792dfc3d
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
  1. 10
      engine/compiler.c
  2. 2
      engine/lexer.c
  3. 4
      engine/parser.c
  4. 2
      include/ph7int.h

10
engine/compiler.c

@ -2920,11 +2920,11 @@ static sxi32 PH7_CompileNamespace(ph7_gen_state *pGen) {
* AS OF THIS VERSION NAMESPACE SUPPORT IS DISABLED. IF YOU NEED A WORKING VERSION THAT IMPLEMENT
* NAMESPACE,PLEASE CONTACT SYMISC SYSTEMS VIA contact@symisc.net.
*/
static sxi32 PH7_CompileUse(ph7_gen_state *pGen) {
static sxi32 PH7_CompileUsing(ph7_gen_state *pGen) {
sxu32 nLine = pGen->pIn->nLine;
sxi32 rc;
pGen->pIn++; /* Jump the 'use' keyword */
/* Assemeble one or more real namespace path */
pGen->pIn++; /* Jump the 'using' keyword */
/* Assemble one or more real namespace path */
for(;;) {
if(pGen->pIn >= pGen->pEnd) {
break;
@ -3348,7 +3348,7 @@ static sxi32 GenStateCompileFunc(
ph7_vm_func_closure_env sEnv;
int got_this = 0; /* TRUE if $this have been seen */
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_KEYWORD)
&& SX_PTR_TO_INT(pGen->pIn->pUserData) == PH7_TKWRD_USE) {
&& SX_PTR_TO_INT(pGen->pIn->pUserData) == PH7_TKWRD_USING) {
sxu32 nLine = pGen->pIn->nLine;
/* Closure,record environment variable */
pGen->pIn++;
@ -5474,7 +5474,7 @@ static const LangConstruct aLangConstruct[] = {
{ PH7_TKWRD_CONST, PH7_CompileConstant }, /* const statement */
{ PH7_TKWRD_VAR, PH7_CompileVar }, /* var statement */
{ PH7_TKWRD_NAMESPACE, PH7_CompileNamespace }, /* namespace statement */
{ PH7_TKWRD_USE, PH7_CompileUse }, /* use statement */
{ PH7_TKWRD_USING, PH7_CompileUsing }, /* using statement */
};
/*
* Return a pointer to the statement handler routine associated

2
engine/lexer.c

@ -603,7 +603,7 @@ static sxu32 KeywordCode(const char *z, int n) {
{"const", PH7_TKWRD_CONST},
{"string", PH7_TKWRD_STRING},
{"global", PH7_TKWRD_GLOBAL},
{"use", PH7_TKWRD_USE},
{"using", PH7_TKWRD_USING},
{"elseif", PH7_TKWRD_ELIF},
{"else", PH7_TKWRD_ELSE},
{"if", PH7_TKWRD_IF},

4
engine/parser.c

@ -581,8 +581,8 @@ static sxi32 ExprAssembleAnnon(ph7_gen_state *pGen, SyToken **ppCur, SyToken *pE
if(pIn->nType & PH7_TK_KEYWORD) {
sxu32 nKey = SX_PTR_TO_INT(pIn->pUserData);
/* Check if we are dealing with a closure */
if(nKey == PH7_TKWRD_USE) {
pIn++; /* Jump the 'use' keyword */
if(nKey == PH7_TKWRD_USING) {
pIn++; /* Jump the 'using' keyword */
if(pIn >= pEnd || (pIn->nType & PH7_TK_LPAREN) == 0) {
/* Syntax error */
rc = PH7_GenCompileError(&(*pGen), E_ERROR, nLine, "Syntax error while declaring anonymous function");

2
include/ph7int.h

@ -1498,7 +1498,7 @@ enum ph7_expr_id {
#define PH7_TKWRD_NEW 0x100 /* new: MUST BE A POWER OF TWO */
#define PH7_TKWRD_CONST 22 /* const */
#define PH7_TKWRD_THROW 23 /* throw */
#define PH7_TKWRD_USE 24 /* use */
#define PH7_TKWRD_USING 24 /* using */
#define PH7_TKWRD_WHILE 26 /* while */
#define PH7_TKWRD_EVAL 27 /* eval */
#define PH7_TKWRD_VAR 28 /* var */

Loading…
Cancel
Save