summaryrefslogtreecommitdiff
path: root/parser/expr.go
diff options
context:
space:
mode:
Diffstat (limited to 'parser/expr.go')
-rw-r--r--parser/expr.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/parser/expr.go b/parser/expr.go
index e4cef1a..0b2ad2a 100644
--- a/parser/expr.go
+++ b/parser/expr.go
@@ -18,6 +18,17 @@ func (p *Parser) ParseExpr(in Tokens) (out Tokens, err error) {
// Process tokens from last to first, the goal is to reorder the tokens in
// a stack machine processing order, so it can be directly interpreted.
//
+ if len(in) > 1 && in[0].Id == lang.Func {
+ // Function as value (i.e closure).
+ if out, err = p.ParseFunc(in); err != nil {
+ return out, err
+ }
+ // Get function label and use it as a symbol ident.
+ fid := out[1]
+ fid.Id = lang.Ident
+ out = append(out, fid)
+ return out, err
+ }
for i := len(in) - 1; i >= 0; i-- {
t := in[i]
// temporary assumptions: binary operators, returning 1 value