Skip to content

Commit 5fcbd30

Browse files
committed
WIP. Initial support syntax assign-bitwise operators
1 parent a9c751b commit 5fcbd30

File tree

10 files changed

+289
-178
lines changed

10 files changed

+289
-178
lines changed

parser/base.c

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
1+
12
/*
2-
+--------------------------------------------------------------------------+
3-
| Zephir Parser |
4-
+--------------------------------------------------------------------------+
5-
| Copyright (c) 2013-2017 Zephir Team and contributors |
6-
+--------------------------------------------------------------------------+
7-
| This source file is subject the MIT license, that is bundled with |
8-
| this package in the file LICENSE, and is available through the |
9-
| world-wide-web at the following url: |
10-
| http://zephir-lang.com/license.html |
11-
| |
12-
| If you did not receive a copy of the MIT license and are unable |
13-
| to obtain it through the world-wide-web, please send a note to |
14-
| license@zephir-lang.com so we can mail you a copy immediately. |
15-
+--------------------------------------------------------------------------+
3+
+--------------------------------------------------------------------------+
4+
| Zephir Parser |
5+
| Copyright (c) 2013-present Zephir (https://zephir-lang.com/) |
6+
| |
7+
| This source file is subject the MIT license, that is bundled with this |
8+
| package in the file LICENSE, and is available through the world-wide-web |
9+
| at the following url: http://zephir-lang.com/license.html |
10+
+--------------------------------------------------------------------------+
1611
*/
1712

1813
const xx_token_names xx_tokens[] =
@@ -275,23 +270,32 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
275270
case XX_T_ASSIGN:
276271
xx_(xx_parser, XX_ASSIGN, NULL, parser_status);
277272
break;
278-
case XX_T_ADDASSIGN:
279-
xx_(xx_parser, XX_ADDASSIGN, NULL, parser_status);
273+
case XX_T_ASSIGN_ADD:
274+
xx_(xx_parser, XX_ASSIGN_ADD, NULL, parser_status);
275+
break;
276+
case XX_T_ASSIGN_SUB:
277+
xx_(xx_parser, XX_ASSIGN_SUB, NULL, parser_status);
278+
break;
279+
case XX_T_ASSIGN_DIV:
280+
xx_(xx_parser, XX_ASSIGN_DIV, NULL, parser_status);
280281
break;
281-
case XX_T_SUBASSIGN:
282-
xx_(xx_parser, XX_SUBASSIGN, NULL, parser_status);
282+
case XX_T_ASSIGN_MUL:
283+
xx_(xx_parser, XX_ASSIGN_MUL, NULL, parser_status);
283284
break;
284-
case XX_T_DIVASSIGN:
285-
xx_(xx_parser, XX_DIVASSIGN, NULL, parser_status);
285+
case XX_T_ASSIGN_CONCAT:
286+
xx_(xx_parser, XX_ASSIGN_CONCAT, NULL, parser_status);
286287
break;
287-
case XX_T_MULASSIGN:
288-
xx_(xx_parser, XX_MULASSIGN, NULL, parser_status);
288+
case XX_T_ASSIGN_MOD:
289+
xx_(xx_parser, XX_T_ASSIGN_MOD, NULL, parser_status);
289290
break;
290-
case XX_T_CONCATASSIGN:
291-
xx_(xx_parser, XX_CONCATASSIGN, NULL, parser_status);
291+
case XX_T_ASSIGN_BITWISE_OR:
292+
xx_(xx_parser, XX_ASSIGN_BITWISE_OR, NULL, parser_status);
292293
break;
293-
case XX_T_MODASSIGN:
294-
xx_(xx_parser, XX_MODASSIGN, NULL, parser_status);
294+
case XX_T_ASSIGN_BITWISE_XOR:
295+
xx_(xx_parser, XX_ASSIGN_BITWISE_XOR, NULL, parser_status);
296+
break;
297+
case XX_T_ASSIGN_BITWISE_SHIFTLEFT:
298+
xx_(xx_parser, XX_ASSIGN_BITWISE_SHIFTLEFT, NULL, parser_status);
295299
break;
296300
case XX_T_EQUALS:
297301
xx_(xx_parser, XX_EQUALS, NULL, parser_status);
@@ -524,7 +528,7 @@ void xx_parse_program(zval *return_value, char *program, size_t program_length,
524528
int length = (48 + strlen(file_path));
525529
error = emalloc(sizeof(char) * length);
526530
snprintf(error, length, "Scanner: unknown opcode %d on in %s line %d", token.opcode, file_path, state->active_line);
527-
531+
528532
array_init(error_msg);
529533
#if PHP_VERSION_ID >= 70000
530534
add_assoc_string(error_msg, "type", "error");

parser/parser.h

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,30 @@
102102
#define XX_IN 102
103103
#define XX_REVERSE 103
104104
#define XX_LET 104
105-
#define XX_ADDASSIGN 105
106-
#define XX_SUBASSIGN 106
107-
#define XX_MULASSIGN 107
108-
#define XX_DIVASSIGN 108
109-
#define XX_CONCATASSIGN 109
110-
#define XX_MODASSIGN 110
111-
#define XX_STRING 111
112-
#define XX_DOUBLECOLON 112
113-
#define XX_INCR 113
114-
#define XX_DECR 114
115-
#define XX_ECHO 115
116-
#define XX_RETURN 116
117-
#define XX_UNSET 117
118-
#define XX_THROW 118
119-
#define XX_PLUS 119
120-
#define XX_INTEGER 120
121-
#define XX_ISTRING 121
122-
#define XX_CHAR 122
123-
#define XX_DOUBLE 123
124-
#define XX_TRUE 124
125-
#define XX_FALSE 125
126-
#define XX_CBLOCK 126
105+
#define XX_ASSIGN_ADD 105
106+
#define XX_ASSIGN_SUB 106
107+
#define XX_ASSIGN_MUL 107
108+
#define XX_ASSIGN_DIV 108
109+
#define XX_ASSIGN_CONCAT 109
110+
#define XX_ASSIGN_MOD 110
111+
#define XX_ASSIGN_BITWISE_AND 111
112+
#define XX_ASSIGN_BITWISE_OR 112
113+
#define XX_ASSIGN_BITWISE_XOR 113
114+
#define XX_ASSIGN_BITWISE_SHIFTLEFT 114
115+
#define XX_ASSIGN_BITWISE_SHIFTRIGHT 115
116+
#define XX_STRING 116
117+
#define XX_DOUBLECOLON 117
118+
#define XX_INCR 118
119+
#define XX_DECR 119
120+
#define XX_ECHO 120
121+
#define XX_RETURN 121
122+
#define XX_UNSET 122
123+
#define XX_THROW 123
124+
#define XX_PLUS 124
125+
#define XX_INTEGER 125
126+
#define XX_ISTRING 126
127+
#define XX_CHAR 127
128+
#define XX_DOUBLE 128
129+
#define XX_TRUE 129
130+
#define XX_FALSE 130
131+
#define XX_CBLOCK 131

0 commit comments

Comments
 (0)