Class: RootASTNode
compiler.RootASTNode
The root node of an abstract syntax tree, which contains all AST nodes of a file.
Since
0.8.0
Hierarchy
ParserASTNode<NoSemantics,NoTypeSemantics>↳
RootASTNode
Table of contents
Constructors
Properties
Accessors
- antlrRuleCtx
- children
- codeGenerator
- compileConfig
- errors
- hasFailed
- kind
- parent
- programCtx
- ruleName
- semanticAnalyser
- semanticData
- sourceCode
- target
- typeSemantics
Methods
- addNewChild
- getAntlrRuleChildren
- getSemanticData
- getTypeSemanticData
- handleSemanticError
- semanticAnalysis
- translate
Constructors
constructor
• new RootASTNode(programCtx, antlrCtx)
Parameters
| Name | Type |
|---|---|
programCtx |
KipperProgramContext |
antlrCtx |
CompilationUnitContext |
Overrides
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:70
Properties
_antlrRuleCtx
• Protected Readonly _antlrRuleCtx: CompilationUnitContext
Overrides
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:29
_children
• Protected Readonly _children: (Statement<StatementSemantics, StatementTypeSemantics> | Declaration<DeclarationSemantics, DeclarationTypeSemantics>)[]
Overrides
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:32
_parent
• Protected Readonly _parent: undefined
Overrides
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:31
_programCtx
• Protected Readonly _programCtx: KipperProgramContext
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:30
_semanticData
• Protected _semanticData: undefined | NoSemantics
Inherited from
Defined in
kipper/core/src/compiler/ast/ast-node.ts:48
_typeSemantics
• Protected _typeSemantics: undefined | NoTypeSemantics
Inherited from
Defined in
kipper/core/src/compiler/ast/ast-node.ts:49
kind
▪ Static Readonly kind: 0
The static kind for this AST Node.
Since
0.11.0
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:38
ruleName
▪ Static Readonly ruleName: "RULE_compilationUnit"
The static rule name for this AST Node.
Since
0.11.0
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:56
Accessors
antlrRuleCtx
• get antlrRuleCtx(): KipperParserRuleContext
The antlr rule context containing the antlr4 metadata for this AST node.
Since
0.8.0
Returns
Inherited from
ParserASTNode.antlrRuleCtx
Defined in
kipper/core/src/compiler/ast/ast-node.ts:112
children
• get children(): (Statement<StatementSemantics, StatementTypeSemantics> | Declaration<DeclarationSemantics, DeclarationTypeSemantics>)[]
The children of this AST root node.
Since
0.8.0
Returns
(Statement<StatementSemantics, StatementTypeSemantics> | Declaration<DeclarationSemantics, DeclarationTypeSemantics>)[]
Overrides
ParserASTNode.children
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:122
codeGenerator
• get codeGenerator(): KipperTargetCodeGenerator
The code generator, which will generate the code for this specific token into the this.target target language.
Since
0.10.0
Returns
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:147
compileConfig
• get compileConfig(): EvaluatedCompileConfig
The compilation config for this program.
Since
0.10.0
Returns
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:138
errors
• get errors(): KipperError[]
The errors that were caused by this root node. Includes all errors from children.
Since
0.10.0
Returns
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:99
hasFailed
• get hasFailed(): boolean
Returns true if the semantic analysis or type checking of this node or any children nodes failed.
This indicates that the root node is not valid and can not be translated.
Since
0.10.0
Returns
boolean
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:114
kind
• get kind(): 0
Returns the kind of this AST node. This represents the specific type of the antlrRuleCtx that this AST node wraps.
This may be compared using the rule fields, for example RULE_expression.
Since
0.10.0
Returns
0
Overrides
ParserASTNode.kind
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:48
parent
• get parent(): undefined
The parent of this root node. This will always return undefined, as there will never be a parent for a root AST node.
Since
0.8.0
Returns
undefined
Overrides
ParserASTNode.parent
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:83
programCtx
• get programCtx(): KipperProgramContext
The program context of this root node, which stores the metadata for the Kipper program.
Since
0.8.0
Returns
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:91
ruleName
• get ruleName(): "RULE_compilationUnit"
Returns the rule name of this AST Node. This represents the specific type of the antlrRuleCtx that this AST node wraps.
This may be compared using the rule fields, for example RULE_expression.
Since
0.11.0
Returns
"RULE_compilationUnit"
Overrides
ParserASTNode.ruleName
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:66
semanticAnalyser
• get semanticAnalyser(): KipperTargetSemanticAnalyser
The translation-specific semantic analyser, which will perform semantic analysis specific for the this.target target language.
Since
0.10.0
Returns
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:156
semanticData
• get semanticData(): undefined | Semantics
Returns the semantic data of this AST node.
Since
0.8.0
Returns
undefined | Semantics
Inherited from
ParserASTNode.semanticData
Defined in
kipper/core/src/compiler/ast/ast-node.ts:78
• set semanticData(value): void
Sets the semantic data of this AST node.
Since
0.8.0
Parameters
| Name | Type | Description |
|---|---|---|
value |
undefined | Semantics |
The semantic data that should be written onto this AST node. |
Returns
void
Inherited from
ParserASTNode.semanticData
Defined in
kipper/core/src/compiler/ast/ast-node.ts:87
sourceCode
• get sourceCode(): string
The Kipper source code that was used to generate this CompilableASTNode.
Any left-over whitespaces will be removed using trim().
Since
0.8.0
Returns
string
Inherited from
ParserASTNode.sourceCode
Defined in
kipper/core/src/compiler/ast/ast-node.ts:131
target
• get target(): KipperCompileTarget
The compilation translation for this specific token.
Since
0.10.0
Returns
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:130
typeSemantics
• get typeSemantics(): undefined | TypeSemantics
Returns the type data of this AST node.
Since
0.10.0
Returns
undefined | TypeSemantics
Inherited from
ParserASTNode.typeSemantics
Defined in
kipper/core/src/compiler/ast/ast-node.ts:95
• set typeSemantics(value): void
Sets the type data of this AST node.
Since
0.10.0
Parameters
| Name | Type | Description |
|---|---|---|
value |
undefined | TypeSemantics |
The semantic data that should be written onto this AST node. |
Returns
void
Inherited from
ParserASTNode.typeSemantics
Defined in
kipper/core/src/compiler/ast/ast-node.ts:104
Methods
addNewChild
▸ addNewChild(newChild): void
Adds new child at the end of the tree.
Since
0.8.0
Parameters
| Name | Type |
|---|---|
newChild |
Statement<StatementSemantics, StatementTypeSemantics> | Declaration<DeclarationSemantics, DeclarationTypeSemantics> |
Returns
void
Overrides
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:164
getAntlrRuleChildren
▸ getAntlrRuleChildren(): ParseTree[]
Returns the children of the antlrRuleCtx and throws an error in case they are undefined.
Throws
If antlrRuleCtx.children is undefined.
Since
0.8.0
Returns
ParseTree[]
Inherited from
ParserASTNode.getAntlrRuleChildren
Defined in
kipper/core/src/compiler/ast/ast-node.ts:159
getSemanticData
▸ getSemanticData(): NoSemantics
Returns the semantic data of this AST node and throws an error in case it is undefined.
Throws
If semanticData is undefined.
Since
0.8.0
Returns
Inherited from
Defined in
kipper/core/src/compiler/ast/ast-node.ts:172
getTypeSemanticData
▸ getTypeSemanticData(): NoTypeSemantics
Returns the type semantic data of this AST node and throws an error in case it is undefined.
Throws
UndefinedSemanticsError If semanticData is undefined.
Since
0.10.0
Returns
Inherited from
ParserASTNode.getTypeSemanticData
Defined in
kipper/core/src/compiler/ast/ast-node.ts:185
handleSemanticError
▸ Protected handleSemanticError(error): void
Handles the specified error that occurred during the semantic analysis of this node in a standardised way.
Since
0.10.0
Parameters
| Name | Type | Description |
|---|---|---|
error |
KipperError | Error |
The error to handle. |
Returns
void
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:173
semanticAnalysis
▸ semanticAnalysis(): Promise<void>
Semantically analyses the children tokens of this instance and performs additional translation specific analysis.
Since
0.8.0
Returns
Promise<void>
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:183
translate
▸ Protected translate(): Promise<TranslatedCodeLine[]>
Translates the children tokens of this instance into the specific this.programCtx.target target language.
Since
0.8.0
Returns
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:230