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

Ast.Parser.Expr

Synopsis

Documentation

parseExpr :: Parser Expr Source #

Parses an expression using a precedence-aware parser. Returns an Expr representing the parsed expression.

operationTable :: [[Operator Parser Expr]] Source #

Defines the operation table for parsing expressions. Includes prefix, postfix, and infix operators with their precedence levels.

parseCall :: Operator Parser Expr Source #

Parses a function or method call expression. Returns a Postfix operator that adds the call to an existing expression.

parseAssignment :: Operator Parser Expr Source #

Parses an assignment expression. Returns an InfixL operator that creates an Assignment.

parseArrayAccess :: Operator Parser Expr Source #

Parses an array access expression. Returns an InfixL operator that creates an ArrayAccess.

parseStructAccess :: Operator Parser Expr Source #

Parses a structure field access expression. Returns an InfixL operator that creates an StructAccess.

parseTerm :: Parser Expr Source #

Parses a term, which can be a variety of expressions, including: literals, variables, blocks, loops, if statements, function declarations, and more. Returns the parsed Expr.

parseLit :: Parser Expr Source #

Parses a literal (e.g., integers, strings, booleans). Returns an Lit containing the parsed literal.

parseVar :: Parser Expr Source #

Parses a variable reference. Returns an Var containing the variable name and type.

parseFunction :: Parser Expr Source #

Parses a function declaration, including its name, type, parameters, and body. Returns an Function.

implicitReturn :: Expr -> Expr Source #

Adds an implicit return statement to the last expression in a block if needed. Returns the modified Expr.

parseForeignFunction :: Parser Expr Source #

Parses a foreign function declaration, which includes the `foreign` keyword. Returns an ForeignFunction.

parseDeclaration :: Parser Expr Source #

Parses a variable declaration, including its name, type, and optional initializer. Returns an Declaration.

parseIf :: Parser Expr Source #

Parses an `if` expression, including its condition, `then` block, and optional `else` block. Returns an If.

parseWhile :: Parser Expr Source #

Parses a while loop expression, including its condition and body. Returns an While.

parseFrom :: Parser Expr Source #

Parses a from loop expression, including the range and step configuration. Returns an From.

parseBlock :: (Expr -> Expr) -> Parser Expr Source #

Parses a block of expressions enclosed by `{}`. Accepts a transformation function to apply to the block's result. Returns an Block or the transformed expression.

deferedExpr :: [Expr] -> Expr -> Expr Source #

Combines deferred expressions with the main block. Ensures that deferred expressions are executed in the correct order. Returns the modified Expr.

parseReturn :: Parser Expr Source #

Parses a return statement. Returns an Return with an optional expression.

parseBreak :: Parser Expr Source #

Parses a break statement. Returns an Break.

parseContinue :: Parser Expr Source #

Parses a continue statement. Returns an Continue.

parseCast :: Parser Expr Source #

Parses a type cast expression. Returns an Cast.

parseDefer :: Parser Expr Source #

Parses a defer statement, which registers an expression to be executed later. Returns the next expression to be parsed.

parseParenExpr :: Parser Expr Source #

Parses an expression enclosed in parentheses. Returns the parsed Expr.

parseAssembly :: Parser Expr Source #

Parses an inline assembly block using the __asm__ keyword. Returns an Assembly containing the parsed assembly expression.