@@ -17,18 +17,25 @@ module.exports = {
17
17
this . expect ( this . tok . T_NAMESPACE ) . next ( ) ;
18
18
var result = this . node ( 'namespace' ) ;
19
19
if ( this . token == '{' ) {
20
+ this . currentNamespace = [ '' ] ;
20
21
return result ( [ '' ] , this . read_code_block ( true ) ) ;
21
22
} else {
22
- // @fixme should expect {, T_STRING even if not NS_SEP
23
- if ( this . token === this . tok . T_NS_SEPARATOR )
24
- this . error ( [ '{' , this . tok . T_STRING ] ) ;
23
+ if ( this . token === this . tok . T_NAMESPACE ) this . error ( [ '{' , this . tok . T_STRING ] ) ;
25
24
var name = this . read_namespace_name ( ) ;
26
25
if ( this . token == ';' ) {
26
+ this . currentNamespace = name ;
27
27
var body = this . nextWithComments ( ) . read_top_statements ( ) ;
28
28
this . expect ( this . EOF ) ;
29
29
return result ( name , body ) ;
30
30
} else if ( this . token == '{' ) {
31
+ this . currentNamespace = name ;
31
32
return result ( name , this . read_code_block ( true ) ) ;
33
+ } else if ( this . token === '(' ) {
34
+ // resolve ambuiguity between namespace & function call
35
+ return this . node ( 'call' ) (
36
+ [ 'ns' , name . slice ( 1 ) ]
37
+ , this . read_function_argument_list ( )
38
+ ) ;
32
39
} else {
33
40
this . error ( [ '{' , ';' ] ) ;
34
41
}
@@ -41,6 +48,9 @@ module.exports = {
41
48
* </ebnf>
42
49
*/
43
50
, read_namespace_name : function ( ) {
51
+ if ( this . token === this . tok . T_NAMESPACE ) {
52
+ this . next ( ) . expect ( this . tok . T_NS_SEPARATOR ) . next ( ) ;
53
+ }
44
54
return this . read_list ( this . tok . T_STRING , this . tok . T_NS_SEPARATOR , true ) ;
45
55
}
46
56
/**
0 commit comments