@dallaylaen/ski-interpreter
    Preparing search index...

    Class Parser

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    addContext: boolean
    allow: Set<string>
    annotate: boolean
    hasLambdas: boolean
    hasNumbers: boolean
    known: Record<string, Named>

    Methods

    • Declare a new term If the first argument is an Alias, it is added as is. Otherwise, a new Alias or Native term (depending on impl type) is created. If note is not provided and this.annotate is true, an automatic note is generated.

      If impl is a function, it should have signature (Expr) => ... => Expr (see typedef Partial at top of expr.js)

      Parameters

      • term: string | Alias
      • Optionalimpl: string | Expr | ((arg: Expr) => Invocation)
      • Optionaloptions: string | AddOptions
        • string
        • AddOptions
          • Optionalarity?: number
          • Optionalcanonize?: boolean
          • Optionalfancy?: string
          • Optionalnote?: string

      Returns this

      chainable

      ski.add('T', 'S(K(SI))K', 'swap combinator')
      
      ski.add( ski.parse('T = S(K(SI))K') ) // ditto but one-arg form
      
      ski.add('T', x => y => y.apply(x), 'swap combinator') // heavy artillery
      
      ski.add('Y', function (f) { return f.apply(this.apply(f)); }, 'Y combinator')
      
    • Declare and remove multiple terms at once term=impl adds term term= removes term

      Parameters

      • list: string[]

      Returns this

      chainable

    • Export term declarations for use in bulkAdd(). Currently only Alias terms are serialized.

      Returns string[]

    • Experimental

      Declare a new term if it is not known, otherwise just allow it. Currently only used by quests. Use with caution, this function may change its signature, behavior, or even be removed in the future.

      Parameters

      Returns this

    • Parameters

      • source: string
      • Optionaloptions: ParseOptions = {}
        • Optionalallow?: string
        • Optionalcanonize?: boolean
        • Optionalenv?: { [key: string]: Expr }
        • Optionallambdas?: boolean
        • Optionalnumbers?: boolean
        • Optionalscope?: object

      Returns Expr

    • Parse a single line of source code, without splitting it into declarations. Internal, always use parse() instead.

      Parameters

      • source: string

        S(KI)I

      • env: { [key: string]: Expr } = {}
      • Optionaloptions: ParseOptions = {}
        • Optionalallow?: string
        • Optionalcanonize?: boolean
        • Optionalenv?: { [key: string]: Expr }
        • Optionallambdas?: boolean
        • Optionalnumbers?: boolean
        • Optionalscope?: object

      Returns Expr

      parsed expression

    • Parameters

      • name: string

      Returns this

    • Restrict the interpreter to given terms. Terms prepended with '+' will be added and terms preceeded with '-' will be removed.

      Parameters

      • spec: string

      Returns this

      chainable

      ski.restrict('SK') // use the basis
      
      ski.restrict('+I') // allow I now
      
      ski.restrict('-SKI +BCKW' ); // switch basis
      
      ski.restrict('-foo -bar'); // forbid some user functions
      
    • Parameters

      • spec: string = '+'

      Returns string

    • Returns {
          allow: string;
          annotate: boolean;
          lambdas: boolean;
          numbers: boolean;
          terms: string[];
          version: string;
      }