-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParseProg.hs
More file actions
32 lines (26 loc) · 715 Bytes
/
ParseProg.hs
File metadata and controls
32 lines (26 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module ParseProg where
import LexAssignment
import ParAssignment
import AbsAssignment
import LayoutAssignment
import qualified AST as A
import ASTConverter
import ErrM
myLLexer = resolveLayout True . myLexer
progToAST :: String -> A.Prog String String
progToAST fileConts = do
case pTree of
Bad emsg ->
error $ "Error in parsing \n" ++ emsg
Ok fpTree ->
transProg fpTree
where
tokens = myLLexer fileConts
pTree = pProg tokens
parseFile :: String -> IO (A.Prog String String)
parseFile fname = do
fconts <- readFile fname
let ast = progToAST fconts
putStrLn $ show ast
return $ ast
showProg ast = A.show_prog ast