Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stagas/lexer-next

lexer for recursive descent parsers
https://github.com/stagas/lexer-next

iterable iterator lexer parser parsing recursive-descent-parser regexp regexp-match tokenizer

Last synced: 14 days ago
JSON representation

lexer for recursive descent parsers

Awesome Lists containing this project

README

        


lexer-next

lexer for recursive descent parsers



npm i lexer-next

pnpm add lexer-next

yarn add lexer-next

## API

# createLexer(tokenize) src/index.ts#L106

    # tokenize


    createLexer(tokenize)  =>



      # (input)

        # input


          string


        (input)  =>





# LexerErrorCauses src/causes.ts#L1 # LexerError src/index.ts#L15 # stackTraceLimit

    number

# captureStackTrace(targetObject, constructorOpt)

    # targetObject


      object

    # constructorOpt

      Function


    captureStackTrace(targetObject, constructorOpt)  =>


      void
# RegExpToken

    # constructor(pattern)


# Token # is(group, value)

    # group


      string

    # value

      string


    is(group, value)  =>


      boolean
# toJSON() # create(value, group, source) # Lexer src/index.ts#L46 # advance() src/index.ts#L50 # expect(group, value) src/index.ts#L77

    # group


      string

    # value

      string


    expect(group, value)  =>


# filter(fn) src/index.ts#L87 # onerror(fn) src/index.ts#L82 # peek() src/index.ts#L59


    peek()  =>


    # group

      string


    # value

      string

    peek(group, value)  =>


# RegExpMatchArrayLike

    # index


      number

    # input

      string


# TokenJson

    # group


      string

    # source

      {


      # index


        number

      # input

        string

      # match

        string []

      }

# value

    string

# ErrorHandler src/index.ts#L31 # FilterFunction src/index.ts#L39

    # (token)

      # token


      (token)  =>


        boolean

# LexerFactory src/index.ts#L95

    # (input)

      # input


        string


      (input)  =>



# Tokenizer src/index.ts#L41

    # (input)

      # input


        string


      (input)  =>



        IterableIterator<RegExpMatchArray>

# createLexer(tokenize) src/index.ts#L106

    # tokenize


    createLexer(tokenize)  =>



      # (input)

        # input


          string


        (input)  =>



## Credits
- [match-to-token](https://npmjs.org/package/match-to-token) by [stagas](https://github.com/stagas) – transform a RegExp named group match to a more useful object

## Contributing

[Fork](https://github.com/stagas/lexer-next/fork) or [edit](https://github.dev/stagas/lexer-next) and submit a PR.

All contributions are welcome!

## License

MIT © 2022 [stagas](https://github.com/stagas)