Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Grammar<T>

Central interface for microgrammar usage. Represents a microgrammar that we can use to match input in a string or stream.

Type parameters

  • T

Hierarchy

Implemented by

Index

Properties

Optional $id

$id: string

Methods

exactMatch

  • Return a match if it explains the whole of the input. This style of usage is more like a traditional parser, building an AST for a whole file.

    deprecated

    use perfectMatch; wrap in toPatternMatchOrDismatchReport if needed

    Parameters

    • input: string | InputStream
    • Optional parseContext: object

      context for the whole parsing operation

    • Optional l: Listeners

      listeners observing input characters as they are read

    Returns PatternMatch & T | DismatchReport

findMatches

  • Convenience method to find matches. Note that this will parse the entire input in one pass. Use matchIterator if you are likely to try to stop part-way through, or want to be kinder to the event loop.

    Parameters

    • input: string | InputStream
    • Optional parseContext: object

      context for the whole parsing operation

    • Optional l: Listeners

      listeners observing input characters as they are read

    Returns Array<T & PatternMatch>

firstMatch

  • Convenient method to find the first match, or null if not found. Stops searching after the first match.

    Parameters

    • input: string | InputStream
    • Optional l: Listeners

      listeners observing input characters as they are read

    Returns PatternMatch & T | null

matchIterator

perfectMatch

  • Return a match (or failure to match) with all structural information including matches that succeeded, and matches that failed

    Parameters

    • input: string | InputStream
    • Optional parseContext: object

      context for the whole parsing operation

    • Optional l: Listeners

      listeners observing input characters as they are read

    Returns MatchReport

    MatchReport

Generated using TypeDoc