File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -178,17 +178,10 @@ class TokenParser {
178
178
return { type : 'ExpressionReference' , child } ;
179
179
}
180
180
case Token . TOK_LPAREN : {
181
+ console . log ( 'nud::TOK_LPAREN' ) ;
181
182
const args : ExpressionNode [ ] = [ ] ;
182
- while ( this . lookahead ( 0 ) !== Token . TOK_RPAREN ) {
183
- let expression : ExpressionNode ;
184
- if ( this . lookahead ( 0 ) === Token . TOK_CURRENT ) {
185
- expression = { type : Token . TOK_CURRENT } ;
186
- this . advance ( ) ;
187
- } else {
188
- expression = this . expression ( 0 ) ;
189
- }
190
- args . push ( expression ) ;
191
- }
183
+ let expression = this . expression ( 0 ) ;
184
+ args . push ( expression ) ;
192
185
this . match ( Token . TOK_RPAREN ) ;
193
186
return args [ 0 ] ;
194
187
}
Original file line number Diff line number Diff line change @@ -55,4 +55,14 @@ describe('parsing', () => {
55
55
return null ;
56
56
} , 'syntax' ) ;
57
57
} ) ;
58
+ it ( 'should parse paren expression' , ( ) => {
59
+ // see #22 - issue with parenthesized expression-type
60
+ const expected = {
61
+ type : 'AndExpression' ,
62
+ left : { type : 'Current' } ,
63
+ right : { type : 'Literal' }
64
+ } ;
65
+ expect ( compile ( ' @ && \'truthy\' ' ) ) . toMatchObject ( expected ) ;
66
+ expect ( compile ( '( @ && \'truthy\' )' ) ) . toMatchObject ( expected ) ;
67
+ } ) ;
58
68
} ) ;
You can’t perform that action at this time.
0 commit comments