From ed225559cd9b54fd0cc696088ad1ed13d51aae04 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 23 Jan 2017 22:16:18 +0100 Subject: Fix type parsing and not supporting capital letters --- parser.hs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/parser.hs b/parser.hs index 6520294..f488762 100644 --- a/parser.hs +++ b/parser.hs @@ -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 () -- cgit v1.2.3-54-g00ecf