]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
Started implementation of typed lisp intermediate language
authorMike D. Lowis <mike@mdlowis.com>
Thu, 17 Jan 2013 17:20:26 +0000 (12:20 -0500)
committerMike D. Lowis <mike@mdlowis.com>
Thu, 17 Jan 2013 17:20:26 +0000 (12:20 -0500)
src/sclpl/Makefile
src/sclpl/src/main.scm
src/sclpl/src/sclpl.scm [deleted file]

index 311b872455860fc5f5071c52374d8bc1d0581636..a8fe4a08b1b477f822748fc95af7efde34661d8b 100644 (file)
@@ -16,7 +16,7 @@ flist = $(shell env find $(1) -name "*.$(strip $(2))" -print)
 # Project and Artifact Names
 #---------------------------
 BIN_NAME    = sclpl
-TEST_RUNNER = sclpl-test
+TEST_RUNNER = $(BIN_NAME)-test
 
 # File and Directory Settings
 #----------------------------
@@ -45,7 +45,7 @@ TEST_INCS = -I inc
 # Compiler and Linker Options
 #----------------------------
 CSC = csc
-CSCFLAGS = -c -explicit-use
+CSCFLAGS = -c -explicit-use -compile-syntax
 
 # Build Rules
 #------------
index 8c872604e066d1ccc89a3ca2e2f05a607da8e77f..205cf1959e967588989228f365f80c3cc3ae65cf 100644 (file)
@@ -1,4 +1,42 @@
-(declare (uses sclpl))
+(declare (uses library))
 
-(interpret (current-input-port))
+(define primitive-types '(Num Char String))
+
+(define (literal e)
+  (if (not (or (number? e) (char? e) (string? e) (symbol? e)))
+      (syn-error e "Not a recognized literal type")))
+
+(define (prim-type e)
+  (if (or (not (symbol? e))
+          (not (member e primitive-types)))
+    (syn-error e "Not a recognized primitive type")))
+
+(define (typed-sym sym)
+  (if (not (pair? sym))
+      (syn-error sym "Expected a type/symbol pair"))
+  (if (not (symbol? (car sym)))
+      (syn-error sym "Expected a symbol name"))
+  (prim-type (cdr sym)))
+
+(define (list-of-types lst)
+  (if (null? lst) lst
+      (begin (typed-sym (car lst))
+             (list-of-types (cdr lst)))))
+
+(define (definition e)
+  (if (or (not (list? e))
+          (< (length e) 3))
+    (syn-error e "Definitions require a type and a body or value"))
+  (if (list? (cadr e)) (list-of-types (cadr e)) (typed-sym (cadr e))))
+
+
+
+(define (syn-error expr msg)
+  (print (string-append "Error: " msg))
+  (display "\n")
+  (pretty-print expr)
+  (exit 1))
+
+; Main
+;------------------------------------------------------------------------------
 
diff --git a/src/sclpl/src/sclpl.scm b/src/sclpl/src/sclpl.scm
deleted file mode 100644 (file)
index 0efa496..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-(declare (unit sclpl) (uses library))
-
-(define (interpret port)
-  (define expression (read port))
-  (print (eval expression))
-  (if (not (null? expression))
-      (interpret port)))
-