Options
All
  • Public
  • Public/Protected
  • All
Menu

Chevrotain

Index

Type aliases

GrammarAction

GrammarAction: function

Type declaration

    • (): void
    • Returns void

LookAheadFunc

LookAheadFunc: function

Type declaration

    • (): boolean
    • Returns boolean

TokenConstructor

TokenConstructor: Function

Variables

EOF_FOLLOW_KEY

EOF_FOLLOW_KEY: any

Functions

EMPTY_ALT

  • EMPTY_ALT<T>(value?: T): function
  • convenience used to express an empty alternative in an OR (alternation). can be used to more clearly describe the intent in a case of empty alternation.

    for example:

    1. without using EMPTY_ALT:

      this.OR([ {ALT: () => {

      this.CONSUME1(OneTok)
      return "1"
      

      }}, {ALT: () => {

      this.CONSUME1(TwoTok)
      return "2"
      

      }}, {ALT: () => { // implicitly empty because there are no invoked grammar rules (OR/MANY/CONSUME...) inside this alternative.

      return "666"
      

      }}, ])

      1. using EMPTY_ALT:

        this.OR([ {ALT: () => { this.CONSUME1(OneTok) return "1" }}, {ALT: () => { this.CONSUME1(TwoTok) return "2" }}, {ALT: EMPTY_ALT("666")}, // explicitly empty, clearer intent ])

    Type parameters

    • T

    Parameters

    • Default value value: T = undefined

    Returns function

      • (): T
      • Returns T

InRuleRecoveryException

  • InRuleRecoveryException(message: string): void

clearCache

  • clearCache(): void
  • Clears the chevrotain internal cache. This should not be used in regular work flows, This is intended for unique use cases for example: online playground where the a parser with the same name is initialized with different implementations multiple times.

    Returns void

extendToken

  • extendToken(tokenName: string, patternOrParent?: any, parentConstructor?: Function): any
  • utility to help the poor souls who are still stuck writing pure javascript 5.1 extend and create Token subclasses in a less verbose manner

    Parameters

    • tokenName: string

      the name of the new TokenClass

    • Default value patternOrParent: any = undefined

      RegExp Pattern or Parent Token Constructor

    • Default value parentConstructor: Function = Token

      the Token class to be extended

    Returns any

    • a constructor for the new extended Token subclass

tokenName

  • tokenName(clazz: Function): string

Generated using TypeDoc