diff options
-rw-r--r-- | src/lang.clj | 14 | ||||
-rw-r--r-- | src/lang/analyser.clj | 8 | ||||
-rw-r--r-- | src/lang/compiler.clj | 10 | ||||
-rw-r--r-- | src/lang/lexer.clj | 8 | ||||
-rw-r--r-- | test2.lang | 10 |
5 files changed, 19 insertions, 31 deletions
diff --git a/src/lang.clj b/src/lang.clj index 83862bb2f..d8b65afe6 100644 --- a/src/lang.clj +++ b/src/lang.clj @@ -51,20 +51,20 @@ (write-file "test2.class" class-data)) ;; TODO: Define functions as classes inheriting Function. + ;; TODO: Allow importing Java classes. + ;; TODO: Allow using other modules. ;; TODO: Add tuples. + ;; TODO: Add thunks. ;; TODO: Add pattern-matching. + ;; TODO: Add Java-interop. ;; TODO: Do tail-call optimization. ;; TODO: Add macros. + ;; TODO: Add signatures & structures OR type-classes. ;; TODO: Add type-level computations. ;; TODO: Add interpreter. - ;; TODO: Add Java-interop. - ;; TODO: Add signatures & structures OR type-classes. - ;; TODO: Allow importing Java classes. - ;; TODO: Allow using other modules. - ;; TODO: Add thunks. ;; TODO: Re-implement compiler in language. - ;; TODO: - ;; TODO: + ;; TODO: Add all the missing literal types. + ;; TODO: Allow strings to have escape characters. ;; TODO: ;; jar cvf test2.jar test2 test2.class diff --git a/src/lang/analyser.clj b/src/lang/analyser.clj index 811cc93ea..c40fccffb 100644 --- a/src/lang/analyser.clj +++ b/src/lang/analyser.clj @@ -173,11 +173,6 @@ (return (annotated [::def [?name args] =value] ::&type/nothing)))) )) -(defanalyser analyse-module - [::&parser/module] - (exec [name module-name] - (return (annotated [::module name] ::&type/nothing)))) - (def ^:private analyse-form (try-all-m [analyse-boolean analyse-string @@ -191,8 +186,7 @@ analyse-let analyse-defclass analyse-definterface - analyse-def - analyse-module])) + analyse-def])) ;; [Interface] (defn analyse [module-name tokens] diff --git a/src/lang/compiler.clj b/src/lang/compiler.clj index 8b73720c4..a8d38842a 100644 --- a/src/lang/compiler.clj +++ b/src/lang/compiler.clj @@ -168,11 +168,6 @@ (.visitEnd)))) )) -(defcompiler ^:private compile-module - [::&analyser/module ?name] - (.visit *writer* Opcodes/V1_5 (+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER) - (->class ?name) nil "java/lang/Object" nil)) - (defcompiler ^:private compile-defclass [::&analyser/defclass [?package ?name] ?members] (let [parent-dir (->package ?package) @@ -236,7 +231,6 @@ compile-if compile-let compile-def - compile-module compile-defclass compile-definterface compile-variant]] @@ -248,7 +242,9 @@ ;; [Interface] (defn compile [class-name inputs] (prn 'inputs inputs) - (let [=class (new ClassWriter ClassWriter/COMPUTE_MAXS) + (let [=class (doto (new ClassWriter ClassWriter/COMPUTE_MAXS) + (.visit Opcodes/V1_5 (+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER) + (->class class-name) nil "java/lang/Object" nil)) ;; (doto (new ClassWriter ClassWriter/COMPUTE_MAXS) ;; (.visit Opcodes/V1_5 (+ Opcodes/ACC_PUBLIC Opcodes/ACC_SUPER) ;; "output" nil "java/lang/Object" nil)) diff --git a/src/lang/lexer.clj b/src/lang/lexer.clj index caaa15604..c88f54d57 100644 --- a/src/lang/lexer.clj +++ b/src/lang/lexer.clj @@ -53,19 +53,19 @@ (exec [_ (lex-str "#(") ;; :let [_ (prn 'OPEN)] ;; comment (lex-regex #"^(#\(.*\)#)") - comment (try-all-m [(lex-regex #"^((?!#\().)*?(?=\)#)") - (exec [pre (lex-regex #"^(.+?(?=#\())") + comment (try-all-m [(lex-regex #"(?is)^((?!#\().)*?(?=\)#)") + (exec [pre (lex-regex #"(?is)^(.+?(?=#\())") ;; :let [_ (prn 'PRE pre)] [_ inner] lex-multi-line-comment ;; :let [_ (prn 'INNER inner)] - post (lex-regex #"^(.+?(?=\)#))") + post (lex-regex #"(?is)^(.+?(?=\)#))") ;:let [_ (prn 'POST post)] ] (return (str pre "#(" inner ")#" post)))]) ;; :let [_ (prn 'COMMENT comment)] _ (lex-str ")#") ;; :let [_ (prn 'CLOSE)] - ;; :let [_ (prn 'multi-comment comment)] + :let [_ (prn 'multi-comment comment)] ] (return [::comment comment]))) diff --git a/test2.lang b/test2.lang index 885f4a91d..62585484a 100644 --- a/test2.lang +++ b/test2.lang @@ -1,5 +1,3 @@ -(module) - (ann-class java.lang.String) (ann-class java.io.PrintStream @@ -23,10 +21,10 @@ (def (id x) x) -## #( (def (id x) -## (let return "RETURN" -## return)) -## )# +#( (def (id x) + (let return "RETURN" + return)) + )# (def (main args) (if true |