dcl voor interface infrastructure, we lezen nu stdin, dat werkt, lexer implementeren...
[cc1516.git] / lex.icl
diff --git a/lex.icl b/lex.icl
index f050062..cc4bc2f 100644 (file)
--- a/lex.icl
+++ b/lex.icl
@@ -1,3 +1,32 @@
-module lex
+implementation module lex
 
-Start = "Hello World!\n"
+import Data.Either
+import Data.List
+import StdString
+import System.CommandLine
+import StdFile
+import StdMisc
+
+// Misschien moeten we hier continuation style van maken
+instance toString lexerOutput where
+       toString l = "dit is een lexer output, danwel error\n"
+
+lexer :: [Char] -> LexerOutput
+lexer _ = Left "Not Implemented"
+
+Start :: *World -> *World
+Start w
+# (args, w) = getCommandLine w // We lezen nu nog standaard van stdin
+# (out, w) = stdio w
+# (toparse, out) = readEntireFile out
+# out = out <<< toString (lexer toparse)
+# (b, w) = fclose out w
+| not b = setReturnCode 1 w
+= w
+       where
+               readEntireFile :: *File -> *([Char], *File)
+               readEntireFile f
+               # (b, c, f) = freadc f
+               | not b = ([], f)
+               # (cs, f) = readEntireFile f
+               = ([c:cs], f)