Traqula
    Preparing search index...

    Class ParserBuilder<Context, Names, RuleDefs>

    The grammar builder. This is the core of traqula (besides using the amazing chevrotain framework). Using the builder you can create a grammar + AST creator. At any point in time, a parser can be constructed from the added rules. Constructing a parser will cause a validation which will validate the correctness of the grammar.

    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 ParserBuilder<
          Context,
          Names,
          {
              [Key in string]: Key extends keyof Patch
                  ? Patch[Key] extends [any, any[]]
                      ? ParserRule<Context, Key, any[any][0], any[any][1]>
                      : Patch[Key] extends [any]
                          ? RuleDefs[Key] extends ParserRule<any, any, any, Par>
                              ? ParserRule<Context, Key, any[any][0], Par>
                              : never
                          : never
                  : RuleDefs[Key] extends ParserRule<Context, 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 ParserBuilder<
          NewContext,
          Names,
          {
              [Key in string
              | number
              | symbol]: Key extends Names
                  ? RuleDefs[Key] extends ParserRule<any, any, RT, PT>
                      ? ParserRule<NewContext, Key, RT, PT>
                      : never
                  : never
          },
      >