Commit e0ff4214 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel
Browse files

Inline helper functions in Coalgebra.Parser

parent acaeffbc
...@@ -56,6 +56,7 @@ class ParseMorphism f where ...@@ -56,6 +56,7 @@ class ParseMorphism f where
newState :: MorphParser l h1 State newState :: MorphParser l h1 State
newState = nextState <<%= succ newState = nextState <<%= succ
{-# INLINE newState #-}
defineSymbol :: Text -> MorphParser l h1 State defineSymbol :: Text -> MorphParser l h1 State
defineSymbol sym = use (symbolTable . at sym) >>= \case defineSymbol sym = use (symbolTable . at sym) >>= \case
...@@ -67,6 +68,7 @@ defineSymbol sym = use (symbolTable . at sym) >>= \case ...@@ -67,6 +68,7 @@ defineSymbol sym = use (symbolTable . at sym) >>= \case
define :: State -> MorphParser l h1 State define :: State -> MorphParser l h1 State
define node = (symbolTable . at sym .= Just (node, Defined)) define node = (symbolTable . at sym .= Just (node, Defined))
*> return node *> return node
{-# INLINE defineSymbol #-}
lookupSymbol :: Text -> MorphParser l h1 State lookupSymbol :: Text -> MorphParser l h1 State
lookupSymbol sym = use (symbolTable . at sym) >>= \case lookupSymbol sym = use (symbolTable . at sym) >>= \case
...@@ -76,6 +78,7 @@ lookupSymbol sym = use (symbolTable . at sym) >>= \case ...@@ -76,6 +78,7 @@ lookupSymbol sym = use (symbolTable . at sym) >>= \case
where where
markUndefined :: State -> MorphParser l h1 () markUndefined :: State -> MorphParser l h1 ()
markUndefined node = symbolTable . at sym .= Just (node, Undefined) markUndefined node = symbolTable . at sym .= Just (node, Undefined)
{-# INLINE lookupSymbol #-}
checkUndefinedRefs :: MorphParser l h1 () checkUndefinedRefs :: MorphParser l h1 ()
checkUndefinedRefs = use (symbolTable . to M.toList . to (filter isUndefined)) >>= \case checkUndefinedRefs = use (symbolTable . to M.toList . to (filter isUndefined)) >>= \case
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment