summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-11-03 11:59:35 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-11-03 11:59:35 +0000
commite2655aa332a33b56d9168928511a598fc9b0c1e6 (patch)
tree6801c00bc1f2f9995f1627c1a6b2df7e20ca55af
parentad0976f8d5f2afbca4e2fe6cbb3d2c2e53760222 (diff)
downloadguix-e2655aa332a33b56d9168928511a598fc9b0c1e6.tar.gz
* Shorter list syntax ([a b c] instead of [a, b, c]).
-rw-r--r--src/fix-ng/fix-expr.cc10
-rw-r--r--src/fix-ng/fix.sdf6
-rw-r--r--src/fix-ng/parser.cc7
3 files changed, 15 insertions, 8 deletions
diff --git a/src/fix-ng/fix-expr.cc b/src/fix-ng/fix-expr.cc
index 96cb13b725..6333595c63 100644
--- a/src/fix-ng/fix-expr.cc
+++ b/src/fix-ng/fix-expr.cc
@@ -4,8 +4,6 @@
 
 ATerm bottomupRewrite(TermFun & f, ATerm e)
 {
-    e = f(e);
-
     if (ATgetType(e) == AT_APPL) {
         AFun fun = ATgetAFun(e);
         int arity = ATgetArity(fun);
@@ -14,10 +12,10 @@ ATerm bottomupRewrite(TermFun & f, ATerm e)
         for (int i = arity - 1; i >= 0; i--)
             args = ATinsert(args, bottomupRewrite(f, ATgetArgument(e, i)));
         
-        return (ATerm) ATmakeApplList(fun, args);
+        e = (ATerm) ATmakeApplList(fun, args);
     }
 
-    if (ATgetType(e) == AT_LIST) {
+    else if (ATgetType(e) == AT_LIST) {
         ATermList in = (ATermList) e;
         ATermList out = ATempty;
 
@@ -26,10 +24,10 @@ ATerm bottomupRewrite(TermFun & f, ATerm e)
             in = ATgetNext(in);
         }
 
-        return (ATerm) ATreverse(out);
+        e = (ATerm) ATreverse(out);
     }
 
-    return e;
+    return f(e);
 }
 
 
diff --git a/src/fix-ng/fix.sdf b/src/fix-ng/fix.sdf
index e09480314b..8e9f0fa721 100644
--- a/src/fix-ng/fix.sdf
+++ b/src/fix-ng/fix.sdf
@@ -45,7 +45,9 @@ exports
     Bind ";" -> BindSemi 
     BindSemi* -> Binds
 
-    "[" Expr* "]" -> Expr {cons("List")}
+    "[" ExprList "]" -> Expr {cons("List")}
+    "" -> ExprList {cons("ExprNil")}
+    Expr ExprList -> ExprList {cons("ExprCons")}
 
     Expr "." Id -> Expr {cons("Select")}
 
@@ -58,7 +60,7 @@ exports
   context-free priorities
 
     Expr "." Id -> Expr
-  > 
+  > Expr ExprList -> ExprList
   > Expr Expr -> Expr
   > "{" {Id ","}* "}" ":" Expr -> Expr
 
diff --git a/src/fix-ng/parser.cc b/src/fix-ng/parser.cc
index e159262ca1..43678ec971 100644
--- a/src/fix-ng/parser.cc
+++ b/src/fix-ng/parser.cc
@@ -56,6 +56,13 @@ struct Cleanup : TermFun
         if (ATmatch(e, "Bool(\"false\")", &s))
             return ATmake("Bool(False)");
 
+        if (ATmatch(e, "ExprNil"))
+            return (ATerm) ATempty;
+
+        ATerm e1, e2;
+        if (ATmatch(e, "ExprCons(<term>, [<list>])", &e1, &e2))
+            return (ATerm) ATinsert((ATermList) e2, e1);
+
         return e;
     }
 };