[tolerating newlines (2007-03-01)
kragen@pobox.com**20070412104514] {
hunk ./bicicleta.ml 227
-    assert((parse "x\n") = Name "x");        
+    assert((parse "x\n") = Name "x");
+    (* separate methods with newlines: *)
+    assert((parse "{x:y=x\nz=x}") = Literal("x",        
+        Definition("y", Name "x",
+        Definition("z", Name "x", NoDefs))));
+    (* allow newlines around period *)
+    assert((parse "x\n.\ny \n . \n z") = Call(Call(Name "x", "y"), "z"));
+    (* allow newlines in parens *)
+    assert((parse "(\nx\n)") = Name "x");
+    (* allow leading newlines *)
+    assert((parse "\nx") = Name "x");
+    (* allow newlines between prototype and overrides *)
+    assert((parse "x{y: z = w}") = (parse "x\n{y: z = w}"));
+    (* allow newlines around self-name *)
+    assert((parse "x {y: z = w}") = (parse "x {\ny\n:z=w}"));
+    (* allow newlines around equals sign *)
+    assert((parse "x{y:z=w}") = (parse "x{y:z\n=\nw}"));
+    assert((parse "x{y:z=w,v=u}") = (parse "x{y:z\n=\nw\nv\n=\nu}"));
hunk ./bicicleta_parser.mly 14
- * - separating definitions with newlines rather than commas
hunk ./bicicleta_parser.mly 19
+o: /* optional newlines */
+    newlines { () } | /* empty */ { () }
hunk ./bicicleta_parser.mly 22
-    expr Eof { $1 }
-  | expr newlines Eof { $1 }
+    o expr Eof { $2 }
+  | o expr newlines Eof { $2 }
+newlines:
+    Newline { () } | newlines Newline { () }
hunk ./bicicleta_parser.mly 27
-    expr Period NameTok   { Call($1, $3) }
+    expr period NameTok   { Call($1, $3) }
hunk ./bicicleta_parser.mly 30
-  | Lbrace NameTok Colon methods Rbrace { Literal($2, $4) }
-  | expr Lbrace NameTok Colon methods Rbrace { Derivation($1, $3, $5) }
-  | Lparen expr Rparen    { $2 }
+  | literal               { Literal(fst $1, snd $1) }
+  | expr o literal        { Derivation($1, fst $3, snd $3) }
+  | Lparen o expr o Rparen    { $3 }
hunk ./bicicleta_parser.mly 34
-methods:
-    NameTok Equals expr   { Definition($1, $3, NoDefs) }
+period:
+    o Period o { () }
+literal:
+    Lbrace o NameTok o Colon o definitions Rbrace { ($3, $7) }
+definitions:
+    NameTok o Equals o expr   { Definition($1, $5, NoDefs) }
+  | NameTok o Equals o expr def_separator definitions { Definition($1, $5, $7) }
hunk ./bicicleta_parser.mly 42
-  | NameTok Equals expr method_separator methods { Definition($1, $3, $5) }
-newlines:
-    Newline { () } | newlines Newline { () }
-method_separator:
-    Comma { () } | Comma newlines { () }
+def_separator:
+    Comma { () } | Comma newlines { () } | newlines { () }
}
