File tree Expand file tree Collapse file tree 5 files changed +28
-6
lines changed Expand file tree Collapse file tree 5 files changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ module.exports = {
108
108
break ;
109
109
} else {
110
110
this . error ( [ ',' , ')' ] ) ;
111
+ break ;
111
112
}
112
113
}
113
114
}
Original file line number Diff line number Diff line change @@ -20,7 +20,10 @@ module.exports = {
20
20
this . currentNamespace = [ '' ] ;
21
21
return result ( [ '' ] , this . read_code_block ( true ) ) ;
22
22
} else {
23
- if ( this . token === this . tok . T_NAMESPACE ) this . error ( [ '{' , this . tok . T_STRING ] ) ;
23
+ if ( this . token === this . tok . T_NAMESPACE ) {
24
+ this . error ( [ '{' , this . tok . T_STRING ] ) ;
25
+ this . next ( ) ; // ignore namespace token
26
+ }
24
27
var name = this . read_namespace_name ( ) ;
25
28
if ( this . token == ';' ) {
26
29
this . currentNamespace = name ;
@@ -38,6 +41,11 @@ module.exports = {
38
41
) ;
39
42
} else {
40
43
this . error ( [ '{' , ';' ] ) ;
44
+ // graceful mode :
45
+ this . currentNamespace = name ;
46
+ var body = this . read_top_statements ( ) ;
47
+ this . expect ( this . EOF ) ;
48
+ return result ( name , body ) ;
41
49
}
42
50
}
43
51
}
Original file line number Diff line number Diff line change @@ -109,7 +109,10 @@ module.exports = {
109
109
case '[' : // short array format
110
110
return this . read_array ( ) ;
111
111
default :
112
- this . error ( 'SCALAR' ) ;
112
+ var err = this . error ( 'SCALAR' ) ;
113
+ // graceful mode : ignore token & return error node
114
+ this . next ( ) ;
115
+ return err ;
113
116
}
114
117
}
115
118
}
Original file line number Diff line number Diff line change @@ -147,7 +147,10 @@ module.exports = {
147
147
case this . tok . T_INTERFACE :
148
148
return this . read_interface ( flag ) ;
149
149
default :
150
- this . error ( [ this . tok . T_CLASS , this . tok . T_INTERFACE ] ) ;
150
+ var err = this . error ( [ this . tok . T_CLASS , this . tok . T_INTERFACE ] ) ;
151
+ // graceful mode : ignore token & go next
152
+ this . next ( ) ;
153
+ return err ;
151
154
}
152
155
case this . tok . T_CLASS :
153
156
return this . read_class ( 0 ) ;
Original file line number Diff line number Diff line change @@ -59,7 +59,9 @@ module.exports = {
59
59
getter = this . text ( ) ;
60
60
this . next ( ) ;
61
61
} else {
62
- this . error ( [ this . tok . T_VARIABLE , this . tok . T_STRING ] ) ;
62
+ getter = this . error ( [ this . tok . T_VARIABLE , this . tok . T_STRING ] ) ;
63
+ // graceful mode : set getter as error node and continue
64
+ this . next ( ) ;
63
65
}
64
66
if ( from [ 0 ] != 'ns' ) {
65
67
from = [ 'lookup' , 'class' , from ] ;
@@ -131,7 +133,10 @@ module.exports = {
131
133
this . expect ( '}' ) . next ( ) ;
132
134
break ;
133
135
default :
134
- this . error ( [ this . tok . T_STRING , this . tok . T_VARIABLE ] ) ;
136
+ what = this . error ( [ this . tok . T_STRING , this . tok . T_VARIABLE ] ) ;
137
+ // graceful mode : set what as error mode & continue
138
+ this . next ( ) ;
139
+ break ;
135
140
}
136
141
result = [ 'prop' , result , what ] ;
137
142
break ;
@@ -217,7 +222,9 @@ module.exports = {
217
222
this . next ( ) ;
218
223
break ;
219
224
default :
220
- this . error ( [ '{' , '$' , this . tok . T_VARIABLE ] ) ;
225
+ result = this . error ( [ '{' , '$' , this . tok . T_VARIABLE ] ) ;
226
+ // graceful mode
227
+ this . next ( ) ;
221
228
}
222
229
result = [ 'lookup' , 'var' , result ] ;
223
230
}
You can’t perform that action at this time.
0 commit comments