glados-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

AST.Ast

Synopsis

Documentation

data Ast Source #

Abstract Syntax Tree (AST) definition for the GLADOS language.

@details The AST represents the hierarchical structure of the parsed source code. Each constructor corresponds to a specific syntactic construct in the language, such as literals, definitions, control flow, and function calls.

Constructors

AInteger IntValue

Represents an integer literal. @param IntValue The value of the integer.

ABool Bool

Represents a boolean literal. @param Bool True or False.

ASymbol Text

Represents a symbol (identifier). Used for variable names, function names, or reference lookups. @param Text The name of the symbol.

AVoid

Represents a Void or Null value (no return value).

AList [Ast]

Represents a generic list of AST nodes. Can be used for list literals or sequence of expressions. @param [Ast] The elements of the list.

ADefineFunc Text [(Text, Text)] Text Ast

Represents a named function definition. param Text The name of the function. param [(Text, Text)] The list of arguments (Name, Type). param Text The return type of the function. param Ast The body of the function.

ADefineLambda [Text] Ast

Represents an anonymous function (Lambda). param [Text] The list of parameter names. param Ast The body of the lambda.

ADefineStruct Text [(Text, Text)]

Represents a structure type definition. param Text The name of the structure. param [(Text, Text)] The list of fields (Name, Type).

ASetVar Text Text Ast

Represents a variable definition or assignment. param Text The name of the variable. param Text The type of the variable. @param Ast The value assigned to the variable.

ASetStruct Text [(Text, Ast)]

Represents a structure definition statement wrapper. @param ADefineStruct The structure definition node.

ACall Ast [Ast]

Represents a function call (Application). param Ast The callee (function expression or symbol). param [Ast] The list of arguments passed to the function.

AAccessStruct Ast Text

Represents a field access (e.g., player.x). param Ast The object/structure being accessed. param Text The name of the field.

AImport Text

Represents an import statement. @param Text The name of the module or file to import.

AIf Ast Ast Ast

Represents a conditional control flow (If-Then-Else). param Ast The condition expression. param Ast The Then branch. @param Ast The Else branch.

AWhile Ast Ast

Represents a While loop. param Ast The loop condition. param Ast The loop body.

AFor Ast Ast Ast Ast

Represents a For loop. param Ast The initialization step. param Ast The loop condition. param Ast The update/increment step. param Ast The loop body.

AReturn Ast

Represents an explicit return statement. @param Ast The expression to return.

AExprStmt Ast

Represents an expression used as a statement. This wrapper is used when an expression is executed for its side effects (e.g., a function call or assignment) rather than its return value. Usually corresponds to an expression followed by a semicolon. @param Ast The wrapped expression.

ABlock [Ast]

Represents a scoped block of code (enclosed in braces `{}`). Used to group multiple statements into a single logical unit, typically for function bodies, loop bodies, or conditional branches. @param [Ast] The list of statements contained in the block.

ABreak

Represents a break statement. Used to immediately terminate the nearest enclosing loop (for, while). Control flow continues at the next statement following the loop.

APos Int Int Ast

Represents a source code position wrapper. Used for precise error reporting (line, column). This node wraps another AST node without changing its semantics. param Int The line number. param Int The column number. @param Ast The wrapped AST node.

Instances

Instances details
Show Ast Source # 
Instance details

Defined in AST.Ast

Methods

showsPrec :: Int -> Ast -> ShowS #

show :: Ast -> String #

showList :: [Ast] -> ShowS #

Eq Ast Source # 
Instance details

Defined in AST.Ast

Methods

(==) :: Ast -> Ast -> Bool #

(/=) :: Ast -> Ast -> Bool #

cleanAst :: Ast -> Ast Source #

Recursively removes all position wrappers (APos) from the AST.

This is useful for: Pretty printing (to avoid cluttering the output with position data). Testing (to compare AST structure without worrying about line numbers).

param Ast The AST potentially containing APos nodes. return Ast The cleaned AST with purely structural nodes.