summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-01-23 22:16:18 +0100
committertomsmeding <tom.smeding@gmail.com>2017-01-23 22:16:18 +0100
commited225559cd9b54fd0cc696088ad1ed13d51aae04 (patch)
treeb61fa7d310c4a1a76d44108cf705abc7b1bbbdb5
parent02f7721474e67e13677e3fd4dee5a78514a1b55f (diff)
Fix type parsing and not supporting capital letters
-rw-r--r--parser.hs14
1 files 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 ()