Comments (2)
Hi 👋
I think you're right. Your second example creates a parser that cannot parse a newline (but does not parse anything else), and then that parser succeeds at failing to parse the newline. However, there is still text to parse, so parjs throws an error (you must handle all input by default).
You have two options:
it("can parse with anyChar()", () => {
const p = newline().pipe(not(), qthen(anyChar()));
expect(p.parse("a")).toBeSuccessful("a");
expect(p.parse("\n")).toBeFailure(ResultKind.SoftFail);
});
it("can parse with must", () => {
const p = anyChar().pipe(must(c => c !== "\n" || { kind: "Soft" }));
expect(p.parse("a")).toBeSuccessful("a");
expect(p.parse("\n")).toBeFailure(ResultKind.SoftFail);
});
from parjs.
Closing this as it's been inactive for some weeks now. Feel free to reopen if needed.
from parjs.
Related Issues (20)
- Proposal - venturing outside the Basic Multilingual Plane
- Proposal - parser and combinator modifiers HOT 3
- StringLen parser uses substring incorrectly, leading to incorrect results HOT 1
- Publishing new versions is broken on the master branch HOT 1
- docs: add a friendly guide for users
- docs: create documentation explaining how to create new parsers
- refactor: replace overloaded functions with mapped types HOT 1
- Reconsider “quiet” parsers
- refactor: Get rid of namespaces HOT 1
- Debugging feature: textual descriptions for parsers HOT 2
- Debugging feature: a zero key
- docs: add performance comparison to other parsing techniques
- test: assert parser positions after combinator failures
- test: add type level tests HOT 2
- feature: Case insensitive string parsing HOT 4
- Example of custom parser from `README.md` doesn't work HOT 4
- Releasing a new version is having challenges HOT 4
- Main documentation describes an upcoming version instead of the current one HOT 1
- More unicode support for character parsing: `anyUniCharOf` and `uniCharCodeWhere` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from parjs.