frostc-1.0.0.0: The Frost Programming Language Compiler
Safe HaskellSafe-Inferred
LanguageHaskell2010

Ast.Parser.Utils

Synopsis

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.

sc :: Parser () Source #

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

parseBool :: Parser Bool Source #

Parses a boolean value (true or false). Returns a Bool.

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`).

hexDigit :: Parser Char Source #

Parses a hexadecimal digit (`0-9`, `a-f`, `A-F`).

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.