| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
AST.Ast
Synopsis
- data Ast
- = AInteger IntValue
- | ABool Bool
- | ASymbol Text
- | AVoid
- | AList [Ast]
- | ADefineFunc Text [(Text, Text)] Text Ast
- | ADefineLambda [Text] Ast
- | ADefineStruct Text [(Text, Text)]
- | ASetVar Text Text Ast
- | ASetStruct Text [(Text, Ast)]
- | ACall Ast [Ast]
- | AAccessStruct Ast Text
- | AImport Text
- | AIf Ast Ast Ast
- | AWhile Ast Ast
- | AFor Ast Ast Ast Ast
- | AReturn Ast
- | AExprStmt Ast
- | ABlock [Ast]
- | ABreak
- | APos Int Int Ast
- showAst :: Ast -> String
- printAst :: Ast -> IO ()
- cleanAst :: Ast -> Ast
Documentation
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.
|
| ADefineLambda [Text] Ast | Represents an anonymous function (Lambda).
|
| ADefineStruct Text [(Text, Text)] | Represents a structure type definition.
|
| ASetVar Text Text Ast | Represents a variable definition or assignment.
|
| ASetStruct Text [(Text, Ast)] | Represents a structure definition statement wrapper. @param ADefineStruct The structure definition node. |
| ACall Ast [Ast] | Represents a function call (Application).
|
| AAccessStruct Ast Text | Represents a field access (e.g., player.x).
|
| 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).
|
| AWhile Ast Ast | Represents a While loop.
|
| AFor Ast Ast Ast Ast | Represents a For loop.
|
| 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 |
| 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.
|
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.