From 38e42752cf15579d1921c25ea88c8b24de01ed2e Mon Sep 17 00:00:00 2001 From: crumbtoo Date: Wed, 6 Dec 2023 17:15:03 -0700 Subject: [PATCH] cleanup cleanup --- app/Main.hs | 4 ++++ src/Compiler/RLPC.hs | 8 +++++--- src/Core/Lex.x | 3 --- src/Core/Parse.y | 2 ++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/Main.hs b/app/Main.hs index 0842b59..0a4f56e 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -2,6 +2,7 @@ module Main where ---------------------------------------------------------------------------------- import Compiler.RLPC +import Control.Exception import Options.Applicative hiding (ParseError) import Control.Monad import Control.Monad.Reader @@ -69,6 +70,9 @@ debugFlagReader = maybeReader $ \case -- temp data CompilerError = CompilerError String + deriving Show + +instance Exception CompilerError main :: IO () main = do diff --git a/src/Compiler/RLPC.hs b/src/Compiler/RLPC.hs index 4961418..274760f 100644 --- a/src/Compiler/RLPC.hs +++ b/src/Compiler/RLPC.hs @@ -35,10 +35,10 @@ module Compiler.RLPC , flagDDumpAST , def ) - where ---------------------------------------------------------------------------------- import Control.Arrow ((>>>)) +import Control.Exception import Control.Monad.Reader import Control.Monad.State (MonadState(state)) import Control.Monad.Errorful @@ -83,13 +83,15 @@ evalRLPC :: RLPCOptions -> Either e (a, [e]) evalRLPC o m = coerce $ evalRLPCT o m -evalRLPCIO :: RLPCOptions +evalRLPCIO :: (Exception e) + => RLPCOptions -> RLPCIO e a -> IO (a, [e]) evalRLPCIO o m = do m' <- evalRLPCT o m case m' of - Left e -> error "need to impl io errors llol" -- TODO + -- TODO: errors + Left e -> throwIO e Right a -> pure a diff --git a/src/Core/Lex.x b/src/Core/Lex.x index bd98c89..7f90296 100644 --- a/src/Core/Lex.x +++ b/src/Core/Lex.x @@ -98,9 +98,6 @@ rlp :- { "#-}" { constTok TokenRPragma `andBegin` 0 } - "{" { constTok TokenLBrace } - "}" { constTok TokenRBrace } - ";" { constTok TokenSemicolon } $white { skip } \n { skip } diff --git a/src/Core/Parse.y b/src/Core/Parse.y index dbc2412..89a7035 100644 --- a/src/Core/Parse.y +++ b/src/Core/Parse.y @@ -74,6 +74,8 @@ Program : ScDefs { Program $1 } ScDefs :: { [ScDef] } ScDefs : ScDef ';' ScDefs { $1 : $3 } + | ScDef ';' { [$1] } + | ScDef { [$1] } | {- epsilon -} { [] } ScDef :: { ScDef }