@@ -136,7 +136,12 @@ export class Parser {
136
136
}
137
137
138
138
const ifBody = getBody ( instruction . tokens , endDefOfDef + 1 ) ;
139
- const conditionNode = this . createExpressionNode ( instruction . tokens . slice ( 1 , endDefOfDef ) )
139
+ const conditionTokens = instruction . tokens . slice ( 1 , endDefOfDef ) ;
140
+
141
+ const conditionNode = ( findIndexes ( conditionTokens , OperationTypes . Logical , logicOpIndexes ) ) ?
142
+ this . groupLogicalOperations ( logicOpIndexes , conditionTokens )
143
+ :
144
+ this . createExpressionNode ( conditionTokens ) ;
140
145
141
146
let elseBody : AstNode [ ] | undefined = undefined ;
142
147
if ( instructions . length > i + 1
@@ -261,10 +266,16 @@ export class Parser {
261
266
throw ( `Can't find : for [while]` )
262
267
}
263
268
264
- const condition = this . createExpressionNode ( instruction . tokens . slice ( 1 , endDefOfDef ) )
269
+
270
+ const conditionTokens = instruction . tokens . slice ( 1 , endDefOfDef ) ;
271
+ const conditionNode = ( findIndexes ( conditionTokens , OperationTypes . Logical , logicOpIndexes ) ) ?
272
+ this . groupLogicalOperations ( logicOpIndexes , conditionTokens )
273
+ :
274
+ this . createExpressionNode ( conditionTokens ) ;
275
+
265
276
const body = getBody ( instruction . tokens , endDefOfDef + 1 ) ;
266
277
267
- ast . body . push ( new WhileNode ( condition , body , getTokenLoc ( firstToken ) ) )
278
+ ast . body . push ( new WhileNode ( conditionNode , body , getTokenLoc ( firstToken ) ) ) ;
268
279
269
280
} else if ( getTokenValue ( firstToken ) === 'import' ) {
270
281
let asIndex = findTokenValueIndex ( instruction . tokens , v => v === 'as' ) ;
@@ -556,7 +567,7 @@ export class Parser {
556
567
let name : AstNode | null = null ;
557
568
const namePart = keyValue [ 0 ] ;
558
569
559
- if ( namePart . length === 1 ) {
570
+ if ( namePart . length === 1 ) {
560
571
name = new ConstNode ( namePart [ 0 ] ) ;
561
572
} else if ( getTokenValue ( namePart [ 0 ] ) === '['
562
573
&& getTokenValue ( namePart [ namePart . length - 1 ] ) === ']' ) {
0 commit comments