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

MultiModeLexerWDefinition

MultiModeLexerWDefinition: object

Type declaration

SingleModeLexerDefinition

SingleModeLexerDefinition: TokenConstructor[]

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

hasTokenLabel

  • hasTokenLabel(clazz: Function): boolean

tokenLabel

  • tokenLabel(clazz: Function): string
  • This can be used to improve the quality/readability of error messages or syntax diagrams.

    Parameters

    • clazz: Function

      A constructor for a Token subclass

    Returns string

    the Human readable label a Token if it exists.

tokenName

  • tokenName(clazz: Function): string

Generated using TypeDoc