Comments (5)
No worries! I'll do some of my own digging and post any updates here.
from parser-ts.
@benrbray - I tracked down the issue. Essentially, the issue stems from the Parser
's many
combinator, which is used internally by the many
combinator in the string
module. This combinator has been notorious for causing issues with infinite recursion in the past.
I believe I have figured out a fix to the recursion issue which allows the many
combinators to handle infinitely large iterations. Will be pushing a PR soon.
from parser-ts.
Hey @benrbray! Thanks for letting us know!
Unfortunately, I am unable to replicate the recursion issue. For context, here is a CodeSandbox containing the code you posted above. If you check the console, you'll see that all four parsers run as expected.
In addition, we have regression tests in place for the fix for #41 that are currently passing:
Lines 30 to 42 in 4d58e69
Could you perhaps provide more context?
from parser-ts.
Thanks for the quick reply! I think this will be slightly system- and browser-dependent. I tested in a few different environments:
- Ubuntu / Chrome v87 -- stack overflow at string length 1000
- Ubuntu / Firefox v1.0 -- works at length 1000, stack overflow at 2000
- Windows 10 / Chrome v89 -- works at length 1000, stack overflow at 2000
- MacOS / Safari 14 via BrowserStack -- works at length 1000, stack overflow at 2000
Are you able to reproduce the error on strings of say, length 10000
?
As for solutions, I haven't dug too much into the parser-ts
internals yet, but I wonder if it's possible to write a many sat
function specialized to strings that avoids recursion by directly iterating over characters. I'm not sure whether that sort of approach would be compatible with Stream
, though.
from parser-ts.
Hey @benrbray - I was in fact able to replicate it when I increased the string length to 10,000. However, I am not really sure where the errors are originating from. I will need to do some further work on this but don't have too much time in the near future so this one might take a bit.
from parser-ts.
Related Issues (20)
- New Feature: notString and notOneOf (string)
- [Feature Request] Expose modules without lib/es6 prefix HOT 5
- export run from test/helpers.ts HOT 1
- Design Question: Stream with Positioned Tokens HOT 2
- Feature Request: manyTill and many1Till HOT 2
- Reci HOT 1
- `doubleQuotedString` hits recursion limit on longer strings HOT 3
- Fatal error from filter HOT 7
- How to skip some parts HOT 5
- P.either should fail with fatal error, if second parser failed with fatal, or should it? HOT 2
- RangeError: Maximum call stack size exceeded HOT 2
- [feature] repeat – many in terms of semigroup/monoid HOT 1
- Import path problem in using ESM feature typescript@next HOT 1
- How to handle left-recursive grammar with parser-ts HOT 2
- Support for NodeJS Buffer HOT 1
- How to compose and handle Optional types in parsers? HOT 3
- Combination of alt and many runs infinitely
- Add hexDigit combinator
- Can @babel/code-frame be avoided?
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 parser-ts.