.SUBDIRS: test src util camlp4
clean:
- rm *~ *.omc
+ rm -f *~ *.omc
.DEFAULT: src/aosh
;; Example for class definition
;;; 12
;;; [object Foo]
+;;; 10
(define-class Foo Object
- ((init x) (let ((t 10))
+ ([init x] (let ((t 10))
(let ((t 12))
(print t))))
- ((f x) (print x)))
+ ([f x] (print x)))
(define foo (new Foo 42))
-(print foo)
\ No newline at end of file
+(print foo)
+(. foo (f 10))
\ No newline at end of file
| LetRec of (string*expr) list * expr
| Block of expr list
| New of name * expr list
- | Invoke of expr * string * expr list (* (invoke <object> <method-name> <arg1> <arg2>...)*)
+ | Invoke of expr * string * expr list (* Invoke (<object>,<method-name>, [<arg1>; <arg2>; ...]) *)
(** A type of statement. Statement has side-effect *)
type stmt =
string = parse_string '"';
number = parse_number;
keyword = parse_keyword ["(";")";"[";"]";"'"];
- ident = parse_ident "!$%&*/:<=>?^_~+-*" "+-.@" <|> (fun s-> Genlex.Ident (Char.escaped @@ one_of "/" s));
+ ident = parse_ident "!$%&*/:<=>?^_~+-*." "+-.@" <|> (fun s-> Genlex.Ident (Char.escaped @@ one_of "/" s));
comment = parse_comment ";";
bool = scheme_bool
}
Ast.Lambda (List.map ensure_symbol args,Ast.Block body')
| Symbol "new"::Symbol name::args ->
Ast.New (split_ns name,List.map make_expr args)
- | Symbol "invoke"::obj::Symbol name::args ->
+ | [Symbol "."; obj; List (Symbol name::args)] ->
Ast.Invoke ((make_expr obj),name,(List.map make_expr args))
| _ ->
Ast.Call (List.map make_expr xs)
#
# Various options
#
-OCAMLCFLAGS += -thread aosh.cma
+OCAMLOPTFLAGS += -thread
+OCAMLCFLAGS += -thread
OCAMLPPFLAGS += -pp "camlp4o ../camlp4/TestCaseCollector.cmo"
OCAMLDEPFLAGS += $(OCAMLPPFLAGS)
OCAML_OTHER_LIBS += threads
-OCamlProgram($(PROGRAM), runner $(FILES))
+OCamlProgram($(PROGRAM), $(FILES) runner)
.DEFAULT: check
test invoke =
assert_equal
(expr [GetLex (make_qname "x");PushByte 10;CallProperty (make_qname "foo",1)])
- (generate_method @@ Lisp.compile_string "(invoke x foo 10)")
+ (generate_method @@ Lisp.compile_string "(. x (foo 10))")
let new_class klass =
assert_equal (Ident "+.") @@ Stream.next (lex "+.");
assert_equal (Ident "foo.bar") @@ Stream.next (lex "foo.bar")
+test dot =
+ assert_equal (Ident ".") @@ Stream.next (lex ".")
+
test bool =
assert_equal (Kwd "true") @@ Stream.next (lex "#t");
assert_equal (Kwd "false") @@ Stream.next (lex "#f")
test invoke =
assert_equal (result (Invoke (Var "foo","baz",[Int 1;Int 2]))) @@
- compile_string "(invoke foo baz 1 2)"
+ compile_string "(. foo (baz 1 2))"
test define =
assert_equal [Define ("x",Block [Int 42])] @@
test symbol =
assert_equal [(String "foo")] "\"foo\"";
- assert_equal [(String "+")] "\"+\""
+ assert_equal [(String "+")] "\"+\"";
+ assert_equal [(Symbol ".")] "."
test add =
assert_equal [List [Symbol "+";Int 1; Int 2]] "(+ 1 2)"