Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ast.Parser.Utils
Synopsis
- type Parser = ParsecT ParseErrorCustom String (StateT ParserState IO)
- data ParseErrorCustom
- sc :: Parser ()
- lexeme :: Parser a -> Parser a
- symbol :: String -> Parser String
- triedChoice :: [Parser a] -> Parser a
- identifier :: Parser String
- parseSrcLoc :: Parser SrcLoc
- prefix :: String -> (SrcLoc -> Expr -> Expr) -> Operator Parser Expr
- postfix :: String -> (SrcLoc -> Expr -> Expr) -> Operator Parser Expr
- binary :: String -> (SrcLoc -> Expr -> Expr -> Expr) -> Operator Parser Expr
- parseBool :: Parser Bool
- parseStringChar :: Parser Char
- parseEscapeSequence :: Parser Char
- parseHexEscape :: Parser Char
- parseOctalEscape :: Parser Char
- hexDigit :: Parser Char
- octalDigit :: Parser Char
- normalizeLoc :: SrcLoc
- normalizeExpr :: Expr -> Expr
Documentation
type Parser = ParsecT ParseErrorCustom String (StateT ParserState IO) Source #
A type alias for the parser, based on Parsec
with Void
error type and String
input.
data ParseErrorCustom Source #
Custom error types for the parser.
Constructors
UnknownType String | |
InvalidFunctionType String Type | |
InvalidDefer Expr |
Instances
Show ParseErrorCustom Source # | |
Defined in Ast.Parser.Utils Methods showsPrec :: Int -> ParseErrorCustom -> ShowS # show :: ParseErrorCustom -> String # showList :: [ParseErrorCustom] -> ShowS # | |
Eq ParseErrorCustom Source # | |
Defined in Ast.Parser.Utils Methods (==) :: ParseErrorCustom -> ParseErrorCustom -> Bool # (/=) :: ParseErrorCustom -> ParseErrorCustom -> Bool # | |
Ord ParseErrorCustom Source # | |
Defined in Ast.Parser.Utils Methods compare :: ParseErrorCustom -> ParseErrorCustom -> Ordering # (<) :: ParseErrorCustom -> ParseErrorCustom -> Bool # (<=) :: ParseErrorCustom -> ParseErrorCustom -> Bool # (>) :: ParseErrorCustom -> ParseErrorCustom -> Bool # (>=) :: ParseErrorCustom -> ParseErrorCustom -> Bool # max :: ParseErrorCustom -> ParseErrorCustom -> ParseErrorCustom # min :: ParseErrorCustom -> ParseErrorCustom -> ParseErrorCustom # | |
ShowErrorComponent ParseErrorCustom Source # | |
Defined in Ast.Parser.Utils Methods |
Skips whitespace and comments (starting with %
). Ensures proper handling of spacing in parsers.
lexeme :: Parser a -> Parser a Source #
Wraps a parser to consume trailing whitespace, returning the result of the inner parser.
symbol :: String -> Parser String Source #
Parses a specific symbol (e.g., "+", "-") while skipping trailing whitespace.
triedChoice :: [Parser a] -> Parser a Source #
Tries each parser in the list sequentially, allowing backtracking for all but the last parser.
identifier :: Parser String Source #
An identifier in our language syntax
parseSrcLoc :: Parser SrcLoc Source #
Gets the SrcLoc
prefix :: String -> (SrcLoc -> Expr -> Expr) -> Operator Parser Expr Source #
Creates a prefix operator parser.
postfix :: String -> (SrcLoc -> Expr -> Expr) -> Operator Parser Expr Source #
Creates a postfix operator parser.
binary :: String -> (SrcLoc -> Expr -> Expr -> Expr) -> Operator Parser Expr Source #
Helper functions to define operators
parseStringChar :: Parser Char Source #
Parses a character in a string literal, supporting escape sequences.
parseEscapeSequence :: Parser Char Source #
Parses an escape sequence in a string literal (e.g., `n`, `t`, `xFF`).
parseHexEscape :: Parser Char Source #
Parses a hexadecimal escape sequence (e.g., `xFF`).
parseOctalEscape :: Parser Char Source #
Parses an octal escape sequence (e.g., `077`).
octalDigit :: Parser Char Source #
Parses an octal digit (`0-7`).
normalizeLoc :: SrcLoc Source #
A default SrcLoc
for normalization.
normalizeExpr :: Expr -> Expr Source #
Normalizes expressions by resetting their source locations. Ensures consistent formatting and comparison of expressions.