Comments (5)
Hi Brett,
The characters package is great, I've already converted some of my other code to use it. For example, the more package uses it for its configurable printers. I've also tried to use it for the char_matcher in the same package (which is used in similar form in PetitParser), with less success. I found it challenging to implement character-based predicates efficiently, for example character ranges or character sets (whitespaces, letters, digits, lower-case, upper-case, ...).
PetitParser needs random access to characters. It currently does it mostly through codeUnitAt
, however the original implementation in Smalltalk used something similar to CharacterRange to navigate forward and backward through the input. I expect this could easily be adopted in Dart.
What I am more concerned about is performance: I expect moveNext
, current
and copy
to be the most frequently called methods. They all execute quite a bit of code, and most of them also allocate new objects. In version 2.2.0 I introduced a fast-parse mode that avoids memory allocations during parsing, which brought a huge speed improvement on some inputs for lexer-like matching. Not sure how this could be adopted with characters?
from dart-petitparser.
I'm sure we'd love some feedback at https://github.com/dart-lang/characters if you have a chance =)
from dart-petitparser.
Now after more than a year, is there any Unicode support available? We are in 2021 and Unicode support is really required.
from dart-petitparser.
This library is designed to parse over streams of bytes (or UTF-16 characters), and as such it is agnostic to the encoding of your input. For example, the xml library is successfully parsing unicode input without the need for either of the libraries to "understand" the underlying characters.
While I understand that out of the box decoding would be desirable, it comes at a hefty cost in performance. So far I haven't seen a compelling need to support it natively. A real-world use-case where the current infrastructure doesn't work would definitely help to motivate investing time into this issue.
from dart-petitparser.
To only slightly hijack this thread, I'm wondering if it's possible to use the higher-level logic provided by the parser to extract values out of an arbitrary jsonDecode. It'd be nice if I could specify a pattern of a json object containing some strings and bools and a json list of further objects, and then the .map action could map that into a Dart object via a constructor. I suspect it's only a matter of coming up with a useful set of primitives, and then using the rest of the mechanics without change, but if there's been any thought about this, I'd be interested. I know the switch stuff makes some of this easier, but it still doesn't feel as satisfying as just writing a composable Parser rule.
from dart-petitparser.
Related Issues (20)
- how do I provide better error messages? HOT 1
- Translate JS/TS to Dart? HOT 5
- Alternative to trim parser or how to discard HOT 2
- Relevance of `refX`? HOT 1
- Broken link for linter rules HOT 1
- Eliminate dynamic calls
- How to upgrade? HOT 7
- Getting line and colone in the code. HOT 2
- Improve error reporting of `ExpressionPaser` HOT 1
- Consider rolling meta back to ^1.8.0 HOT 1
- Greedy parse problem HOT 2
- Higher Unicode planes support? HOT 2
- Collecting Parsed result and passing it to next product HOT 1
- Possible alternative use of switch that might be fast enough HOT 3
- ReferenceParser prevents repeatString optimization HOT 1
- Projects that are using PetitParser HOT 1
- Parsing Latin1 characters HOT 4
- Alternative to deprecated `separatedBy(separator, includeSeparators: false)` HOT 2
- Choice parser behavior HOT 2
- use petitparser to recognize jsonDecode output 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 dart-petitparser.