From 43882a3a0697945b35194c2b5940605e9f4dd846 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 30 Oct 2024 14:12:51 +0100 Subject: Generate a call to _divide_by_zero_error on RiscV --- lib/Language/Elna/Frontend/Parser.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/Language/Elna/Frontend/Parser.hs') 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 -- cgit v1.2.3