parse trait
This commit is contained in:
parent
e0ff4b7e57
commit
56ae0982fd
15
parser.y
15
parser.y
@ -289,6 +289,7 @@ func (n node) attribute(key string, value string) node {
|
|||||||
%type <node> inline_use_declaration
|
%type <node> inline_use_declaration
|
||||||
%type <node> unprefixed_use_declaration
|
%type <node> unprefixed_use_declaration
|
||||||
%type <node> use_declaration
|
%type <node> use_declaration
|
||||||
|
%type <node> trait_declaration_statement
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
@ -338,6 +339,7 @@ top_statement:
|
|||||||
statement { $$ = $1 }
|
statement { $$ = $1 }
|
||||||
| function_declaration_statement { $$ = $1 }
|
| function_declaration_statement { $$ = $1 }
|
||||||
| class_declaration_statement { $$ = $1; }
|
| class_declaration_statement { $$ = $1; }
|
||||||
|
| trait_declaration_statement { $$ = $1; }
|
||||||
|
|
||||||
| T_HALT_COMPILER '(' ')' ';' { $$ = Node("THaltCompiler") }
|
| T_HALT_COMPILER '(' ')' ';' { $$ = Node("THaltCompiler") }
|
||||||
|
|
||||||
@ -683,6 +685,10 @@ class_modifier:
|
|||||||
| T_FINAL { $$ = "final" }
|
| T_FINAL { $$ = "final" }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
trait_declaration_statement:
|
||||||
|
T_TRAIT T_STRING '{' class_statement_list '}' { $$ = Node("Trait").attribute("name", $2).append($4) }
|
||||||
|
;
|
||||||
|
|
||||||
class_statement_list:
|
class_statement_list:
|
||||||
class_statement_list class_statement { $$ = $1.append($2) }
|
class_statement_list class_statement { $$ = $1.append($2) }
|
||||||
| /* empty */ { $$ = Node("Stmt") }
|
| /* empty */ { $$ = Node("Stmt") }
|
||||||
@ -1061,8 +1067,13 @@ static_member:
|
|||||||
%%
|
%%
|
||||||
|
|
||||||
const src = `<?php
|
const src = `<?php
|
||||||
use A, B as C;
|
trait foo
|
||||||
use \D\{function E, F};
|
{
|
||||||
|
private static function bas($a = null)
|
||||||
|
{
|
||||||
|
echo $a;
|
||||||
|
}
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user