Function and production invocation
append([1,2], [3,4]) fromMaybe(1, just(2)) cons(1, cons(2, nil()))
Functions and productions are invoked with identical syntax, which is similar to C/Java’s (i.e. uncurried):
expression ( expressions... )
Example: invoking the
substringfunction, with three arguments.
substring(1, 5, "/path/file")
fooas a parameter to either
b, depending on the value of
(if cond then a else b)(foo)
Example: constructing trees (given suitable productions
Note that production application necessarily produces the undecorated type of the nonterminal it constructs. (See Decorated vs Undecorated for more on the distinction between decorated and undecorated.)
Missing arguments replaced by underscores will result in a partially-applied function.
map(add(3,_), [1,2]) = [add(3,1), add(3,2)] fun(_,_) = fun
Arguments supplied in a partial application are only evaluated once, so any expensive computation will be reused by the other applications of the same resulting function value.
Annotations are supplied to a production as named parameters after the ordered parameters.
add(l.ast, r.ast, location=this.location)