Options
All
  • Public
  • Public/Protected
  • All
Menu

chevrotain

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

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: TokenType[]

TokenMatcher

TokenMatcher: function

Type declaration

TokenVocabulary

TokenVocabulary: object | TokenType[] | IMultiModeLexerDefinition

lookAheadSequence

lookAheadSequence: TokenType[][]

Variables

Const END_OF_FILE

END_OF_FILE: IToken

Const EOF

Const defaultGrammarResolverErrorProvider

defaultGrammarResolverErrorProvider: IGrammarResolverErrorMessageProvider

Const defaultGrammarValidatorErrorProvider

defaultGrammarValidatorErrorProvider: IGrammarValidatorErrorMessageProvider

Const defaultParserErrorProvider

defaultParserErrorProvider: IParserErrorMessageProvider

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

EarlyExitException

  • EarlyExitException(message: string, token: IToken, previousToken: IToken): void
  • Parameters

    Returns void

MismatchedTokenException

  • MismatchedTokenException(message: string, token: IToken): void
  • Parameters

    • message: string
    • token: IToken

    Returns void

NoViableAltException

  • NoViableAltException(message: string, token: IToken): void
  • Parameters

    • message: string
    • token: IToken

    Returns void

NotAllInputParsedException

  • NotAllInputParsedException(message: string, token: IToken): void
  • Parameters

    • message: string
    • token: IToken

    Returns void

assignOccurrenceIndices

  • assignOccurrenceIndices(options: object): void
  • Parameters

    • options: object

    Returns 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

createSyntaxDiagramsCode

  • createSyntaxDiagramsCode(grammar: ISerializedGast[], __namedParameters?: object): string
  • Parameters

    • grammar: ISerializedGast[]
    • Optional __namedParameters: object
      • css: string
      • resourceBase: string

    Returns string

createToken

  • Parameters

    Returns TokenType

    • A constructor for the new Token subclass

createTokenInstance

  • createTokenInstance(tokType: TokenType, 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

    • tokType: TokenType
    • 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}}

hasTokenLabel

  • Parameters

    Returns boolean

isRecognitionException

  • isRecognitionException(error: Error): boolean
  • Parameters

    • error: Error

    Returns boolean

resolveGrammar

serializeGrammar

serializeProduction

tokenLabel

  • This can be used to improve the quality/readability of error messages or syntax diagrams.

    Parameters

    • clazz: TokenType

      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. This utility is needed because Chevrotain tokens support "categories" which means A TokenType may have multiple categories, so a TokenType for the "true" literal in JavaScript May be both a Keyword Token and a Literal Token.

    Parameters

    Returns boolean

tokenName

  • tokenName(obj: TokenType | Function): string
  • Parameters

    Returns string

validateGrammar

Generated using TypeDoc