diff options
author | tomsmeding <tom.smeding@gmail.com> | 2017-01-23 22:16:18 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2017-01-23 22:16:18 +0100 |
commit | ed225559cd9b54fd0cc696088ad1ed13d51aae04 (patch) | |
tree | b61fa7d310c4a1a76d44108cf705abc7b1bbbdb5 | |
parent | 02f7721474e67e13677e3fd4dee5a78514a1b55f (diff) |
Fix type parsing and not supporting capital letters
-rw-r--r-- | parser.hs | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -176,7 +176,12 @@ pType :: Parser Type pType = pPrimType <|> pPtrType <|> pTypeName pPrimType :: Parser Type -pPrimType = findPrimType <$> choice (map symbol' $ Map.keys primitiveTypes) +pPrimType = findPrimType <$> choice (map typeParser $ Map.keys primitiveTypes) + where typeParser t = try $ do + void $ string t + void $ lookAhead $ satisfy (\c -> not (isAlphaNum c) && c /= '_') + pWhiteComment + return t pPtrType :: Parser Type pPtrType = do @@ -192,8 +197,8 @@ pTypeName = TypeName <$> pName pName :: Parser Name pName = ((:) <$> pFirstChar <*> many pOtherChar) << pWhiteComment - where pFirstChar = satisfy (isLower .||. (=='_')) - pOtherChar = satisfy (isLower .||. isDigit .||. (=='_')) + where pFirstChar = satisfy (isAlpha .||. (=='_')) + pOtherChar = satisfy (isAlpha .||. isDigit .||. (=='_')) pInteger :: Parser Integer pInteger = (read <$> many1 (satisfy isDigit)) << pWhiteComment @@ -228,9 +233,6 @@ pString = do symbol :: String -> Parser () symbol s = try (string s) >> pWhiteComment -symbol' :: String -> Parser String -symbol' s = try (string s) << pWhiteComment - pWhiteComment :: Parser () pWhiteComment = sepBy pWhitespace pComment >> return () |