minor changes
putting this on hold; implementing TTG first
This commit is contained in:
@@ -15,3 +15,5 @@
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Release 1.0.0
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ Listed in order of importance.
|
|||||||
- [ ] Actual compiler errors -- no more unexceptional `error` calls
|
- [ ] Actual compiler errors -- no more unexceptional `error` calls
|
||||||
- [ ] Better CLI dump flags
|
- [ ] Better CLI dump flags
|
||||||
- [ ] Annotate the AST with token positions for errors
|
- [ ] Annotate the AST with token positions for errors
|
||||||
|
- [ ] More examples
|
||||||
|
|
||||||
### March Release Plan
|
### March Release Plan
|
||||||
- [ ] Tests
|
- [ ] Tests
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ options = RLPCOptions
|
|||||||
evaluatorReader :: ReadM Evaluator
|
evaluatorReader :: ReadM Evaluator
|
||||||
evaluatorReader = maybeReader $ \case
|
evaluatorReader = maybeReader $ \case
|
||||||
"gm" -> Just EvaluatorGM
|
"gm" -> Just EvaluatorGM
|
||||||
"tim" -> Just EvaluatorTI
|
"ti" -> Just EvaluatorTI
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
mmany :: (Alternative f, Monoid m) => f m -> f m
|
mmany :: (Alternative f, Monoid m) => f m -> f m
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ license: GPL-2.0-only
|
|||||||
-- license-file: LICENSE
|
-- license-file: LICENSE
|
||||||
author: crumbtoo
|
author: crumbtoo
|
||||||
maintainer: crumb@disroot.org
|
maintainer: crumb@disroot.org
|
||||||
-- copyright:
|
copyright: Madeleine Sydney Ślaga
|
||||||
category: Language
|
category: Language
|
||||||
build-type: Simple
|
build-type: Simple
|
||||||
extra-doc-files: README.md
|
extra-doc-files: README.md
|
||||||
|
|||||||
@@ -28,14 +28,12 @@ module Compiler.RLPC
|
|||||||
, evalRLPCIO
|
, evalRLPCIO
|
||||||
, evalRLPC
|
, evalRLPC
|
||||||
, rlpcLogFile
|
, rlpcLogFile
|
||||||
, rlpcDebugOpts
|
, rlpcDFlags
|
||||||
, rlpcEvaluator
|
, rlpcEvaluator
|
||||||
, rlpcInputFiles
|
, rlpcInputFiles
|
||||||
, DebugFlag(..)
|
, DebugFlag(..)
|
||||||
, whenFlag
|
, whenDFlag
|
||||||
, flagDDumpEval
|
, whenFFlag
|
||||||
, flagDDumpOpts
|
|
||||||
, flagDDumpAST
|
|
||||||
, def
|
, def
|
||||||
, liftErrorful
|
, liftErrorful
|
||||||
)
|
)
|
||||||
@@ -43,6 +41,7 @@ module Compiler.RLPC
|
|||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
import Control.Arrow ((>>>))
|
import Control.Arrow ((>>>))
|
||||||
import Control.Exception
|
import Control.Exception
|
||||||
|
import Control.Monad
|
||||||
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
|
||||||
@@ -51,19 +50,19 @@ import Data.Functor.Identity
|
|||||||
import Data.Default.Class
|
import Data.Default.Class
|
||||||
import Data.Foldable
|
import Data.Foldable
|
||||||
import GHC.Generics (Generic)
|
import GHC.Generics (Generic)
|
||||||
|
import Data.Maybe
|
||||||
import Data.Hashable (Hashable)
|
import Data.Hashable (Hashable)
|
||||||
import Data.HashSet (HashSet)
|
import Data.HashSet (HashSet)
|
||||||
import Data.HashSet qualified as S
|
import Data.HashSet qualified as S
|
||||||
import Data.Coerce
|
import Data.Coerce
|
||||||
import Lens.Micro
|
import Lens.Micro.Platform
|
||||||
import Lens.Micro.TH
|
|
||||||
import System.Exit
|
import System.Exit
|
||||||
----------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------
|
||||||
|
|
||||||
newtype RLPCT m a = RLPCT {
|
newtype RLPCT m a = RLPCT {
|
||||||
runRLPCT :: ReaderT RLPCOptions (ErrorfulT (MsgEnvelope RlpcError) m) a
|
runRLPCT :: ReaderT RLPCOptions (ErrorfulT (MsgEnvelope RlpcError) m) a
|
||||||
}
|
}
|
||||||
deriving (Functor, Applicative, Monad)
|
deriving (Functor, Applicative, Monad, MonadReader RLPCOptions)
|
||||||
|
|
||||||
type RLPC = RLPCT Identity
|
type RLPC = RLPCT Identity
|
||||||
|
|
||||||
@@ -98,7 +97,8 @@ liftErrorful e = RLPCT $ lift (fmap liftRlpcError `mapErrorful` e)
|
|||||||
|
|
||||||
data RLPCOptions = RLPCOptions
|
data RLPCOptions = RLPCOptions
|
||||||
{ _rlpcLogFile :: Maybe FilePath
|
{ _rlpcLogFile :: Maybe FilePath
|
||||||
, _rlpcDebugOpts :: DebugOpts
|
, _rlpcDFlags :: HashSet DebugFlag
|
||||||
|
, _rlpcFFlags :: HashSet CompilerFlag
|
||||||
, _rlpcEvaluator :: Evaluator
|
, _rlpcEvaluator :: Evaluator
|
||||||
, _rlpcHeapTrigger :: Int
|
, _rlpcHeapTrigger :: Int
|
||||||
, _rlpcInputFiles :: [FilePath]
|
, _rlpcInputFiles :: [FilePath]
|
||||||
@@ -113,38 +113,33 @@ data Evaluator = EvaluatorGM | EvaluatorTI
|
|||||||
instance Default RLPCOptions where
|
instance Default RLPCOptions where
|
||||||
def = RLPCOptions
|
def = RLPCOptions
|
||||||
{ _rlpcLogFile = Nothing
|
{ _rlpcLogFile = Nothing
|
||||||
, _rlpcDebugOpts = mempty
|
, _rlpcDFlags = mempty
|
||||||
|
, _rlpcFFlags = mempty
|
||||||
, _rlpcEvaluator = EvaluatorGM
|
, _rlpcEvaluator = EvaluatorGM
|
||||||
, _rlpcHeapTrigger = 200
|
, _rlpcHeapTrigger = 200
|
||||||
, _rlpcInputFiles = []
|
, _rlpcInputFiles = []
|
||||||
}
|
}
|
||||||
|
|
||||||
type DebugOpts = HashSet DebugFlag
|
-- debug flags are passed with -dFLAG
|
||||||
|
type DebugFlag = String
|
||||||
|
|
||||||
data DebugFlag = DDumpEval
|
type CompilerFlag = String
|
||||||
| DDumpOpts
|
|
||||||
| DDumpAST
|
|
||||||
deriving (Show, Eq, Generic)
|
|
||||||
|
|
||||||
instance Hashable DebugFlag
|
|
||||||
|
|
||||||
makeLenses ''RLPCOptions
|
makeLenses ''RLPCOptions
|
||||||
pure []
|
pure []
|
||||||
|
|
||||||
whenFlag :: (MonadReader s m) => SimpleGetter s Bool -> m () -> m ()
|
-- TODO: rewrite this with prisms once microlens-pro drops :3
|
||||||
whenFlag l m = asks (^. l) >>= \a -> if a then m else pure ()
|
whenDFlag :: (Monad m) => DebugFlag -> RLPCT m () -> RLPCT m ()
|
||||||
|
whenDFlag f m = do
|
||||||
|
-- mfw no `At` instance for HashSet
|
||||||
|
fs <- view rlpcDFlags
|
||||||
|
let a = S.member f fs
|
||||||
|
when a m
|
||||||
|
|
||||||
-- there's probably a better way to write this. my current knowledge of lenses
|
whenFFlag :: (Monad m) => CompilerFlag -> RLPCT m () -> RLPCT m ()
|
||||||
-- is too weak.
|
whenFFlag f m = do
|
||||||
flagGetter :: DebugFlag -> SimpleGetter RLPCOptions Bool
|
-- mfw no `At` instance for HashSet
|
||||||
flagGetter d = to $ \s -> s ^. rlpcDebugOpts & S.member d
|
fs <- view rlpcFFlags
|
||||||
|
let a = S.member f fs
|
||||||
flagDDumpEval :: SimpleGetter RLPCOptions Bool
|
when a m
|
||||||
flagDDumpEval = flagGetter DDumpEval
|
|
||||||
|
|
||||||
flagDDumpOpts :: SimpleGetter RLPCOptions Bool
|
|
||||||
flagDDumpOpts = flagGetter DDumpOpts
|
|
||||||
|
|
||||||
flagDDumpAST :: SimpleGetter RLPCOptions Bool
|
|
||||||
flagDDumpAST = flagGetter DDumpAST
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user