Skip to content

Commit 78e08fc

Browse files
committed
Allow keywords in namespace declaration
1 parent 3aadc15 commit 78e08fc

File tree

4 files changed

+1018
-981
lines changed

4 files changed

+1018
-981
lines changed

grammar/php7.y

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ reserved_non_modifiers_identifier:
4949
reserved_non_modifiers { $$ = Node\Identifier[$1]; }
5050
;
5151

52+
namespace_declaration_name:
53+
T_STRING { $$ = Name[$1]; }
54+
| semi_reserved { $$ = Name[$1]; }
55+
| T_NAME_QUALIFIED { $$ = Name[$1]; }
56+
;
57+
5258
namespace_name:
5359
T_STRING { $$ = Name[$1]; }
5460
| T_NAME_QUALIFIED { $$ = Name[$1]; }
@@ -83,11 +89,11 @@ top_statement:
8389
| class_declaration_statement { $$ = $1; }
8490
| T_HALT_COMPILER
8591
{ $$ = Stmt\HaltCompiler[$this->lexer->handleHaltCompiler()]; }
86-
| T_NAMESPACE namespace_name semi
92+
| T_NAMESPACE namespace_declaration_name semi
8793
{ $$ = Stmt\Namespace_[$2, null];
8894
$$->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON);
8995
$this->checkNamespace($$); }
90-
| T_NAMESPACE namespace_name '{' top_statement_list '}'
96+
| T_NAMESPACE namespace_declaration_name '{' top_statement_list '}'
9197
{ $$ = Stmt\Namespace_[$2, $4];
9298
$$->setAttribute('kind', Stmt\Namespace_::KIND_BRACED);
9399
$this->checkNamespace($$); }

0 commit comments

Comments
 (0)