Code Monkey home page Code Monkey logo

rudus's People

Contributors

bikossor avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rudus's Issues

Add anyOf combinator

  • Takes an array of parsers and tries to match them sequentially
  • Returns the first successful one

TypeError: object null is not iterable

This happens with the regex, word and whitespace parser when they can't match.

D:\Git\Railgun\dist\parser\regex.js:6
    const [fullMatch] = searchString.exec(state.input.slice(state.offset));
                        ^

TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
    at Parser.transformState (D:\Git\Railgun\dist\parser\regex.js:6:25)
    at Parser.transformState (D:\Git\Railgun\dist\combinators\sequenceOf.js:10:32)
    at Parser.run (D:\Git\Railgun\dist\Parser.js:9:21)
    at Object.<anonymous> (D:\Git\Railgun\main.js:9:29)
    at Module._compile (internal/modules/cjs/loader.js:1201:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1221:10)
    at Module.load (internal/modules/cjs/loader.js:1050:32)
    at Function.Module._load (internal/modules/cjs/loader.js:938:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

Add the endOfInput parser

This parser checks if the state.input.slice(state.offset) still contains something, if so it fails.

Add endOfLine parser

This would be equivalent of the regex (\r\n|\r|\n) but the match won't get captured.

Add separatedBy combinators

  • separatedBy (value, separator)
    • if the value parser fails, sepBy will fail too
    • if value parses an empty string, sepBy won't fail
    • if value parses just a separator, sepBy will fail

Add the many1 combinator

The many1 combinator tries as many times as possible but at least once to parse a given parser otherwise it fails.

Introduce `between` combinator

  • outerLeft, outerRight and inner parser
  • outerRight defaults to outerLeft
  • all parsers needs to successfully match, otherwise it fails
  • only the result of the inner parser will be captured

Improve require path of the `example-01`

From

const { whitespace, endOfInput, string } = require("../dist/cjs/parser/index");
const { sequenceOf } = require("../dist/cjs/combinators/index");

to

const { whitespace, endOfInput, string } = require("rudus");
const { sequenceOf } = require("rudus");

Update README

With descriptions of the parsers and combinators.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.