aboutsummaryrefslogtreecommitdiff
path: root/lib/Language/Elna/Frontend/Parser.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Language/Elna/Frontend/Parser.hs')
-rw-r--r--lib/Language/Elna/Frontend/Parser.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/Language/Elna/Frontend/Parser.hs b/lib/Language/Elna/Frontend/Parser.hs
index 89853f0..a8e61d2 100644
--- a/lib/Language/Elna/Frontend/Parser.hs
+++ b/lib/Language/Elna/Frontend/Parser.hs
@@ -46,8 +46,8 @@ type Parser = Parsec Void Text
literalP :: Parser Literal
literalP
- = HexadecimalLiteral <$> (string "0x" *> lexeme Lexer.hexadecimal)
- <|> IntegerLiteral <$> Lexer.signed space integerP
+ = HexadecimalLiteral <$> Lexer.signed space hexadecimalP
+ <|> DecimalLiteral <$> Lexer.signed space decimalP
<|> CharacterLiteral <$> lexeme charP
where
charP = fromIntegral . fromEnum
@@ -141,8 +141,11 @@ commaP = void $ symbol ","
semicolonP :: Parser ()
semicolonP = void $ symbol ";"
-integerP :: Integral a => Parser a
-integerP = lexeme Lexer.decimal
+decimalP :: Integral a => Parser a
+decimalP = lexeme Lexer.decimal
+
+hexadecimalP :: Integral a => Parser a
+hexadecimalP = string "0x" *> lexeme Lexer.hexadecimal
identifierP :: Parser Identifier
identifierP =
@@ -166,7 +169,7 @@ typeExpressionP = arrayTypeExpression
<?> "type expression"
where
arrayTypeExpression = ArrayType
- <$> (symbol "array" *> bracketsP integerP)
+ <$> (symbol "array" *> bracketsP literalP)
<*> (symbol "of" *> typeExpressionP)
procedureDeclarationP :: Parser Declaration