diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-10-04 18:26:10 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-10-04 18:26:10 +0200 |
| commit | 35742aa52587400950cf25170c2247f98f498d4d (patch) | |
| tree | 78d0fd208e2e08d30c18ada33c52bc76a91267d6 /lib/Language/Elna/Frontend/Parser.hs | |
| parent | fdf56ce9d0de459dc5bd65537847ded7b02ad5c2 (diff) | |
| download | elna-35742aa52587400950cf25170c2247f98f498d4d.tar.gz | |
Add printc and exit builtin functions
Diffstat (limited to 'lib/Language/Elna/Frontend/Parser.hs')
| -rw-r--r-- | lib/Language/Elna/Frontend/Parser.hs | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/Language/Elna/Frontend/Parser.hs b/lib/Language/Elna/Frontend/Parser.hs index 4093f25..75f359e 100644 --- a/lib/Language/Elna/Frontend/Parser.hs +++ b/lib/Language/Elna/Frontend/Parser.hs @@ -34,27 +34,24 @@ import Text.Megaparsec import qualified Text.Megaparsec.Char.Lexer as Lexer import Text.Megaparsec.Char ( alphaNumChar --- , char + , char , letterChar , space1 --- , string + , string ) import Control.Applicative (Alternative(..)) import Data.Maybe (isJust) --- import Data.Functor (($>)) type Parser = Parsec Void Text literalP :: Parser Literal literalP - = {- HexadecimalLiteral <$> (string "0x" *> lexeme Lexer.hexadecimal) - <|> -} IntegerLiteral <$> Lexer.signed space integerP - {- <|> CharacterLiteral <$> lexeme charP - <|> BooleanLiteral <$> (symbol "true" $> True) - <|> BooleanLiteral <$> (symbol "false" $> False) + = HexadecimalLiteral <$> (string "0x" *> lexeme Lexer.hexadecimal) + <|> IntegerLiteral <$> Lexer.signed space integerP + <|> CharacterLiteral <$> lexeme charP where charP = fromIntegral . fromEnum - <$> between (char '\'') (char '\'') Lexer.charLiteral -} + <$> between (char '\'') (char '\'') Lexer.charLiteral {- typeDefinitionP :: Parser Declaration typeDefinitionP = TypeDefinition @@ -73,7 +70,7 @@ termP = choice operatorTable :: [[Operator Parser Expression]] operatorTable = [ unaryOperator - -- , factorOperator + , factorOperator , termOperator ] where @@ -81,10 +78,10 @@ operatorTable = [ prefix "-" NegationExpression , prefix "+" id ] - {- factorOperator = + factorOperator = [ binary "*" ProductExpression - , binary "/" DivisionExpression - ] -} + -- , binary "/" DivisionExpression + ] termOperator = [ binary "+" SumExpression , binary "-" SubtractionExpression |
