diff options
-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 () |