Traqula
    Preparing search index...

    Class GeneratorBuilder<Context, Names, RuleDefs>

    Builder for composing modular code generators from rule definitions. Mirrors the ParserBuilder API but targets code generation (AST → string) instead of parsing (string → AST).

    Builders mutate internal state and return this. Always start by copying an existing builder with GeneratorBuilder.create(existingBuilder).

    Type Parameters

    Index

    Methods

    • Update the type signatures (return types and/or parameter types) of existing rules without changing their implementations. Use this when a patched rule changes the types flowing through downstream rules that don't need new implementations. This is a zero-cost type-level operation.

      Type Parameters

      • Patch extends { [Key in string]?: [any] | [any, any[]] }

      Returns GeneratorBuilder<
          Context,
          Names,
          {
              [Key in string]: Key extends keyof Patch
                  ? Patch[Key] extends [any, any[]]
                      ? GeneratorRule<Context, Key, any[any][0], any[any][1]>
                      : Patch[Key] extends [any]
                          ? RuleDefs[Key] extends GeneratorRule<any, any, any, Par>
                              ? GeneratorRule<Context, Key, any[any][0], Par>
                              : never
                          : never
                  : RuleDefs[Key] extends GeneratorRule<any, Key> ? any[any] : never
          },
      >

    • Narrow the builder's context type parameter to a more specific subtype. This is a zero-cost type-level operation — the builder instance is returned as-is but with updated type parameters.

      Type Parameters

      • NewContext

      Returns GeneratorBuilder<
          NewContext,
          Names,
          {
              [Key in string
              | number
              | symbol]: Key extends Names
                  ? RuleDefs[Key] extends GeneratorRule<any, any, RT, PT>
                      ? GeneratorRule<NewContext, Key, RT, PT>
                      : never
                  : never
          },
      >