git @ Cat's Eye Technologies ZOWIE / a43cc8e
Fix parser. Chris Pressey 5 months ago
2 changed file(s) with 8 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
3939
4040 operand = do
4141 spaces
42 r <- indirect <|> direct <|> immediate
42 r <- (try indirect) <|> (try direct) <|> immediate
4343 return r
4444
4545 indirect = do
5555
5656 immediate = do
5757 n <- number
58 return $ Direct n
58 return $ Immediate n
5959
6060 number = do
6161 c <- digit
1010 main = do
1111 args <- getArgs
1212 case args of
13 ["parse", fileName] -> do
14 text <- readFile fileName
15 let prog = Parser.parseZOWIE text
16 putStrLn $ show $ prog
17 return ()
1318 ["run", fileName] -> do
1419 text <- readFile fileName
1520 let prog = Parser.parseZOWIE text
1722 putStrLn $ show $ result
1823 return ()
1924 _ -> do
20 abortWith "Usage: zowie run <carriage-program-text-filename>"
25 abortWith "Usage: zowie (parse|run) <zowie-program-filename>"
2126
2227 abortWith msg = do
2328 hPutStrLn stderr msg