cleanup
cleanup
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
module Main where
|
module Main where
|
||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
import Compiler.RLPC
|
import Compiler.RLPC
|
||||||
|
import Control.Exception
|
||||||
import Options.Applicative hiding (ParseError)
|
import Options.Applicative hiding (ParseError)
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
import Control.Monad.Reader
|
import Control.Monad.Reader
|
||||||
@@ -69,6 +70,9 @@ debugFlagReader = maybeReader $ \case
|
|||||||
|
|
||||||
-- temp
|
-- temp
|
||||||
data CompilerError = CompilerError String
|
data CompilerError = CompilerError String
|
||||||
|
deriving Show
|
||||||
|
|
||||||
|
instance Exception CompilerError
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ module Compiler.RLPC
|
|||||||
, flagDDumpAST
|
, flagDDumpAST
|
||||||
, def
|
, def
|
||||||
)
|
)
|
||||||
|
|
||||||
where
|
where
|
||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
import Control.Arrow ((>>>))
|
import Control.Arrow ((>>>))
|
||||||
|
import Control.Exception
|
||||||
import Control.Monad.Reader
|
import Control.Monad.Reader
|
||||||
import Control.Monad.State (MonadState(state))
|
import Control.Monad.State (MonadState(state))
|
||||||
import Control.Monad.Errorful
|
import Control.Monad.Errorful
|
||||||
@@ -83,13 +83,15 @@ evalRLPC :: RLPCOptions
|
|||||||
-> Either e (a, [e])
|
-> Either e (a, [e])
|
||||||
evalRLPC o m = coerce $ evalRLPCT o m
|
evalRLPC o m = coerce $ evalRLPCT o m
|
||||||
|
|
||||||
evalRLPCIO :: RLPCOptions
|
evalRLPCIO :: (Exception e)
|
||||||
|
=> RLPCOptions
|
||||||
-> RLPCIO e a
|
-> RLPCIO e a
|
||||||
-> IO (a, [e])
|
-> IO (a, [e])
|
||||||
evalRLPCIO o m = do
|
evalRLPCIO o m = do
|
||||||
m' <- evalRLPCT o m
|
m' <- evalRLPCT o m
|
||||||
case m' of
|
case m' of
|
||||||
Left e -> error "need to impl io errors llol" -- TODO
|
-- TODO: errors
|
||||||
|
Left e -> throwIO e
|
||||||
Right a -> pure a
|
Right a -> pure a
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -98,9 +98,6 @@ rlp :-
|
|||||||
<pragma>
|
<pragma>
|
||||||
{
|
{
|
||||||
"#-}" { constTok TokenRPragma `andBegin` 0 }
|
"#-}" { constTok TokenRPragma `andBegin` 0 }
|
||||||
"{" { constTok TokenLBrace }
|
|
||||||
"}" { constTok TokenRBrace }
|
|
||||||
";" { constTok TokenSemicolon }
|
|
||||||
|
|
||||||
$white { skip }
|
$white { skip }
|
||||||
\n { skip }
|
\n { skip }
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ Program : ScDefs { Program $1 }
|
|||||||
|
|
||||||
ScDefs :: { [ScDef] }
|
ScDefs :: { [ScDef] }
|
||||||
ScDefs : ScDef ';' ScDefs { $1 : $3 }
|
ScDefs : ScDef ';' ScDefs { $1 : $3 }
|
||||||
|
| ScDef ';' { [$1] }
|
||||||
|
| ScDef { [$1] }
|
||||||
| {- epsilon -} { [] }
|
| {- epsilon -} { [] }
|
||||||
|
|
||||||
ScDef :: { ScDef }
|
ScDef :: { ScDef }
|
||||||
|
|||||||
Reference in New Issue
Block a user