[template-glib] expr-parser.y: only allow func() for anonymous functions



commit 1f72e8d7b05a76c92c3867c653b0a24b9eee3feb
Author: Christian Hergert <chergert redhat com>
Date:   Wed May 4 18:02:46 2022 -0700

    expr-parser.y: only allow func() for anonymous functions
    
    We can just use def/end for cases other than that.

 src/tmpl-expr-parser.y | 18 ------------------
 tests/test1.script     |  6 +++---
 2 files changed, 3 insertions(+), 21 deletions(-)
---
diff --git a/src/tmpl-expr-parser.y b/src/tmpl-expr-parser.y
index a10ebf7..1a25ff4 100644
--- a/src/tmpl-expr-parser.y
+++ b/src/tmpl-expr-parser.y
@@ -150,24 +150,6 @@ expr: /* nothing */ EOL {
     YYACCEPT;
   }
 
-  | FUNC NAME '(' symlist ')' '=' list EOL {
-    define_function (parser, $2, g_steal_pointer (&$4), $7);
-    YYACCEPT;
-  }
-  | FUNC NAME '(' symlist ')' '=' list ';' {
-    define_function (parser, $2, g_steal_pointer (&$4), $7);
-    YYACCEPT;
-  }
-
-  | FUNC NAME '(' ')' '=' list EOL {
-    define_function (parser, $2, NULL, $6);
-    YYACCEPT;
-  }
-  | FUNC NAME '(' ')' '=' list ';' {
-    define_function (parser, $2, NULL, $6);
-    YYACCEPT;
-  }
-
   | DEF NAME '(' ')' EOL list END {
     define_function (parser, $2, NULL, $6);
     YYACCEPT;
diff --git a/tests/test1.script b/tests/test1.script
index f8f16f2..fb5809d 100644
--- a/tests/test1.script
+++ b/tests/test1.script
@@ -26,14 +26,14 @@ assert(abc != "def")
 
 # we can't do builtins yet w/ >1 param so this is a
 # very bad pow() implementation that works on integers only.
-func pow(a,b) = while b > 1 do a = a * a; b = b - 1;
+pow = func(a,b) while b > 1 do a = a * a; b = b - 1; a
 assert(pow(2,3) == 8)
 assert(pow(2,3) == 8) # and here
-func multiply(x,y) = x * y
+multiply = func(x,y) x*y
 assert(multiply(10, 10) == 100)
 assert(multiply(-10, 10) == -100)
 
-func nop() = pass
+nop = func() pass
 nop()
 
 def order2(a,b) assert(a==1); assert(b==2); end


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]