Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Ast.Parser.Expr
Synopsis
- parseExpr :: Parser Expr
- operationTable :: [[Operator Parser Expr]]
- parseCall :: Operator Parser Expr
- parseAssignment :: Operator Parser Expr
- parseArrayAccess :: Operator Parser Expr
- parseStructAccess :: Operator Parser Expr
- parseTerm :: Parser Expr
- parseLit :: Parser Expr
- parseVar :: Parser Expr
- parseFunction :: Parser Expr
- implicitReturn :: Expr -> Expr
- parseForeignFunction :: Parser Expr
- parseDeclaration :: Parser Expr
- parseIf :: Parser Expr
- parseWhile :: Parser Expr
- parseFrom :: Parser Expr
- parseBlock :: (Expr -> Expr) -> Parser Expr
- deferedExpr :: [Expr] -> Expr -> Expr
- parseReturn :: Parser Expr
- parseBreak :: Parser Expr
- parseContinue :: Parser Expr
- parseCast :: Parser Expr
- parseDefer :: Parser Expr
- parseParenExpr :: Parser Expr
- parseAssembly :: Parser Expr
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 #
parseDefer :: Parser Expr Source #
Parses a defer
statement, which registers an expression to be executed later.
Returns the next expression to be parsed.