• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

      • next /
      • Kipper API /
      • Module /
      • @kipper/core /
      • compiler
    Kipper Docs
    • next
    • latest
    • 0.11.0
    • 0.10.4
    • 0.9.2
    • Overview

    • Quickstart

    • Goals for Kipper

    • Supported platforms

    • Usage Examples

      • Overview

    • Variables

      • Overview

      • String Type

      • Number Type

      • Boolean Type

      • Void Type

      • Null Type

      • Undefined Type

      • Array Type

      • Overview

      • Tangled Expression

      • Arithmetic Expression

      • Assignment Expression

      • Conditional Expressions

      • Logical Expressions

      • Bitwise Expression

      • Relational Expressions

      • Convert Or Cast Expression

      • F-String Expression

      • Member Access Expression

      • Function Call Expression

      • Lambda Expression

      • Matches Expression

      • Overview

      • Expression Statement

      • If Statement

      • While Loop

      • Do-While Loop

      • For Loop

      • Compound Statement

      • Jump Statement

    • Functions

    • Interfaces

    • Classes

    • Comments

    • Built-in Functions

      • Overview

      • Compiler Setup

        • Overview

          • index

          • compiler

          • errors

          • logger

          • utils

          • config

          • index

          • index

        • Overview

        • new

        • run

        • compile

        • help

        • version

      • next /
      • Kipper API /
      • Module /
      • @kipper/core /
      • compiler
    • next /
    • Kipper API /
    • Module /
    • @kipper/core /
    • compiler

    Edit page

    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

    • ScopeNode<GlobalScope>

    Table of contents

    Constructors

    • constructor

    Properties

    • _antlrRuleCtx
    • _children
    • _innerScope
    • _parent
    • _programCtx
    • _semanticData
    • _typeSemantics
    • kind
    • ruleName

    Accessors

    • antlrRuleCtx
    • children
    • codeGenerator
    • compileConfig
    • errors
    • hasFailed
    • innerScope
    • kind
    • parent
    • programCtx
    • ruleName
    • semanticAnalyser
    • semanticData
    • sourceCode
    • target
    • typeSemantics

    Methods

    • _processAnalysis
    • addNewChild
    • getAntlrRuleChildren
    • getSemanticData
    • getTypeSemanticData
    • handleSemanticError
    • semanticAnalysis
    • translate

    Constructors

    constructor

    • new RootASTNode(programCtx, antlrCtx)

    Parameters

    Name Type
    programCtx KipperProgramContext
    antlrCtx CompilationUnitContext

    Overrides

    ParserASTNode.constructor

    Defined in

    kipper/core/src/compiler/ast/nodes/root-ast-node.ts:46

    Properties

    _antlrRuleCtx

    • Protected Readonly _antlrRuleCtx: CompilationUnitContext

    Implementation of

    ScopeNode._antlrRuleCtx

    Overrides

    ParserASTNode._antlrRuleCtx

    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

    ScopeNode._children

    Overrides

    ParserASTNode._children

    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

    ScopeNode._parent

    Overrides

    ParserASTNode._parent

    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

    ScopeNode._semanticData

    Inherited from

    ParserASTNode._semanticData

    Defined in

    kipper/core/src/compiler/ast/ast-node.ts:56


    _typeSemantics

    • Protected _typeSemantics: undefined | NoTypeSemantics

    Implementation of

    ScopeNode._typeSemantics

    Inherited from

    ParserASTNode._typeSemantics

    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

    KipperParserRuleContext

    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

    KipperTargetCodeGenerator

    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

    EvaluatedCompileConfig

    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

    KipperError[]

    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

    GlobalScope

    Implementation of

    ScopeNode.innerScope

    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

    KipperProgramContext

    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

    KipperTargetSemanticAnalyser

    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

    KipperCompileTarget

    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

    _processAnalysis

    ▸ Private _processAnalysis(toCall): Promise<void>

    Parameters

    Name Type
    toCall (item: Statement<StatementSemantics, StatementTypeSemantics> | Declaration<DeclarationSemantics, DeclarationTypeSemantics>) => Promise<void>

    Returns

    Promise<void>

    Defined in

    kipper/core/src/compiler/ast/nodes/root-ast-node.ts:177


    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

    ScopeNode.addNewChild

    Overrides

    ParserASTNode.addNewChild

    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

    NoSemantics

    Implementation of

    ScopeNode.getSemanticData

    Inherited from

    ParserASTNode.getSemanticData

    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

    NoTypeSemantics

    Implementation of

    ScopeNode.getTypeSemanticData

    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:249


    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:193


    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

    Promise<TranslatedCodeLine[]>

    Defined in

    kipper/core/src/compiler/ast/nodes/root-ast-node.ts:225

  • Developed at:

    • Releases
    • GitHub
    • Security
    • Issue Tracker
    • License
  • Copyright © 2021-2026 Luna Klatzer, 2024-2025 Lorenz Holzbauer & Fabian Baitura.
    Kipper is licensed under the GPL-3.0-or-later license.