@@ -136,7 +136,12 @@ export class Parser {
136136 }
137137
138138 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 ) ;
140145
141146 let elseBody : AstNode [ ] | undefined = undefined ;
142147 if ( instructions . length > i + 1
@@ -261,10 +266,16 @@ export class Parser {
261266 throw ( `Can't find : for [while]` )
262267 }
263268
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+
265276 const body = getBody ( instruction . tokens , endDefOfDef + 1 ) ;
266277
267- ast . body . push ( new WhileNode ( condition , body , getTokenLoc ( firstToken ) ) )
278+ ast . body . push ( new WhileNode ( conditionNode , body , getTokenLoc ( firstToken ) ) ) ;
268279
269280 } else if ( getTokenValue ( firstToken ) === 'import' ) {
270281 let asIndex = findTokenValueIndex ( instruction . tokens , v => v === 'as' ) ;
@@ -556,7 +567,7 @@ export class Parser {
556567 let name : AstNode | null = null ;
557568 const namePart = keyValue [ 0 ] ;
558569
559- if ( namePart . length === 1 ) {
570+ if ( namePart . length === 1 ) {
560571 name = new ConstNode ( namePart [ 0 ] ) ;
561572 } else if ( getTokenValue ( namePart [ 0 ] ) === '['
562573 && getTokenValue ( namePart [ namePart . length - 1 ] ) === ']' ) {
0 commit comments