diff options
author | Marvin Borner | 2022-08-22 11:23:04 +0200 |
---|---|---|
committer | Marvin Borner | 2022-08-22 11:23:04 +0200 |
commit | a26c8e542dba44e348ac723ed3f6252c6a7496b4 (patch) | |
tree | 7c5ac7e22bbcb6526c7b46d378ee43be6f535b9a /src/Helper.hs | |
parent | 022489600acf7acf736f64684c64ab8fbc790ce6 (diff) |
Fixed namespace prefix of infix/prefix functions
Diffstat (limited to 'src/Helper.hs')
-rw-r--r-- | src/Helper.hs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/Helper.hs b/src/Helper.hs index 23f6361..2ec40a3 100644 --- a/src/Helper.hs +++ b/src/Helper.hs @@ -35,13 +35,13 @@ printContext (Context inp path) = p $ lines inp errPrefix :: String errPrefix = "\ESC[41mERROR\ESC[0m " -data Error = SyntaxError String | UndeclaredIdentifier String | InvalidIndex Int | FailedTest Expression Expression Expression Expression | ContextualError Error Context | ImportError String +data Error = SyntaxError String | UndeclaredIdentifier Identifier | InvalidIndex Int | FailedTest Expression Expression Expression Expression | ContextualError Error Context | ImportError String instance Show Error where show (ContextualError err ctx) = show err <> "\n" <> (printContext ctx) show (SyntaxError err) = errPrefix <> "invalid syntax\n\ESC[45mnear\ESC[0m " <> err show (UndeclaredIdentifier ident) = - errPrefix <> "undeclared identifier " <> ident + errPrefix <> "undeclared identifier " <> show ident show (InvalidIndex err) = errPrefix <> "invalid index " <> show err show (FailedTest exp1 exp2 red1 red2) = errPrefix @@ -126,12 +126,12 @@ data EvalConf = EvalConf , nicePath :: String , evalPaths :: [String] } --- data Environment = Environment [(EnvDef, Environment)] -data Environment = Environment (M.Map String (Expression, Environment)) +data Environment = Environment (M.Map Identifier (Expression, Environment)) + deriving Show data EnvCache = EnvCache { _imported :: M.Map String Environment } -type Program = S.State Environment +type EvalState = S.State Environment --- @@ -192,7 +192,9 @@ decodeStdout e = do -- TODO: Performanize matchingFunctions :: Expression -> Environment -> String matchingFunctions e (Environment env) = - intercalate ", " $ map fst $ M.toList $ M.filter (\(e', _) -> e == e') env + intercalate ", " $ map (functionName . fst) $ M.toList $ M.filter + (\(e', _) -> e == e') + env -- TODO: Expression -> Maybe Char is missing maybeHumanifyExpression :: Expression -> Maybe String |