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
Implements
Table of contents
Constructors
Properties
Accessors
- antlrRuleCtx
- children
- codeGenerator
- compileConfig
- errors
- hasFailed
- innerScope
- 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:46
Properties
_antlrRuleCtx
• Protected
Readonly
_antlrRuleCtx: CompilationUnitContext
Implementation of
Overrides
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:40
_children
• Protected
Readonly
_children: (Statement
<StatementSemantics
, StatementTypeSemantics
> | Declaration
<DeclarationSemantics
, DeclarationTypeSemantics
>)[]
Implementation of
Overrides
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:43
_innerScope
• Protected
Readonly
_innerScope: GlobalScope
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:44
_parent
• Protected
Readonly
_parent: undefined
Implementation of
Overrides
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:42
_programCtx
• Protected
Readonly
_programCtx: KipperProgramContext
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:41
_semanticData
• Protected
_semanticData: undefined
| NoSemantics
Implementation of
Inherited from
Defined in
kipper/core/src/compiler/ast/ast-node.ts:56
_typeSemantics
• Protected
_typeSemantics: undefined
| NoTypeSemantics
Implementation of
Inherited from
Defined in
kipper/core/src/compiler/ast/ast-node.ts:75
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:34
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:39
Accessors
antlrRuleCtx
• get
antlrRuleCtx(): KipperParserRuleContext
The antlr rule context containing the antlr4 metadata for this AST node.
Since
0.8.0
Returns
Implementation of
ScopeNode.antlrRuleCtx
Inherited from
ParserASTNode.antlrRuleCtx
Defined in
kipper/core/src/compiler/ast/ast-node.ts:114
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
>)[]
Implementation of
ScopeNode.children
Overrides
ParserASTNode.children
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:131
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:156
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:147
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:108
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:123
innerScope
• get
innerScope(): GlobalScope
Gets the inner scope of this function, where also the semanticData.params arguments should be registered.
Since
0.10.0
Returns
Implementation of
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:83
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
Implementation of
ScopeNode.kind
Overrides
ParserASTNode.kind
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:63
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
Implementation of
ScopeNode.parent
Overrides
ParserASTNode.parent
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:92
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:100
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"
Implementation of
ScopeNode.ruleName
Overrides
ParserASTNode.ruleName
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:75
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:165
semanticData
• get
semanticData(): undefined
| Semantics
Returns the semantic data of this AST node.
Since
0.8.0
Returns
undefined
| Semantics
Implementation of
ScopeNode.semanticData
Inherited from
ParserASTNode.semanticData
Defined in
kipper/core/src/compiler/ast/ast-node.ts:62
• 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
Implementation of
ScopeNode.semanticData
Inherited from
ParserASTNode.semanticData
Defined in
kipper/core/src/compiler/ast/ast-node.ts:71
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
Implementation of
ScopeNode.sourceCode
Inherited from
ParserASTNode.sourceCode
Defined in
kipper/core/src/compiler/ast/ast-node.ts:133
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:139
typeSemantics
• get
typeSemantics(): undefined
| TypeSemantics
Returns the type data of this AST node.
Since
0.10.0
Returns
undefined
| TypeSemantics
Implementation of
ScopeNode.typeSemantics
Inherited from
ParserASTNode.typeSemantics
Defined in
kipper/core/src/compiler/ast/ast-node.ts:81
• 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
Implementation of
ScopeNode.typeSemantics
Inherited from
ParserASTNode.typeSemantics
Defined in
kipper/core/src/compiler/ast/ast-node.ts:90
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
Implementation of
Overrides
Defined in
kipper/core/src/compiler/ast/nodes/root-ast-node.ts:173
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
[]
Implementation of
ScopeNode.getAntlrRuleChildren
Inherited from
ParserASTNode.getAntlrRuleChildren
Defined in
kipper/core/src/compiler/ast/ast-node.ts:161
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
Implementation of
Inherited from
Defined in
kipper/core/src/compiler/ast/ast-node.ts:174
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
Implementation of
Inherited from
ParserASTNode.getTypeSemanticData
Defined in
kipper/core/src/compiler/ast/ast-node.ts:187
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:264
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:240