diff options
author | Marvin Borner | 2022-08-16 23:18:44 +0200 |
---|---|---|
committer | Marvin Borner | 2022-08-16 23:18:44 +0200 |
commit | d7e6c86554acc2bf92d3adb40863d1f7351f8918 (patch) | |
tree | 45ef383d68e057785d864a882826a08d8e7508f5 | |
parent | c5f1bbbf5aa9544465fc14f19c5009181ef9fc1c (diff) |
More special chars
-rw-r--r-- | src/Parser.hs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index 82fe98b..ddd74e2 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -17,16 +17,19 @@ type Parser = Parsec Void String sc :: Parser () sc = void $ char ' ' +specialChar :: Parser Char +specialChar = oneOf "!?*@.:;+-_#$%^&<>/|~='" + infixOperator :: Parser String -infixOperator = some $ oneOf "!?*@.:+-#$%^&<>/|~=" +infixOperator = some specialChar prefixOperator :: Parser String -prefixOperator = some $ oneOf "!?*@.:+-#$%^&<>/|~=" +prefixOperator = some specialChar -- def identifier disallows the import prefix dots defIdentifier :: Parser String defIdentifier = - ((:) <$> (letterChar <|> char '_') <*> many (alphaNumChar <|> oneOf "?!'_-*")) + ((:) <$> letterChar <*> many (alphaNumChar <|> specialChar)) <|> ((\l i r -> [l] ++ i ++ [r]) <$> char '(' <*> infixOperator <*> char ')' ) <|> ((\p i -> p ++ [i]) <$> prefixOperator <*> char '(') @@ -35,8 +38,7 @@ defIdentifier = -- TODO: write as extension to defIdentifier identifier :: Parser String identifier = - ((:) <$> (letterChar <|> char '_') <*> many (alphaNumChar <|> oneOf "?!'_-*.") - ) + ((:) <$> letterChar <*> many (alphaNumChar <|> specialChar <|> char '.')) <?> "identifier" namespace :: Parser String |