OSDN Git Service

Change class sytnax: if super class is empty, super class is Object
authormzp <mzpppp@gmail.com>
Mon, 17 Aug 2009 12:02:16 +0000 (21:02 +0900)
committermzp <mzpppp@gmail.com>
Mon, 17 Aug 2009 12:02:16 +0000 (21:02 +0900)
scm/src/parser/lisp.ml
scm/test/parser/lispTest.ml

index f434d89..37d48d5 100644 (file)
@@ -191,13 +191,18 @@ let rec p_stmt =
        `Open (Node.lift (Str.split_delim dot) module_name)
     | [< _         = kwd "class";
         name      = symbol;
-        (super,_) = list @@ one_list symbol symbol;
+        supers    = list @@ many symbol;
         attrs     = list @@ many symbol;
         methods   = many @@ list p_method>] ->
-       `Class {Ast.class_name = name;
-               super          = qname super;
-               attrs          = attrs;
-               methods        = methods}
+       let super =
+         match supers with
+             [x] -> x
+           | []  -> Node.ghost "Object"
+           | _   -> Parsec.fail () in
+         `Class {Ast.class_name = name;
+                 super          = qname super;
+                 attrs          = attrs;
+                 methods        = methods}
     | [< _ = kwd "module"; name = symbol; exports = list @@ many symbol; stmts = many stmt>] ->
        if exports = [] then
          (* exports nothing must not be happened. *)
index 64c1d23..d66895c 100644 (file)
@@ -284,6 +284,8 @@ let _ =
        (fun () ->
          ok [class_ "Foo" ([],"Object") ["x";"y"] []]
            "(class Foo (Object) (x y))";
+         ok [class_ "Foo" ([],"Object") ["x";"y"] []]
+           "(class Foo () (x y))";
          ok [class_ "Foo" (["flash";"text"],"Object") ["x";"y"] []]
            "(class Foo (flash.text.Object) (x y))";
          ok [class_ "Foo" (["flash";"text"],"Object") [] []]