]> git.mdlowis.com Git - archive/dlang-scm.git/commitdiff
Added code to main for parsing input from a file
authorMike D. Lowis <mike@mdlowis.com>
Fri, 20 Jul 2012 17:10:10 +0000 (13:10 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Fri, 20 Jul 2012 17:10:10 +0000 (13:10 -0400)
example.dl
source/main.scm

index e082830a7ab928d7d550c8d70f6f483f7f3b175d..5d5766d7ab91a0d91166b92049654c82f1d187b9 100644 (file)
@@ -1,4 +1,4 @@
-# Literals
+## Literals
 "foo"
 'a'
 1.0
@@ -19,12 +19,14 @@ foo(1, 2, 3)
 
 # Definition and assignment
 def foo 5 ;
-set foo 6 ;
+set! foo 6 ;
 def foo 5 end
-set foo 6 end
+set! foo 6 end
 
-# Special function definition shorthand
-def max(a, b) if (a > b) a else b ;;
+# Special function definition shorthand (not yet supported)
+#def max(a, b)
+#   if (a > b) a b;
+#end
 
 # If statement
 if conditional
@@ -54,20 +56,17 @@ func (a) foo(a) ;
 func (a, b) foo(a, b) ;
 func (a, b, c) foo(a, b, c) ;
 
-# Macro expressions
-macro () ;
-macro (a) ;
-macro (a, b) ;
-macro (a, b, c) ;
-macro () foo(a) ;
-macro (a) foo(a) ;
-macro (a, b) foo(a, b) ;
-macro (a, b, c) foo(a, b, c) ;
-
-# Quoting Expressions
-#quote( (1 + 1) )
+## Macro expressions (not yet supported)
+#macro () ;
+#macro (a) ;
+#macro (a, b) ;
+#macro (a, b, c) ;
+#macro () foo(a) ;
+#macro (a) foo(a) ;
+#macro (a, b) foo(a, b) ;
+#macro (a, b, c) foo(a, b, c) ;
 
-# Syntactic Extensions
+# Syntactic Extensions (not yet supported)
 #syntax let ( := = ) ;
 #    ( a := b )
 #        define a b ;
@@ -75,6 +74,6 @@ macro (a, b, c) foo(a, b, c) ;
 #    ( a = b )
 #        set! a b ;
 #end
-
+#
 #let foo := "bar" ;
 #let foo = 5 ;
index 3b208180320b9bb20735379793282aa70268b10f..cfe643beeda6b50f49443c361d1f4585658169d0 100644 (file)
@@ -1,5 +1,14 @@
-(include "loop.scm")
-(declare (uses buf)
-         (uses lexer)
+(declare
+
          (uses parser))
 
+(define (parse-file fname)
+  (define result
+    (dlang/program (dlang/lexer (open-input-file fname))))
+  (print result))
+
+; If we have a file, then parse it
+(if (= 1 (length (command-line-arguments)))
+  (parse-file (car (command-line-arguments)))
+  (print "No input file provided."))
+