• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

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

      • Type Consistency

      • Runtime Type Casting

      • Strict Compiler Inspection

      • Integrated Runtime Library

    • 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

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

    Edit page

    Class: ParserASTNode<Semantics, TypeSemantics>

    compiler.ParserASTNode

    An Abstract Syntax Tree (AST) node, which wraps an Antlr4 parse rule context and simplifies its content down to a simplified representation, which can be used for semantic analysis and code translation.

    Since

    0.8.0

    Type parameters

    Name Type
    Semantics extends SemanticData
    TypeSemantics extends TypeData

    Hierarchy

    • ParserASTNode

      ↳ AnalysableASTNode

      ↳ ScopeNode

      ↳ RootASTNode

    Table of contents

    Constructors

    • constructor

    Properties

    • _antlrRuleCtx
    • _children
    • _parent
    • _semanticData
    • _typeSemantics

    Accessors

    • antlrRuleCtx
    • children
    • kind
    • parent
    • ruleName
    • semanticData
    • sourceCode
    • typeSemantics

    Methods

    • addNewChild
    • getAntlrRuleChildren
    • getSemanticData
    • getTypeSemanticData

    Constructors

    constructor

    • Protected new ParserASTNode<Semantics, TypeSemantics>(antlrCtx, parent)

    Type parameters

    Name Type
    Semantics extends SemanticData
    TypeSemantics extends TypeData

    Parameters

    Name Type
    antlrCtx KipperParserRuleContext
    parent undefined | ParserASTNode<any, any>

    Defined in

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

    Properties

    _antlrRuleCtx

    • Protected Readonly _antlrRuleCtx: KipperParserRuleContext

    Defined in

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


    _children

    • Protected Readonly _children: ParserASTNode<any, any>[]

    Defined in

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


    _parent

    • Protected Readonly _parent: undefined | ParserASTNode<any, any>

    Defined in

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


    _semanticData

    • Protected _semanticData: undefined | Semantics

    Defined in

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


    _typeSemantics

    • Protected _typeSemantics: undefined | TypeSemantics

    Defined in

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

    Accessors

    antlrRuleCtx

    • get antlrRuleCtx(): KipperParserRuleContext

    The antlr rule context containing the antlr4 metadata for this AST node.

    Since

    0.8.0

    Returns

    KipperParserRuleContext

    Defined in

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


    children

    • get children(): ParserASTNode<any, any>[]

    The children of this AST node.

    Since

    0.8.0

    Returns

    ParserASTNode<any, any>[]

    Defined in

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


    kind

    • Abstract get kind(): number

    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 KipperParser rule fields, for example RULE_expression.

    Since

    0.10.0

    Returns

    number

    Defined in

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


    parent

    • get parent(): undefined | ParserASTNode<any, any>

    Returns the parent that has this node as a child. If parent is undefined, then this item is a root node.

    Since

    0.8.0

    Returns

    undefined | ParserASTNode<any, any>

    Defined in

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


    ruleName

    • Abstract get ruleName(): string

    Returns the identifier of this AST node. This is a unique identifier that can be used to differentiate this AST node from other AST nodes.

    Since

    0.11.0

    Returns

    string

    Defined in

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


    semanticData

    • get semanticData(): undefined | Semantics

    Returns the semantic data of this AST node.

    Since

    0.8.0

    Returns

    undefined | Semantics

    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

    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

    Defined in

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


    typeSemantics

    • get typeSemantics(): undefined | TypeSemantics

    Returns the type data of this AST node.

    Since

    0.10.0

    Returns

    undefined | 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

    Defined in

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

    Methods

    addNewChild

    ▸ addNewChild(newChild): void

    Adds new child ctx item to this AST node. The child item should be in the order that they appeared in the this.antlrCtx parse tree.

    This will also automatically set the parent of newChild to this instance.

    Since

    0.8.0

    Parameters

    Name Type
    newChild ParserASTNode<any, any>

    Returns

    void

    Defined in

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


    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[]

    Defined in

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


    getSemanticData

    ▸ getSemanticData(): Semantics

    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

    Semantics

    Defined in

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


    getTypeSemanticData

    ▸ getTypeSemanticData(): TypeSemantics

    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

    TypeSemantics

    Defined in

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

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