Browse Source

There is no need to use 'and' & 'or' keywords, as P# supports also '&&' and '||' to use respectively

pull/8/head
Rafal Kupiec 3 years ago
parent
commit
8b59a01198
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
3 changed files with 7 additions and 15 deletions
  1. +2
    -4
      lexer.c
  2. +1
    -5
      parser.c
  3. +4
    -6
      ph7int.h

+ 2
- 4
lexer.c View File

@ -83,8 +83,8 @@ static sxi32 TokenizePHP(SyStream *pStream, SyToken *pToken, void *pUserData, vo
nKeyword = KeywordCode(pStr->zString, (int)pStr->nByte);
if(nKeyword != PH7_TK_ID) {
if(nKeyword &
(PH7_TKWRD_NEW | PH7_TKWRD_CLONE | PH7_TKWRD_AND | PH7_TKWRD_OR | PH7_TKWRD_INSTANCEOF)) {
/* Alpha stream operators [i.e: new,clone,and,instanceof,eq,ne,or,xor],save the operator instance for later processing */
(PH7_TKWRD_NEW | PH7_TKWRD_CLONE | PH7_TKWRD_INSTANCEOF)) {
/* Alpha stream operators [i.e: new,clone,instanceof],save the operator instance for later processing */
pToken->pUserData = (void *)PH7_ExprExtractOperator(pStr, 0);
/* Mark as an operator */
pToken->nType = PH7_TK_ID | PH7_TK_OP;
@ -595,7 +595,6 @@ static sxu32 KeywordCode(const char *z, int n) {
{"throw", PH7_TKWRD_THROW},
{"bool", PH7_TKWRD_BOOL},
{"boolean", PH7_TKWRD_BOOL},
{"and", PH7_TKWRD_AND},
{"default", PH7_TKWRD_DEFAULT},
{"try", PH7_TKWRD_TRY},
{"case", PH7_TKWRD_CASE},
@ -640,7 +639,6 @@ static sxu32 KeywordCode(const char *z, int n) {
{"endforeach", PH7_TKWRD_END4EACH},
{"for", PH7_TKWRD_FOR},
{"foreach", PH7_TKWRD_FOREACH},
{"or", PH7_TKWRD_OR},
{"isset", PH7_TKWRD_ISSET},
{"parent", PH7_TKWRD_PARENT},
{"private", PH7_TKWRD_PRIVATE},


+ 1
- 5
parser.c View File

@ -239,10 +239,6 @@ static const ph7_expr_op aOpTable[] = {
{ {"^=", sizeof(char) * 2}, EXPR_OP_XOR_ASSIGN, 19, EXPR_OP_ASSOC_RIGHT, PH7_OP_BXOR_STORE },
{ {"<<=", sizeof(char) * 3}, EXPR_OP_SHL_ASSIGN, 19, EXPR_OP_ASSOC_RIGHT, PH7_OP_SHL_STORE },
{ {">>=", sizeof(char) * 3}, EXPR_OP_SHR_ASSIGN, 19, EXPR_OP_ASSOC_RIGHT, PH7_OP_SHR_STORE },
/* Precedence 20,left-associative */
{ {"and", sizeof("and") - 1}, EXPR_OP_LAND, 20, EXPR_OP_ASSOC_LEFT, PH7_OP_LAND},
/* Precedence 22,left-associative */
{ {"or", sizeof("or") - 1}, EXPR_OP_LOR, 22, EXPR_OP_ASSOC_LEFT, PH7_OP_LOR},
/* Precedence 23,left-associative [Lowest operator] */
{ {",", sizeof(char)}, EXPR_OP_COMMA, 23, EXPR_OP_ASSOC_LEFT, 0},
};
@ -266,7 +262,7 @@ PH7_PRIVATE const ph7_expr_op *PH7_ExprExtractOperator(SyString *pStr, SyToken
break;
}
if(SyisAlpha(aOpTable[n].sOp.zString[0])) {
/* TICKET 1433-012: Alpha stream operators [i.e: and,or,xor,new...] */
/* TICKET 1433-012: Alpha stream operators [i.e: new, clone, instanceof] */
rc = SyStringCmp(pStr, &aOpTable[n].sOp, SyStrnicmp);
} else {
rc = SyStringCmp(pStr, &aOpTable[n].sOp, SyMemcmp);


+ 4
- 6
ph7int.h View File

@ -1402,8 +1402,8 @@ enum ph7_vm_op {
PH7_OP_BAND, /* Bitwise and '&' */
PH7_OP_BXOR, /* Bitwise xor '^' */
PH7_OP_BOR, /* Bitwise or '|' */
PH7_OP_LAND, /* Logical and '&&','and' */
PH7_OP_LOR, /* Logical or '||','or' */
PH7_OP_LAND, /* Logical and '&&' */
PH7_OP_LOR, /* Logical or '||' */
PH7_OP_LXOR, /* Logical xor '^^' */
PH7_OP_STORE, /* Store Object */
PH7_OP_STORE_IDX, /* Store indexed object */
@ -1485,8 +1485,8 @@ enum ph7_expr_id {
EXPR_OP_REF, /* Reference operator '&' */
EXPR_OP_XOR, /* bitwise xor '^' */
EXPR_OP_BOR, /* bitwise or '|' */
EXPR_OP_LAND, /* Logical and '&&','and' */
EXPR_OP_LOR, /* Logical or '||','or'*/
EXPR_OP_LAND, /* Logical and '&&' */
EXPR_OP_LOR, /* Logical or '||' */
EXPR_OP_LXOR, /* Logical xor '^^' */
EXPR_OP_QUESTY, /* Ternary operator '?' */
EXPR_OP_ASSIGN, /* Assignment '=' */
@ -1578,7 +1578,6 @@ enum ph7_expr_id {
#define PH7_TKWRD_ARRAY 0x200 /* array: MUST BE A POWER OF TWO */
#define PH7_TKWRD_ABSTRACT 29 /* abstract */
#define PH7_TKWRD_TRY 30 /* try */
#define PH7_TKWRD_AND 0x400 /* and: MUST BE A POWER OF TWO */
#define PH7_TKWRD_DEFAULT 31 /* default */
#define PH7_TKWRD_CLASS 32 /* class */
#define PH7_TKWRD_AS 33 /* as */
@ -1599,7 +1598,6 @@ enum ph7_expr_id {
#define PH7_TKWRD_END4EACH 0x2000000 /* endforeach: MUST BE A POWER OF TWO */
#define PH7_TKWRD_FOR 48 /* for */
#define PH7_TKWRD_FOREACH 49 /* foreach */
#define PH7_TKWRD_OR 0x1000 /* or: MUST BE A POWER OF TWO */
#define PH7_TKWRD_PROTECTED 50 /* protected */
#define PH7_TKWRD_DO 51 /* do */
#define PH7_TKWRD_PUBLIC 52 /* public */


Loading…
Cancel
Save