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/Parser.hs | |
parent | 022489600acf7acf736f64684c64ab8fbc790ce6 (diff) |
Fixed namespace prefix of infix/prefix functions
Diffstat (limited to 'src/Parser.hs')
-rw-r--r-- | src/Parser.hs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index a27c6a2..2e929e1 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -26,12 +26,17 @@ greekLetter :: Parser Char greekLetter = satisfy isGreek where isGreek c = ('Α' <= c && c <= 'Ω') || ('α' <= c && c <= 'ω') -infixOperator :: Parser String -infixOperator = - some specialChar <|> ((++) <$> dottedNamespace <*> infixOperator) +infixOperator :: Parser Identifier +infixOperator = normalInfix <|> namespacedInfix + where + normalInfix = InfixFunction <$> some specialChar + namespacedInfix = NamespacedFunction <$> dottedNamespace <*> infixOperator -prefixOperator :: Parser String -prefixOperator = infixOperator +prefixOperator :: Parser Identifier +prefixOperator = normalPrefix <|> namespacedPrefix + where + normalPrefix = PrefixFunction <$> some specialChar + namespacedPrefix = NamespacedFunction <$> dottedNamespace <*> prefixOperator defIdentifier :: Parser Identifier defIdentifier = @@ -40,8 +45,8 @@ defIdentifier = (alphaNumChar <|> specialChar <|> char '\'') ) ) - <|> (InfixFunction <$> (char '(' *> infixOperator <* char ')')) - <|> (PrefixFunction <$> (prefixOperator <* char '(')) + <|> (char '(' *> infixOperator <* char ')') + <|> (prefixOperator <* char '(') <?> "defining identifier" identifier :: Parser Identifier @@ -127,13 +132,13 @@ parseInfix = do i <- infixOperator sc e2 <- parseSingleton - pure $ Infix e1 (InfixFunction i) e2 + pure $ Infix e1 i e2 parsePrefix :: Parser Expression parsePrefix = do p <- prefixOperator e <- parseSingleton - pure $ Prefix (PrefixFunction p) e + pure $ Prefix p e parseSingleton :: Parser Expression parseSingleton = |