Nonlinear Performance Magnification

    rudus
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0-alpha.11 • Public • Published

    Rudus

    Parser combinator library for TypeScript.

     

    API

    Parsers

    • number
      • Tries to match a given number
    • string
      • Tries to match a given string
    • regex
      • Tries to match a given regex
    • whitespace
      • Tries to match one or more whitespaces (regex: /[\r\n\t\f\v ]+/)
    • word
      • Tries to match one or more words (regex: /[a-zA-Z0-9_]+/)
    • endOfInput
      • Checks if there is nothing left to parse otherwise it fails
    • endOfLine
      • Tries to match an end of line (either \r\n, \r or \n)
    • lazy
      • Takes a function that just returns a parser (a thunk). This defers the evaluation of the given parser. Useful for writing recursive parsers.
    • failure
      • Always returns a failing parser with the given errorMessage. Typically used inside a contextual parser.

    Combinators

    • sequenceOf
      • Accepts multiple parsers, which must all match successfully in the given order otherwise it fails.
    • many
      • Accepts a single parser, which may match zero or infinite times.
    • many1
      • Accepts a single parser, which must match at least once or infinite times otherwise it fails.
    • separatedBy
      • Tries to match a given value separated by a given separator
      • Only captures the value
    • anyOf
      • Tries to match all parsers and returns the first successful one.
    • optional
      • The given parser may or may not match. This combinator can not fail.
    • between
      • Tries to match a given inner surrounded by a given outerLeft and outerRight. The outerRight parser is optional and defaults to outerLeft.

    Install

    npm i rudus

    DownloadsWeekly Downloads

    12

    Version

    1.0.0-alpha.11

    License

    GPL-3.0

    Unpacked Size

    79 kB

    Total Files

    72

    Last publish

    Collaborators

    • bikossor