Index: Zend/zend_language_scanner.l =================================================================== --- Zend/zend_language_scanner.l (révision 25) +++ Zend/zend_language_scanner.l (révision 33) @@ -870,6 +870,10 @@ return T_CONST; } +"enum" { + return T_ENUM; +} + "return" { return T_RETURN; } Index: Zend/zend_language_parser.y =================================================================== --- Zend/zend_language_parser.y (révision 25) +++ Zend/zend_language_parser.y (révision 33) @@ -156,6 +156,7 @@ %token T_NS_C %token T_DIR %token T_NS_SEPARATOR +%token T_ENUM %% /* Rules */ @@ -200,10 +201,20 @@ ; constant_declaration: - constant_declaration ',' T_STRING '=' static_scalar { zend_do_declare_constant(&$3, &$5 TSRMLS_CC); } - | T_CONST T_STRING '=' static_scalar { zend_do_declare_constant(&$2, &$4 TSRMLS_CC); } + constant_declaration ',' inner_constant_declaration + | T_CONST inner_constant_declaration ; +inner_constant_declaration: + T_STRING '=' static_scalar { zend_do_declare_constant(&$1, &$3 TSRMLS_CC); } + | T_ENUM { CG(enum_current_value) = 0; } '{' constant_enum_declaration '}' +; + +constant_enum_declaration: + constant_enum_declaration ',' T_STRING constant_enum_value { zend_do_declare_constant(&$3, &$4 TSRMLS_CC); } + | T_STRING constant_enum_value { zend_do_declare_constant(&$1, &$2 TSRMLS_CC); } +; + inner_statement_list: inner_statement_list { zend_do_extended_info(TSRMLS_C); } inner_statement { HANDLE_INTERACTIVE(); } | /* empty */ @@ -628,10 +639,25 @@ ; class_constant_declaration: - class_constant_declaration ',' T_STRING '=' static_scalar { zend_do_declare_class_constant(&$3, &$5 TSRMLS_CC); } - | T_CONST T_STRING '=' static_scalar { zend_do_declare_class_constant(&$2, &$4 TSRMLS_CC); } + class_constant_declaration ',' class_constant_inner_declaration + | T_CONST class_constant_inner_declaration ; +class_constant_inner_declaration: + T_STRING '=' static_scalar { zend_do_declare_class_constant(&$1, &$3 TSRMLS_CC); } + | T_ENUM { CG(enum_current_value) = 0; } '{' class_constant_enum_declaration '}' +; + +class_constant_enum_declaration: + class_constant_enum_declaration ',' T_STRING constant_enum_value { zend_do_declare_class_constant(&$3, &$4 TSRMLS_CC); } + | T_STRING constant_enum_value { zend_do_declare_class_constant(&$1, &$2 TSRMLS_CC); } +; + +constant_enum_value: + '=' T_LNUMBER { $$ = $2; CG(enum_current_value) = Z_LVAL($$.u.constant); } + | /* empty */ { $$.op_type = IS_CONST; INIT_PZVAL(&$$.u.constant); Z_TYPE($$.u.constant) = IS_LONG; Z_LVAL($$.u.constant) = ++CG(enum_current_value); } +; + echo_expr_list: echo_expr_list ',' expr { zend_do_echo(&$3 TSRMLS_CC); } | expr { zend_do_echo(&$1 TSRMLS_CC); } Index: Zend/zend_globals.h =================================================================== --- Zend/zend_globals.h (révision 25) +++ Zend/zend_globals.h (révision 33) @@ -151,6 +151,7 @@ void (*interned_strings_snapshot)(TSRMLS_D); void (*interned_strings_restore)(TSRMLS_D); + long enum_current_value; #ifdef ZEND_MULTIBYTE zend_encoding **script_encoding_list; size_t script_encoding_list_size;