[support objects with no self-name
kragen@pobox.com**20070412105331
 
 Previously, every object literal or override expression had to contain
 a self-name.  Now they can be omitted.
 
] {
hunk ./bicicleta.ml 21
+(* XXX How to handle methods without a selfname? Maybe have a special
+   non-string name that doesn't compare equal to anything?  Or a
+   special kind of method that doesn't augment its environment when
+   called? *)
hunk ./bicicleta.ml 30
+    | AnonLiteral(methods) -> bind ProtoObject env "i hope nobody XXX" methods
hunk ./bicicleta.ml 33
+    | AnonDerivation(object_, methods) -> let object_ = eval env object_
+        in bind object_ env "i hope nobody uses this identifier XXX" methods
hunk ./bicicleta.ml 82
+    | AnonDerivation(object_, methods) ->
+        show_bicexpr object_ ^ show_bicexpr (AnonLiteral(methods))
hunk ./bicicleta.ml 86
+    | AnonLiteral(methods) ->
+        "{" ^ show_methods methods ^ "}"
hunk ./bicicleta.ml 117
+  | AnonLiteral (methods) -> freevars_methods methods
hunk ./bicicleta.ml 120
+  | AnonDerivation (object_, methods) ->
+        StringSet.union (freevars object_) (freevars_methods methods)
hunk ./bicicleta.ml 279
-    (* still to do: various kinds of syntactic sugar *)
+    (* various kinds of syntactic sugar *)
+    assert((parse "x { z = w }") 
+           = AnonDerivation(Name "x", Definition("z", Name "w", NoDefs)));
+    assert((parse "{x = 1, y = 2}") = AnonLiteral(
+        Definition("x", Number "1", Definition("y", Number "2", NoDefs))));
+
+    (* more evaluation tests now that we know parsing works *)
+    assert((eval Phi (parse "{}{\n\tx = \"foo\"\n\ty=\"bar\"}.x"))
+        = BicStr("foo"));
+    assert((eval Phi (parse "{\n\tx = \"foo\"\n\ty=\"bar\"}.y"))
+        = BicStr("bar"));
hunk ./bicicleta.ml 293
+    assert((show_bicexpr (parse "{x = 1}")) = "{x = 1}");
hunk ./bicicleta.ml 317
+
+    assert(freevars_are "{}" []);
+    assert(freevars_are "{x=y}" ["y"]);
+    assert(freevars_are "x {y = z}" ["x"; "z"]);
+
hunk ./bicicleta_parser.mly 30
-  | literal               { Literal(fst $1, snd $1) }
-  | expr o literal        { Derivation($1, fst $3, snd $3) }
+  | literal               { match fst $1 with 
+                              Some name -> Literal(name, snd $1) 
+                            | None -> AnonLiteral(snd $1) }
+  | expr o literal        { match fst $3 with
+                              Some name -> Derivation($1, name, snd $3) 
+                            | None -> AnonDerivation($1, snd $3) }
hunk ./bicicleta_parser.mly 41
-    Lbrace o NameTok o Colon o definitions Rbrace { ($3, $7) }
+    Lbrace o NameTok o Colon o definitions Rbrace { ((Some $3), $7) }
+  | Lbrace o definitions Rbrace { (None, $3) }
hunk ./bicicleta_syntax.ml 6
+             | AnonLiteral of methods
hunk ./bicicleta_syntax.ml 8
+             | AnonDerivation of bicexpr * methods
hunk ./bicicleta_syntax.ml 11
+
}
