Options
All
  • Public
  • Public/Protected
  • All
Menu

Chevrotain

Index

Type aliases

GrammarAction

GrammarAction: function

Type declaration

    • (): void
    • Returns void

IAnyOrAlt

IAnyOrAlt: IOrAlt<T> | IOrAltWithGate<T>

IgnoredParserIssues

IgnoredParserIssues: object

Type declaration

IgnoredRuleIssues

IgnoredRuleIssues: object

Type declaration

  • [dslNameAndOccurrence: string]: boolean

MultiModesDefinition

MultiModesDefinition: object

Type declaration

Predicate

Predicate: function

Type declaration

    • (): boolean
    • Returns boolean

SingleModeLexerDefinition

SingleModeLexerDefinition: TokenConstructor[]

TokenClassIdentityFunc

TokenClassIdentityFunc: function

Type declaration

TokenConstructor

TokenConstructor: Function

TokenInstanceIdentityFunc

TokenInstanceIdentityFunc: function

Type declaration

    • Parameters

      Returns string

TokenMatcher

TokenMatcher: function

Type declaration

Variables

AT_LEAST_ONE_IDX

AT_LEAST_ONE_IDX: number = 4 << BITS_FOR_METHOD_IDX

AT_LEAST_ONE_SEP_IDX

AT_LEAST_ONE_SEP_IDX: number = 6 << BITS_FOR_METHOD_IDX

BITS_FOR_METHOD_IDX

BITS_FOR_METHOD_IDX: number = 4

BITS_FOR_OCCURRENCE_IDX

BITS_FOR_OCCURRENCE_IDX: number = 4

DEFAULT_PARSER_CONFIG

DEFAULT_PARSER_CONFIG: IParserConfig = Object.freeze({recoveryEnabled: false,maxLookahead: 5,ignoredIssues: <any>{},dynamicTokensEnabled: false})

DEFAULT_RULE_CONFIG

DEFAULT_RULE_CONFIG: IRuleConfig<any> = Object.freeze({recoveryValueFunc: () => undefined,resyncEnabled: true})

END_OF_FILE

END_OF_FILE: EOF = new EOF()

EOF_FOLLOW_KEY

EOF_FOLLOW_KEY: any

IN_RULE_RECOVERY_EXCEPTION

IN_RULE_RECOVERY_EXCEPTION: string = "InRuleRecoveryException"

MANY_IDX

MANY_IDX: number = 3 << BITS_FOR_METHOD_IDX

MANY_SEP_IDX

MANY_SEP_IDX: number = 5 << BITS_FOR_METHOD_IDX

OPTION_IDX

OPTION_IDX: number = 2 << BITS_FOR_METHOD_IDX

OR_IDX

OR_IDX: number = 1 << BITS_FOR_METHOD_IDX

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

extendLazyToken

  • extendLazyToken(tokenName: string, patternOrParent?: any, parentConstructor?: Function): any
  • Parameters

    • tokenName: string
    • Default value patternOrParent: any = undefined
    • Default value parentConstructor: Function = LazyToken

    Returns any

extendSimpleLazyToken

  • extendSimpleLazyToken(tokenName: string, patternOrParent?: any): any
  • Parameters

    • tokenName: string
    • Default value patternOrParent: any = undefined

    Returns any

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

getEndColumn

getEndLine

getEndOffset

getImage

getStartColumn

getStartLine

getStartOffset

getTokenConstructor

  • Given a Token instance, will return the Token Constructor. Note that this function is not just for convenience, Because a SimpleLazyToken "instance' Does not use standard prototype inheritance and thus it's constructor cannot be accessed by traversing the prototype chain.

    Parameters

    Returns TokenConstructor

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.

tokenMatcher

  • A Utility method to check if a token instance of of the type of a specific Token class. Simply using instanceof is not enough because SimpleLazyToken Implementation does not use ECMAScript's built-in prototype inheritance.

    Parameters

    Returns boolean

tokenName

  • tokenName(clazz: Function): string

Generated using TypeDoc