Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "chevrotain.d"

Index

Type aliases

CstChildrenDictionary

CstChildrenDictionary: object

Type declaration

CstElement

CstElement: IToken | CstNode

CustomPatternMatcherFunc

CustomPatternMatcherFunc: function

The type of custom pattern matcher functions. Matches should only be done on the start of the text. Note that this is similar to the signature of RegExp.prototype.exec

This should behave as if the regExp match is using a start of input anchor. So: for example if a custom matcher is implemented for Tokens matching: /\w+/ The implementation of the custom matcher must implement a custom matcher for /^\w+/.

The Optional tokens and groups arguments enable accessing information about previously identified tokens if necessary.

This can be used for example to lex python like indentation. see: https://github.com/SAP/chevrotain/blob/master/examples/lexer/python_indentation/python_indentation.js for a fuller example

Type declaration

    • (test: string, offset?: number, tokens?: IToken[], groups?: object): RegExpExecArray
    • Parameters

      • test: string
      • Optional offset: number
      • Optional tokens: IToken[]
      • Optional groups: object

      Returns RegExpExecArray

GrammarAction

GrammarAction: function

Type declaration

    • (): OUT
    • Returns OUT

IAnyOrAlt

IAnyOrAlt: IOrAlt<T> | IOrAltWithGate<T>

ISeparatedIterationResult

ISeparatedIterationResult: object

Type declaration

  • separators: IToken[]
  • values: OUT[]

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

TokenInstanceIdentityFunc

TokenInstanceIdentityFunc: function

Type declaration

    • Parameters

      Returns string

TokenMatcher

TokenMatcher: function

Type declaration

Variables

defaultErrorProvider

defaultErrorProvider: IErrorMessageProvider

This is the default logic Chevrotain uses to construct error messages. When constructing a custom error message provider it may be used as a reference or reused.

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

    • Optional value: T

    Returns function

      • (): T
      • Returns T

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

createToken

  • Parameters

    Returns TokenConstructor

    • A constructor for the new Token subclass

createTokenInstance

  • createTokenInstance(tokClass: TokenConstructor, image: string, startOffset: number, endOffset: number, startLine: number, endLine: number, startColumn: number, endColumn: number): IToken
  • Utility to create Chevrotain Token "instances" Note that Chevrotain tokens are not real instances, and thus the instanceOf cannot be used.

    Parameters

    • tokClass: TokenConstructor
    • image: string
    • startOffset: number
    • endOffset: number
    • startLine: number
    • endLine: number
    • startColumn: number
    • endColumn: number

    Returns IToken

    {{image: string, startOffset: number, endOffset: number, startLine: number, endLine: number, startColumn: number, endColumn: number, tokenType}}

extendToken

  • extendToken(tokenName: string, patternOrParent?: any, parentConstructor?: Function): TokenConstructor
  • deprecated
    • Use the new CreateToken API

    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

    • Optional patternOrParent: any

      RegExp Pattern or Parent Token Constructor

    • Optional parentConstructor: Function

      The Token class to be extended

    Returns TokenConstructor

    • A constructor for the new extended Token subclass

getTokenConstructor

  • Given a Token instance, will return the Token Constructor. Note that this function is not just for convenience, Because a Token "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
  • Parameters

    • clazz: Function

    Returns 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 for a Token if it exists.

tokenMatcher

  • A Utility method to check if a token is of the type of the argument Token class. Not that while this utility has similar semantics to ECMAScript "instanceOf" As Chevrotain tokens support inheritance.

    It is not actually implemented using the "instanceOf" operator because Chevrotain Tokens have their own performance optimized inheritance mechanism.

    Parameters

    Returns boolean

tokenName

  • tokenName(clazz: Function): string
  • Parameters

    • clazz: Function

    Returns string

Generated using TypeDoc