Browse Source

P# supports only ^^ keyword as a logical XOR. There is no need to have 'xor'.

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

+ 1
- 2
lexer.c View File

@ -83,7 +83,7 @@ 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_XOR | PH7_TKWRD_OR | PH7_TKWRD_INSTANCEOF)) {
(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 */
pToken->pUserData = (void *)PH7_ExprExtractOperator(pStr, 0);
/* Mark as an operator */
@ -648,7 +648,6 @@ static sxu32 KeywordCode(const char *z, int n) {
{"public", PH7_TKWRD_PUBLIC},
{"catch", PH7_TKWRD_CATCH},
{"unset", PH7_TKWRD_UNSET},
{"xor", PH7_TKWRD_XOR},
{"break", PH7_TKWRD_BREAK}
};
if(n < 2) {


+ 0
- 2
parser.c View File

@ -241,8 +241,6 @@ static const ph7_expr_op aOpTable[] = {
{ {">>=", 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 21,left-associative */
{ {"xor", sizeof("xor") - 1}, EXPR_OP_LXOR, 21, EXPR_OP_ASSOC_LEFT, PH7_OP_LXOR},
/* 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] */


+ 2
- 3
ph7int.h View File

@ -1410,7 +1410,7 @@ enum ph7_vm_op {
PH7_OP_BOR, /* Bitwise or '|' */
PH7_OP_LAND, /* Logical and '&&','and' */
PH7_OP_LOR, /* Logical or '||','or' */
PH7_OP_LXOR, /* Logical xor 'xor' */
PH7_OP_LXOR, /* Logical xor '^^' */
PH7_OP_STORE, /* Store Object */
PH7_OP_STORE_IDX, /* Store indexed object */
PH7_OP_STORE_IDX_REF,/* Store indexed object by reference */
@ -1493,7 +1493,7 @@ enum ph7_expr_id {
EXPR_OP_BOR, /* bitwise or '|' */
EXPR_OP_LAND, /* Logical and '&&','and' */
EXPR_OP_LOR, /* Logical or '||','or'*/
EXPR_OP_LXOR, /* Logical xor 'xor' */
EXPR_OP_LXOR, /* Logical xor '^^' */
EXPR_OP_QUESTY, /* Ternary operator '?' */
EXPR_OP_ASSIGN, /* Assignment '=' */
EXPR_OP_ADD_ASSIGN, /* Combined operator: += */
@ -1612,7 +1612,6 @@ enum ph7_expr_id {
#define PH7_TKWRD_CATCH 53 /* catch */
#define PH7_TKWRD_RETURN 54 /* return */
#define PH7_TKWRD_UNSET 0x2000 /* unset: MUST BE A POWER OF TWO */
#define PH7_TKWRD_XOR 0x4000 /* xor: MUST BE A POWER OF TWO */
#define PH7_TKWRD_BREAK 55 /* break */
#define PH7_TKWRD_GOTO 56 /* goto */
#define PH7_TKWRD_BOOL 0x8000 /* bool: MUST BE A POWER OF TWO */


Loading…
Cancel
Save