diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2024-12-07 19:46:34 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2024-12-08 15:19:44 +0100 |
commit | 20b24c190e70cf57819c9b67aae1338d20248784 (patch) | |
tree | 743f432c6889bf7378ead44544436c9de19bf024 /src | |
parent | 5cd3a3d6108a8d48ec3e7729f707248cc0647782 (diff) |
Use void context for user-defined functions
Diffstat (limited to 'src')
-rw-r--r-- | src/Parser.hs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index 1339ec8..e23b277 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -14,6 +14,7 @@ import Data.Set qualified as S import Data.Text qualified as T import Data.Text.Lazy qualified as TL import Data.Text.Lazy.IO qualified as TL +import Data.Void import Text.Megaparsec hiding (State) import Text.Megaparsec.Char @@ -32,10 +33,15 @@ import Test.Builtins parseTestDefinition :: TestParser Toplevel parseTestDefinition = label "test definition" $ toplevel ToplevelTest $ do - block (\name steps -> return $ Test name $ mconcat steps) header testStep - where header = do - wsymbol "test" - lexeme $ TL.toStrict <$> takeWhileP (Just "test name") (/=':') + localState $ do + modify $ \s -> s + { testContext = SomeExpr $ varExpr SourceLineBuiltin rootNetworkVar + } + block (\name steps -> return $ Test name $ mconcat steps) header testStep + where + header = do + wsymbol "test" + lexeme $ TL.toStrict <$> takeWhileP (Just "test name") (/=':') parseDefinition :: TestParser Toplevel parseDefinition = label "symbol definition" $ toplevel ToplevelDefinition $ do @@ -121,7 +127,7 @@ parseTestFile path = do { testVars = concat [ map (fmap someVarValueType) builtins ] - , testContext = SomeExpr $ varExpr SourceLineBuiltin rootNetworkVar + , testContext = SomeExpr (Undefined "void" :: Expr Void) , testNextTypeVar = 0 , testTypeUnif = M.empty } |