@@ -174,7 +174,7 @@ fn language<'src, 'ast>() -> impl Parser<'src, &'src [Token], (), ParserConfig<'
174
174
. labelled ( "an ordered set of values" ) ;
175
175
176
176
let unordered_container = op ( Symbol :: OpenCurly )
177
- . then ( many)
177
+ . then ( many. clone ( ) )
178
178
. then ( op ( Symbol :: CloseCurly ) )
179
179
. map_with ( |( ( open, nodes) , _close) , extra| {
180
180
let ast: & mut Ast = std:: ops:: DerefMut :: deref_mut ( extra. state ( ) ) ;
@@ -236,13 +236,8 @@ fn language<'src, 'ast>() -> impl Parser<'src, &'src [Token], (), ParserConfig<'
236
236
} ;
237
237
238
238
/*
239
- Source: https://www.foonathan.net/2017/07/operator-precedence/
240
- Inside the categories the relative precedence of the operators is as follows:
241
- logical operators: ! > &&,||, but not mixed && and || chains
242
- comparison operators: no chaining at all
243
- mathematical operators: unary +,- > *,/ > +,-, with the usual associativity
244
- bitwise operators: unary ~ before the binary operators, but again no mixed chaining of &, | and ^ and no chaining of the shift operators
245
- unary operators: just as usual
239
+ For reference, some interesting ideas about partial ordering of precedences:
240
+ - https://www.foonathan.net/2017/07/operator-precedence/
246
241
*/
247
242
248
243
use Symbol :: * ;
@@ -308,9 +303,23 @@ fn language<'src, 'ast>() -> impl Parser<'src, &'src [Token], (), ParserConfig<'
308
303
// postfix_op(11, Try),
309
304
// infix_op(left(9), DoubleArrow),
310
305
// infix_op(left(8), Arrow),
306
+ let params = many
307
+ . clone ( )
308
+ . delimited_by ( op ( Symbol :: OpenParen ) , op ( Symbol :: CloseParen ) )
309
+ . labelled ( "a set of parameters" ) ;
310
+
311
+ let callable = expr
312
+ . clone ( )
313
+ . then ( params)
314
+ . map_with ( |( lhs, rhs) , extra| {
315
+ let ast: & mut Ast = std:: ops:: DerefMut :: deref_mut ( extra. state ( ) ) ;
316
+ ast. add_args ( lhs, rhs)
317
+ } )
318
+ . labelled ( "a callable" ) ;
311
319
312
320
let expr = math_expr
313
321
. clone ( )
322
+ . or ( callable)
314
323
. or ( boolean_expr)
315
324
. or ( comparison)
316
325
. or ( lshift_expr)
0 commit comments