• Kipper

    v0.12.1
  • Downloads

  • Docs

  • Playground

  • Changelog

  • Kipper

    v0.12.1
    • Downloads

    • Docs

    • Playground

    • Changelog

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

    Edit page

    Namespace: utils

    Table of contents

    Functions

    • codeGenerator
    • getConversionFunctionIdentifier
    • getNaturalOrZero
    • getParseRuleSource
    • getParseTreeSource
    • getTokenIntervalSource
    • getTokenSource
    • inverseMap
    • replaceObjKeys
    • titleCase

    Functions

    codeGenerator

    ▸ codeGenerator(target): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void

    A decorator function which registers the given method as a code generator for the specified target.

    By applying this decorator to a method, the method will be automatically called when the compiler is generating code for the specified target.

    Since

    0.11.0

    Parameters

    Name Type Description
    target ASTKind The number identifier of the target for which the decorated method should be called. This number can be fetched from the kind property.

    Returns

    fn

    ▸ (target, propertyKey, descriptor): void

    Parameters
    Name Type
    target any
    propertyKey string
    descriptor PropertyDescriptor
    Returns

    void

    Defined in

    kipper/core/src/tools/decorators/code-generator.ts:16


    getConversionFunctionIdentifier

    ▸ getConversionFunctionIdentifier(originalType, destType): string

    Generates for the specific types the corresponding conversion function identifier that should be implemented by the KipperTargetBuiltInGenerator.

    Since

    0.8.0

    Parameters

    Name Type Description
    originalType string The original type.
    destType string The type to convert to.

    Returns

    string

    Defined in

    kipper/core/src/tools/functions/other.ts:31


    getNaturalOrZero

    ▸ getNaturalOrZero(num): number

    Returns num unchanged if its positive, otherwise if its negative it will return 0.

    Since

    0.4.0

    Parameters

    Name Type
    num number

    Returns

    number

    Defined in

    kipper/core/src/tools/functions/other.ts:10


    getParseRuleSource

    ▸ getParseRuleSource(antlrCtx): string

    Returns the token source for the passed antlrCtx instance.

    Since

    0.4.0

    Parameters

    Name Type Description
    antlrCtx KipperParserRuleContext The token antlr4 context.

    Returns

    string

    Defined in

    kipper/core/src/tools/functions/parser-rules.ts:16


    getParseTreeSource

    ▸ getParseTreeSource(inputStream, parseTree): string

    Get the source code for a parse tree.

    Since

    0.6.0

    Parameters

    Name Type Description
    inputStream CharStream The input stream to fetch from.
    parseTree ParseTree The parse tree.

    Returns

    string

    Defined in

    kipper/core/src/tools/functions/parser-rules.ts:59


    getTokenIntervalSource

    ▸ getTokenIntervalSource(inputStream, start, stop): string

    Get the source code for two tokens (interval between these two tokens).

    Since

    0.6.0

    Parameters

    Name Type Description
    inputStream CharStream The input stream to fetch from.
    start Token The start token
    stop Token The stop token

    Returns

    string

    Defined in

    kipper/core/src/tools/functions/parser-rules.ts:39


    getTokenSource

    ▸ getTokenSource(inputStream, token): string

    Get the source code for a single token.

    Since

    0.6.0

    Parameters

    Name Type Description
    inputStream CharStream The input stream to fetch from.
    token Token The token to get the source code from.

    Returns

    string

    Defined in

    kipper/core/src/tools/functions/parser-rules.ts:49


    inverseMap

    ▸ inverseMap<T>(obj): InverseMap<T>

    Returns a given object with its keys and value inverted.

    Since

    0.11.0

    Type parameters

    Name Type
    T extends RecordT, string | number | symbol\>

    Parameters

    Name Type Description
    obj T The object to inverse.

    Returns

    InverseMap<T>

    Defined in

    kipper/core/src/tools/functions/inverse-map.ts:8


    replaceObjKeys

    ▸ replaceObjKeys<O, N, V>(obj, callback): Record<N, V>

    Replaces the keys of an object with the result of the callback function.

    Since

    0.11.0

    Type parameters

    Name Type
    O extends string | number | symbol
    N extends string | number | symbol
    V any

    Parameters

    Name Type Description
    obj Record<O, V> The object to replace the keys of.
    callback (key: O) => N The callback function to replace the keys with.

    Returns

    Record<N, V>

    Defined in

    kipper/core/src/tools/functions/replace-obj-keys.ts:7


    titleCase

    ▸ titleCase(str): string

    Apply title-case formatting on the specific string e.g. the first character of a word/char sequence must always be uppercase.

    Since

    0.8.0

    Parameters

    Name Type Description
    str string The string to modify.

    Returns

    string

    Defined in

    kipper/core/src/tools/functions/other.ts:20

  • Developed at and supported by:

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