Changed the occam and Rain parsers to return a Structured rather than a Process (which will simplify the generated ASTs)
This commit is contained in:
parent
a25824b601
commit
1c858e112c
|
@ -1951,13 +1951,20 @@ mainProcess
|
||||||
--}}}
|
--}}}
|
||||||
--}}}
|
--}}}
|
||||||
--{{{ top-level forms
|
--{{{ top-level forms
|
||||||
-- | A source file consists of a process.
|
|
||||||
-- This is only really true once we've tacked a process onto the bottom; a
|
topLevelItem :: OccParser A.Structured
|
||||||
-- source file is really a series of specifications, but the later ones need to
|
topLevelItem = handleSpecs (allocation <|> specification) topLevelItem
|
||||||
|
(\m s inner -> A.Spec m s inner)
|
||||||
|
<|> (mainProcess >>= (\(A.Main m) -> return $ A.Several m []))
|
||||||
|
|
||||||
|
|
||||||
|
-- | A source file consists of a structured.
|
||||||
|
-- A source file is really a series of specifications, but the later ones need to
|
||||||
-- have the earlier ones in scope, so we can't parse them separately.
|
-- have the earlier ones in scope, so we can't parse them separately.
|
||||||
sourceFile :: OccParser (A.Process, CompState)
|
-- Instead, we nest the specifications
|
||||||
|
sourceFile :: OccParser (A.Structured, CompState)
|
||||||
sourceFile
|
sourceFile
|
||||||
= do p <- process
|
= do p <- topLevelItem
|
||||||
s <- getState
|
s <- getState
|
||||||
return (p, s)
|
return (p, s)
|
||||||
--}}}
|
--}}}
|
||||||
|
@ -1972,7 +1979,7 @@ runTockParser toks prod cs
|
||||||
Right r -> return r
|
Right r -> return r
|
||||||
|
|
||||||
-- | Parse an occam program.
|
-- | Parse an occam program.
|
||||||
parseOccamProgram :: [Token] -> PassM A.Process
|
parseOccamProgram :: [Token] -> PassM A.Structured
|
||||||
parseOccamProgram toks
|
parseOccamProgram toks
|
||||||
= do cs <- get
|
= do cs <- get
|
||||||
(p, cs') <- runTockParser toks sourceFile cs
|
(p, cs') <- runTockParser toks sourceFile cs
|
||||||
|
|
|
@ -416,14 +416,14 @@ topLevelDecl = do decls <- many (processDecl <|> functionDecl <?> "process or fu
|
||||||
eof
|
eof
|
||||||
return $ A.Several emptyMeta decls
|
return $ A.Several emptyMeta decls
|
||||||
|
|
||||||
rainSourceFile :: RainParser (A.Process, CompState)
|
rainSourceFile :: RainParser (A.Structured, CompState)
|
||||||
rainSourceFile
|
rainSourceFile
|
||||||
= do p <- topLevelDecl
|
= do p <- topLevelDecl
|
||||||
s <- getState
|
s <- getState
|
||||||
return (A.Seq emptyMeta p, s)
|
return (p, s)
|
||||||
|
|
||||||
-- | Load and parse a Rain source file.
|
-- | Load and parse a Rain source file.
|
||||||
parseRainProgram :: String -> PassM A.Process
|
parseRainProgram :: String -> PassM A.Structured
|
||||||
parseRainProgram filename
|
parseRainProgram filename
|
||||||
= do source <- liftIO $ readFile filename
|
= do source <- liftIO $ readFile filename
|
||||||
lexOut <- liftIO $ L.runLexer filename source
|
lexOut <- liftIO $ L.runLexer filename source
|
||||||
|
|
Loading…
Reference in New Issue
Block a user