• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

      • 0.11.0 /
      • 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

      • Compiler Setup

        • Overview

          • index

          • compiler

          • errors

          • logger

          • utils

          • config

          • index

          • index

        • Overview

        • new

        • run

        • compile

        • help

        • version

    • Variables

      • Overview

      • String Type

      • Number Type

      • Boolean Type

      • Void Type

      • Null Type

      • Undefined Type

      • Array Type

      • Overview

      • Arithmetic Expression

      • Assignment Expression

      • Conditional Expressions

      • Logical Expressions

      • Bitwise Expression

      • Relational Expressions

      • Convert Expression

      • F-String Expression

      • Member Access Expression

      • Function Call Expression

      • Overview

      • Expression Statement

      • If Statement

      • While Loop

      • Do-While Loop

      • For Loop

      • Compound Statement

      • Jump Statement

    • Functions

    • Comments

    • Built-in Functions

      • 0.11.0 /
      • Kipper API /
      • Module /
      • @kipper/core /
      • compiler
    • 0.11.0 /
    • 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

    Table of contents

    Constructors

    • constructor

    Properties

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

    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

    ParserASTNode.constructor

    Defined in

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

    Properties

    _antlrRuleCtx

    • Protected Readonly _antlrRuleCtx: CompilationUnitContext

    Overrides

    ParserASTNode._antlrRuleCtx

    Defined in

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


    _children

    • Protected Readonly _children: (Statement<StatementSemantics, StatementTypeSemantics> | Declaration<DeclarationSemantics, DeclarationTypeSemantics>)[]

    Overrides

    ParserASTNode._children

    Defined in

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


    _parent

    • Protected Readonly _parent: undefined

    Overrides

    ParserASTNode._parent

    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

    ParserASTNode._semanticData

    Defined in

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


    _typeSemantics

    • Protected _typeSemantics: undefined | NoTypeSemantics

    Inherited from

    ParserASTNode._typeSemantics

    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

    KipperParserRuleContext

    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

    KipperTargetCodeGenerator

    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

    EvaluatedCompileConfig

    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

    KipperError[]

    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

    KipperProgramContext

    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

    KipperTargetSemanticAnalyser

    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

    KipperCompileTarget

    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

    ParserASTNode.addNewChild

    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

    NoSemantics

    Inherited from

    ParserASTNode.getSemanticData

    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

    NoTypeSemantics

    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

    Promise<TranslatedCodeLine[]>

    Defined in

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

  • 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.