]> granicus.if.org Git - php/commitdiff
Don't specify precedence for T_INC/T_DEC
authorNikita Popov <nikita.ppv@gmail.com>
Tue, 27 Aug 2019 19:59:56 +0000 (21:59 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Tue, 27 Aug 2019 19:59:56 +0000 (21:59 +0200)
As these do not operate on expressions, precedence is meaningless
for them.

Zend/zend_language_parser.y
ext/tokenizer/tokenizer_data.c

index 9646a2d97a5045bf41351ef0501a1a2d5824d3da..c25d13ecf20e9b101d8f1b6e9fc2517fa52ecf7d 100644 (file)
@@ -75,7 +75,7 @@ static YYSIZE_T zend_yytnamerr(char*, const char*);
 %left '*' '/' '%'
 %precedence '!'
 %precedence T_INSTANCEOF
-%precedence '~' T_INC T_DEC T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@'
+%precedence '~' T_INT_CAST T_DOUBLE_CAST T_STRING_CAST T_ARRAY_CAST T_OBJECT_CAST T_BOOL_CAST T_UNSET_CAST '@'
 %right T_POW
 %precedence T_NEW T_CLONE
 
@@ -938,8 +938,8 @@ expr:
        |       expr '%' expr   { $$ = zend_ast_create_binary_op(ZEND_MOD, $1, $3); }
        |       expr T_SL expr  { $$ = zend_ast_create_binary_op(ZEND_SL, $1, $3); }
        |       expr T_SR expr  { $$ = zend_ast_create_binary_op(ZEND_SR, $1, $3); }
-       |       '+' expr %prec T_INC { $$ = zend_ast_create(ZEND_AST_UNARY_PLUS, $2); }
-       |       '-' expr %prec T_INC { $$ = zend_ast_create(ZEND_AST_UNARY_MINUS, $2); }
+       |       '+' expr %prec '~' { $$ = zend_ast_create(ZEND_AST_UNARY_PLUS, $2); }
+       |       '-' expr %prec '~' { $$ = zend_ast_create(ZEND_AST_UNARY_MINUS, $2); }
        |       '!' expr { $$ = zend_ast_create_ex(ZEND_AST_UNARY_OP, ZEND_BOOL_NOT, $2); }
        |       '~' expr { $$ = zend_ast_create_ex(ZEND_AST_UNARY_OP, ZEND_BW_NOT, $2); }
        |       expr T_IS_IDENTICAL expr
index e6df371a27a8b6790343a65252d0f784e3a7b34a..cc3a1f939f40ed23b2ac2f714ef68c1dcb054788 100644 (file)
@@ -64,8 +64,6 @@ void tokenizer_register_constants(INIT_FUNC_ARGS) {
        REGISTER_LONG_CONSTANT("T_SL", T_SL, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("T_SR", T_SR, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("T_INSTANCEOF", T_INSTANCEOF, CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("T_INC", T_INC, CONST_CS | CONST_PERSISTENT);
-       REGISTER_LONG_CONSTANT("T_DEC", T_DEC, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("T_INT_CAST", T_INT_CAST, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("T_DOUBLE_CAST", T_DOUBLE_CAST, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("T_STRING_CAST", T_STRING_CAST, CONST_CS | CONST_PERSISTENT);
@@ -88,6 +86,8 @@ void tokenizer_register_constants(INIT_FUNC_ARGS) {
        REGISTER_LONG_CONSTANT("T_STRING_VARNAME", T_STRING_VARNAME, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("T_NUM_STRING", T_NUM_STRING, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("T_EVAL", T_EVAL, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("T_INC", T_INC, CONST_CS | CONST_PERSISTENT);
+       REGISTER_LONG_CONSTANT("T_DEC", T_DEC, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("T_EXIT", T_EXIT, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("T_IF", T_IF, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("T_ENDIF", T_ENDIF, CONST_CS | CONST_PERSISTENT);
@@ -207,8 +207,6 @@ char *get_token_type_name(int token_type)
                case T_SL: return "T_SL";
                case T_SR: return "T_SR";
                case T_INSTANCEOF: return "T_INSTANCEOF";
-               case T_INC: return "T_INC";
-               case T_DEC: return "T_DEC";
                case T_INT_CAST: return "T_INT_CAST";
                case T_DOUBLE_CAST: return "T_DOUBLE_CAST";
                case T_STRING_CAST: return "T_STRING_CAST";
@@ -231,6 +229,8 @@ char *get_token_type_name(int token_type)
                case T_STRING_VARNAME: return "T_STRING_VARNAME";
                case T_NUM_STRING: return "T_NUM_STRING";
                case T_EVAL: return "T_EVAL";
+               case T_INC: return "T_INC";
+               case T_DEC: return "T_DEC";
                case T_EXIT: return "T_EXIT";
                case T_IF: return "T_IF";
                case T_ENDIF: return "T_ENDIF";