• 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: KipperCompiler

    compiler.KipperCompiler

    The main Compiler class that contains the functions for parsing and compiling a file.

    This class will per default use a KipperLogger and log events while processing. To define custom behaviour initialise KipperLogger yourself and overwrite emitHandler.

    Since

    0.0.1

    Table of contents

    Constructors

    • constructor

    Properties

    • _logger

    Accessors

    • internalFunctions
    • logger

    Methods

    • compile
    • getProgramCtx
    • getTokensForChannel
    • handleStreamInput
    • parse
    • syntaxAnalyse

    Constructors

    constructor

    • new KipperCompiler(logger?)

    Parameters

    Name Type
    logger KipperLogger

    Defined in

    kipper/core/src/compiler/compiler.ts:37

    Properties

    _logger

    • Private Readonly _logger: KipperLogger

    The private field '_logger' that actually stores the variable data, which is returned inside the this.logger.

    Defined in

    kipper/core/src/compiler/compiler.ts:35

    Accessors

    internalFunctions

    • Private get internalFunctions(): InternalFunction[]

    An array of all internal functions that are available to the compiler

    Since

    0.10.0

    Returns

    InternalFunction[]

    Defined in

    kipper/core/src/compiler/compiler.ts:53


    logger

    • get logger(): KipperLogger

    Returns the initialised logger for this class

    Returns

    KipperLogger

    Defined in

    kipper/core/src/compiler/compiler.ts:44

    Methods

    compile

    ▸ compile(stream, compilerOptions): Promise<KipperCompileResult>

    Compiles a file and generates a KipperCompileResult instance representing the generated code.

    This function is async to not render-block the browser and allow rendering to happen in-between the async processing.

    Throws

    If any syntactical, semantic or logical issues were encountered during the compilation.

    Parameters

    Name Type Description
    stream string | KipperFileStream The input to compile, which may be either a String or KipperFileStream.
    compilerOptions CompileConfig Compilation Configuration, which defines how the compiler should handle the program and compilation.

    Returns

    Promise<KipperCompileResult>

    The created KipperCompileResult instance.

    Defined in

    kipper/core/src/compiler/compiler.ts:168


    getProgramCtx

    ▸ getProgramCtx(parseData, compilerOptions): Promise<KipperProgramContext>

    Creates a new KipperProgramContext based on the passed parseData and compilerOptions.

    Since

    0.10.0

    Parameters

    Name Type Description
    parseData LexerParserData The parsing data of the file.
    compilerOptions EvaluatedCompileConfig | CompileConfig The compilation config.

    Returns

    Promise<KipperProgramContext>

    The newly created KipperProgramContext instance, which contains the metadata of the compiled program.

    Defined in

    kipper/core/src/compiler/compiler.ts:145


    getTokensForChannel

    ▸ Private getTokensForChannel(tokenStream, channel): Token[]

    Returns all tokens for a specific channel from the token stream.

    Since

    0.11.0

    Parameters

    Name Type Description
    tokenStream CommonTokenStream The token stream to get the tokens from.
    channel number The channel to get the tokens from.

    Returns

    Token[]

    Defined in

    kipper/core/src/compiler/compiler.ts:83


    handleStreamInput

    ▸ Private handleStreamInput(stream, name?): Promise<KipperFileStream>

    Handles the input for a file-based function of the KipperCompiler.

    Parameters

    Name Type Default value Description
    stream string | KipperFileStream undefined The input, which may be either a String or KipperFileStream.
    name string "anonymous-script" The encoding to read the file with.

    Returns

    Promise<KipperFileStream>

    Defined in

    kipper/core/src/compiler/compiler.ts:62


    parse

    ▸ parse(parseStream): Promise<LexerParserData>

    Parses a file and generates a parse tree using the Antlr4 KipperLexer and KipperParser.

    Throws

    KipperSyntaxError If a syntax exception was encountered while running.

    Parameters

    Name Type Description
    parseStream KipperFileStream The KipperFileStream instance that contains the required file content.

    Returns

    Promise<LexerParserData>

    An object containing the parse data.

    Defined in

    kipper/core/src/compiler/compiler.ts:100


    syntaxAnalyse

    ▸ syntaxAnalyse(stream): Promise<void>

    Analyses the syntax of the given file. Errors will be raised as an exception and warnings logged using the this.logger.

    If this function executes without any errors, then the syntax check succeeded.

    This function is async to not render-block the browser and allow rendering to happen in-between the async processing.

    Throws

    If a syntax exception was encountered while running.

    Parameters

    Name Type Description
    stream string | KipperFileStream The input to analyse, which may be either a String or KipperFileStream.

    Returns

    Promise<void>

    Defined in

    kipper/core/src/compiler/compiler.ts:248

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