Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ReaderCodegen

Factory that returns the reader code and values for variables that must be bound to the reader.

Hierarchy

  • ReaderCodegen

Index

Methods

Methods

  • factory(inputVar: symbol, offsetVar: symbol, contextVar: symbol, resultVar: symbol): CodeBindings
  • The factory that returns the code of the reader function. The produced code assigns the reader result for inputVar and offsetVar to resultVar. The produced code must be a semicolon-terminated statement.

    const abcReaderCodegenFactory: ReaderCodegenFactory = (inputVar, offsetVar, contextVar, resultVar) => {
    const abcVar = Symbol();
    return {
    code: [resultVar, '=', inputVar, '.startsWith(', abcVar, ',', offsetVar, ')?', offsetVar, '+3:-1;'],
    bindings: [[abcVar, 'abc']],
    };
    };

    Parameters

    • inputVar: symbol

      The variable that holds the input string.

    • offsetVar: symbol

      The variable that holds the offset in the input string from which the reader must be applied.

    • contextVar: symbol

      The variable that holds the reader context.

    • resultVar: symbol

      The variable to which the reader result must be assigned.

    Returns CodeBindings

    The source code and required variable bindings.

Generated using TypeDoc