summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-11-12 19:04:39 +0100
committerJo-Philipp Wich <jo@mein.io>2020-11-12 19:04:39 +0100
commitcfb9b55964ff7074e1b35883b4b6009060151b26 (patch)
treeab5d9115848281ff71ac54594b03d036dbbf2a9b
parent225a2807f10ac02844eb2a7a65fdf7999a62ba66 (diff)
parser: reuse T_FUNC nodes when creating anonymous function values
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--parser.y16
1 files changed, 8 insertions, 8 deletions
diff --git a/parser.y b/parser.y
index d36ab0c..45958b0 100644
--- a/parser.y
+++ b/parser.y
@@ -441,14 +441,14 @@ primary_exp(A) ::= T_THIS(B). { A = B; }
primary_exp(A) ::= array(B). { A = B; }
primary_exp(A) ::= object(B). { A = B; }
primary_exp(A) ::= paren_exp(B). { A = ut_reject_local(s, B); }
-primary_exp(A) ::= T_FUNC T_LPAREN T_RPAREN empty_object.
- { A = new_op(T_FUNC, NULL, 0, 0, 0); }
-primary_exp(A) ::= T_FUNC T_LPAREN args(B) T_RPAREN empty_object.
- { A = new_op(T_FUNC, NULL, 0, B, 0); }
-primary_exp(A) ::= T_FUNC T_LPAREN T_RPAREN cpd_stmt(B).
- { A = new_op(T_FUNC, NULL, 0, 0, B); }
-primary_exp(A) ::= T_FUNC T_LPAREN args(B) T_RPAREN cpd_stmt(C).
- { A = new_op(T_FUNC, NULL, 0, B, C); }
+primary_exp(A) ::= T_FUNC(B) T_LPAREN T_RPAREN empty_object.
+ { A = B; }
+primary_exp(A) ::= T_FUNC(B) T_LPAREN args(C) T_RPAREN empty_object.
+ { A = wrap_op(B, 0, C, 0); }
+primary_exp(A) ::= T_FUNC(B) T_LPAREN T_RPAREN cpd_stmt(C).
+ { A = wrap_op(B, 0, 0, C); }
+primary_exp(A) ::= T_FUNC(B) T_LPAREN args(C) T_RPAREN cpd_stmt(D).
+ { A = wrap_op(B, 0, C, D); }
paren_exp(A) ::= T_LPAREN exp(B) T_RPAREN. { A = B; }
paren_exp(A) ::= T_LPAREN T_LOCAL(B) decls(C) T_RPAREN. { A = wrap_op(B, C); }