]> hydra-www.ietfng.org Git - dyna2/commitdiff
Take a stab at fixing up = vs ==
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 15 Jun 2013 00:24:06 +0000 (20:24 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Tue, 18 Jun 2013 01:23:37 +0000 (21:23 -0400)
Adds examples/equalities.dyna to selftests.

examples/equalities.dyna [new file with mode: 0644]
examples/expected/equalities.py.out [new file with mode: 0644]
src/Dyna/Backend/Python/Backend.hs
src/Dyna/Backend/Python/Selftest.hs
src/Dyna/Term/SurfaceSyntax.hs

diff --git a/examples/equalities.dyna b/examples/equalities.dyna
new file mode 100644 (file)
index 0000000..102ae8a
--- /dev/null
@@ -0,0 +1,17 @@
+% Given two items with different names and equal values...
+a += 0.
+b += 0.
+
+% ==
+by_evl_refl  := a == a.     % True
+by_evl_cross := a == b.     % True
+
+% =
+by_syn_refl  := a =  a.     % &a is the same as &a
+by_syn_cross := a =  b.     % ... but not the same as &b.
+
+% is
+by_is_0a     := 0 is a.     % That's right, a evaluates to 0.
+by_is_ab     := a is b.     % b does not evaluate to &a, so this is
+                            % a unification failure and the head
+                            % remains null (not false).
diff --git a/examples/expected/equalities.py.out b/examples/expected/equalities.py.out
new file mode 100644 (file)
index 0000000..637d9c7
--- /dev/null
@@ -0,0 +1,35 @@
+
+Charts
+============
+a/0
+=================
+a                              := 0
+
+b/0
+=================
+b                              := 0
+
+by_evl_cross/0
+=================
+by_evl_cross                   := true
+
+by_evl_refl/0
+=================
+by_evl_refl                    := true
+
+by_is_0a/0
+=================
+by_is_0a                       := true
+
+by_is_ab/0
+=================
+
+
+by_syn_cross/0
+=================
+by_syn_cross                   := false
+
+by_syn_refl/0
+=================
+by_syn_refl                    := true
+
index 4d08cd2a1ae632495c920ec2e50a273d28bd172d..d40d6d64131ce223f45132e2f03f5d236f9b6dbd 100644 (file)
@@ -147,8 +147,7 @@ constants = go
 
   go ("<=",2)    = Just $ PDBS $ infixOp "<="
   go ("<",2)     = Just $ PDBS $ infixOp "<"
-  go ("=",2)     = Just $ PDBS $ infixOp "="
-  -- XXX "==" means something else in Dyna
+  go ("=",2)     = Just $ PDBS $ infixOp "=="
   go ("==",2)    = Just $ PDBS $ infixOp "=="
   go (">=",2)    = Just $ PDBS $ infixOp ">="
   go (">",2)     = Just $ PDBS $ infixOp ">"
index 7e13bddbc7678cec13caa76da7ecc08ae6a823f4..99db41452ac7bcf460bc6d2ef36a4690d911472c 100644 (file)
@@ -75,7 +75,7 @@ mkExample name =
 -- will be broken. ;)
 test_End_To_End :: [Test]
 test_End_To_End = map mkExample
-  [ "simple", "fib-limit", "dijkstra", "papa2", "matrixops" ]
+  [ "simple", "equalities", "fib-limit", "dijkstra", "papa2", "matrixops" ]
 
 test_REPL :: [Test]
 test_REPL = map (\n -> testProgramRuns n ("./test/repl/"++n) [])
index 77ce614f463cdefb97c896b8d3f9258627dbe6e9..a0c45d2133624e9c217478a92a2e4b565dd7ccac 100644 (file)
@@ -62,6 +62,7 @@ defOperSpec = M.fromList
   , ("<=" ,[(4,PFIn AssocNone )            ])
   , ("<"  ,[(4,PFIn AssocNone )            ])
   , ("="  ,[(4,PFIn AssocNone )            ])
+  , ("==" ,[(4,PFIn AssocNone )            ])
   , (">=" ,[(4,PFIn AssocNone )            ])
   , (">"  ,[(4,PFIn AssocNone )            ])
   , ("!=" ,[(4,PFIn AssocNone )            ])
@@ -165,7 +166,8 @@ disposTab_dyna t = DisposTab s a
   -- There are, however, even in this case a few terms we would prefer to
   -- behave structurally by default.
   dt = M.fromList [
-         (("pair" ,2),(SDQuote,[ADEval,ADEval]))
+         (("="    ,2),(SDEval ,[ADQuote,ADQuote]))
+       , (("pair" ,2),(SDQuote,[ADEval ,ADEval ]))
        , (("true" ,0),(SDQuote,[]))
        , (("false",0),(SDQuote,[]))
        ]