dcl voor interface infrastructure, we lezen nu stdin, dat werkt, lexer implementeren...
[cc1516.git] / lex.icl
1 implementation module lex
2
3 import Data.Either
4 import Data.List
5 import StdString
6 import System.CommandLine
7 import StdFile
8 import StdMisc
9
10 // Misschien moeten we hier continuation style van maken
11 instance toString lexerOutput where
12 toString l = "dit is een lexer output, danwel error\n"
13
14 lexer :: [Char] -> LexerOutput
15 lexer _ = Left "Not Implemented"
16
17 Start :: *World -> *World
18 Start w
19 # (args, w) = getCommandLine w // We lezen nu nog standaard van stdin
20 # (out, w) = stdio w
21 # (toparse, out) = readEntireFile out
22 # out = out <<< toString (lexer toparse)
23 # (b, w) = fclose out w
24 | not b = setReturnCode 1 w
25 = w
26 where
27 readEntireFile :: *File -> *([Char], *File)
28 readEntireFile f
29 # (b, c, f) = freadc f
30 | not b = ([], f)
31 # (cs, f) = readEntireFile f
32 = ([c:cs], f)