diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-10-30 14:12:51 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-10-30 14:12:51 +0100 |
| commit | 43882a3a0697945b35194c2b5940605e9f4dd846 (patch) | |
| tree | 494bde0fec422937f26b7b1a954adbcd477f7a9b /lib/Language/Elna/Frontend/Parser.hs | |
| parent | 6b92e5059c04709b3506bb4e7bef29872b16811f (diff) | |
| download | elna-43882a3a0697945b35194c2b5940605e9f4dd846.tar.gz | |
Generate a call to _divide_by_zero_error on RiscV
Diffstat (limited to 'lib/Language/Elna/Frontend/Parser.hs')
| -rw-r--r-- | lib/Language/Elna/Frontend/Parser.hs | 13 |
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 |
