@@ -322,17 +322,31 @@ class Parser {
322322 return null ;
323323 }
324324
325- function acceptIfElseIf () {
326- if (this .acceptRoamingToken (" keyword" , " elseif" ))
327- return this .instruction ( this .getTokenTrace (), " if" , [this .acceptCondition (), this .acceptBlock (" else if condition" ), true , this .acceptIfElseIf ()] );
325+ function acceptIfElseIf (): Array <Instruction > {
326+ var args = [];
327+ while (true ) {
328+ if (this .acceptRoamingToken (" keyword" , " elseif" )) {
329+ args .push (
330+ this .instruction (this .getTokenTrace (), " if" , [this .acceptCondition (), this .acceptBlock (" elseif condition" ), null , false ])
331+ );
332+ } else if (this .acceptRoamingToken (" keyword" , " else" )) {
333+ args .push (
334+ this .instruction (this .getTokenTrace (), " if" , [null , this .acceptBlock (" else" ), null , true ])
335+ );
336+ break ;
337+ } else {
338+ break ;
339+ }
340+ }
328341
329- return this . acceptIfElse () ;
342+ return args ;
330343 }
331344
332345 function acceptIfElse () {
333346 if (this .acceptRoamingToken (" keyword" , " else" ))
334347 return this .acceptBlock (" else" );
335348
349+ trace (" root?" );
336350 return this .instruction ( this .getTokenTrace (), " root" , [] );
337351 }
338352
@@ -523,7 +537,7 @@ class Parser {
523537 function stmt1 () {
524538 if (this .acceptRoamingToken (" keyword" , " if" )) {
525539 var trace = this .getTokenTrace ();
526- return this .instruction ( trace , " if" , [this .acceptCondition (), this .acceptBlock (" if condition" ), false , this .acceptIfElseIf ()] );
540+ return this .instruction ( trace , " if" , [this .acceptCondition (), this .acceptBlock (" if condition" ), this .acceptIfElseIf (), false ] );
527541 }
528542 return this .stmt2 ();
529543 }
@@ -1136,7 +1150,7 @@ class Parser {
11361150
11371151 expr = this .instruction ( trace , " stringcall" , [expr , exprs , stype ] );
11381152 } else {
1139- expr = this .instruction ( trace , " stringcall" , [expr , exprs , " " ] );
1153+ expr = this .instruction ( trace , " stringcall" , [expr , exprs , null ] );
11401154 }
11411155 } else {
11421156 break ;
0 commit comments