mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
Allow keywords in namespace declaration
This commit is contained in:
parent
3aadc15e2e
commit
78e08fc178
@ -49,6 +49,12 @@ reserved_non_modifiers_identifier:
|
||||
reserved_non_modifiers { $$ = Node\Identifier[$1]; }
|
||||
;
|
||||
|
||||
namespace_declaration_name:
|
||||
T_STRING { $$ = Name[$1]; }
|
||||
| semi_reserved { $$ = Name[$1]; }
|
||||
| T_NAME_QUALIFIED { $$ = Name[$1]; }
|
||||
;
|
||||
|
||||
namespace_name:
|
||||
T_STRING { $$ = Name[$1]; }
|
||||
| T_NAME_QUALIFIED { $$ = Name[$1]; }
|
||||
@ -83,11 +89,11 @@ top_statement:
|
||||
| class_declaration_statement { $$ = $1; }
|
||||
| T_HALT_COMPILER
|
||||
{ $$ = Stmt\HaltCompiler[$this->lexer->handleHaltCompiler()]; }
|
||||
| T_NAMESPACE namespace_name semi
|
||||
| T_NAMESPACE namespace_declaration_name semi
|
||||
{ $$ = Stmt\Namespace_[$2, null];
|
||||
$$->setAttribute('kind', Stmt\Namespace_::KIND_SEMICOLON);
|
||||
$this->checkNamespace($$); }
|
||||
| T_NAMESPACE namespace_name '{' top_statement_list '}'
|
||||
| T_NAMESPACE namespace_declaration_name '{' top_statement_list '}'
|
||||
{ $$ = Stmt\Namespace_[$2, $4];
|
||||
$$->setAttribute('kind', Stmt\Namespace_::KIND_BRACED);
|
||||
$this->checkNamespace($$); }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,44 +1,66 @@
|
||||
Keywords in namespaced name
|
||||
-----
|
||||
<?php
|
||||
namespace fn;
|
||||
namespace fn\use;
|
||||
fn\use();
|
||||
\fn\use();
|
||||
namespace\fn\use();
|
||||
-----
|
||||
!!php7
|
||||
array(
|
||||
0: Stmt_Expression(
|
||||
expr: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: fn
|
||||
1: use
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
0: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: fn
|
||||
)
|
||||
)
|
||||
)
|
||||
1: Stmt_Expression(
|
||||
expr: Expr_FuncCall(
|
||||
name: Name_FullyQualified(
|
||||
parts: array(
|
||||
0: fn
|
||||
1: use
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
2: Stmt_Expression(
|
||||
expr: Expr_FuncCall(
|
||||
name: Name_Relative(
|
||||
parts: array(
|
||||
0: fn
|
||||
1: use
|
||||
1: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: fn
|
||||
1: use
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
0: Stmt_Expression(
|
||||
expr: Expr_FuncCall(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: fn
|
||||
1: use
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
1: Stmt_Expression(
|
||||
expr: Expr_FuncCall(
|
||||
name: Name_FullyQualified(
|
||||
parts: array(
|
||||
0: fn
|
||||
1: use
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
2: Stmt_Expression(
|
||||
expr: Expr_FuncCall(
|
||||
name: Name_Relative(
|
||||
parts: array(
|
||||
0: fn
|
||||
1: use
|
||||
)
|
||||
)
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -32,8 +32,18 @@ array(
|
||||
-----
|
||||
<?php namespace static;
|
||||
-----
|
||||
Syntax error, unexpected T_STATIC, expecting T_STRING or T_NAME_QUALIFIED or '{' from 1:17 to 1:22
|
||||
!!php7
|
||||
Cannot use 'static' as namespace name from 1:17 to 1:22
|
||||
array(
|
||||
0: Stmt_Namespace(
|
||||
name: Name(
|
||||
parts: array(
|
||||
0: static
|
||||
)
|
||||
)
|
||||
stmts: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
-----
|
||||
<?php use A as self;
|
||||
|
Loading…
Reference in New Issue
Block a user