Comments (5)
Hi Shahar,
Good job with the Chevrotain library.
Here is what I felt was missing from the Parsimmon library:
- Rule definitions were more complex and not as easy to read for a JavaScript programmer than I think they could/should be: compare https://github.com/cdiggins/myna-parser/blob/master/grammars with https://github.com/jneen/parsimmon/tree/master/examples
- Slower than I would have liked (https://sap.github.io/chevrotain/performance/)
- Lacking some debugging tool: e.g. pretty printing of grammar, printing of the AST structure
- I was not able to figure out how to control the shape of the generated parse tree
- I did not like the reliance on regular expressions for primitive parsers
- Missing some common useful low-level parsers.
from myna-parser.
Thanks for your feedback @cdiggins
Rule definitions were more complex and not as easy to read for a JavaScript programmer than I think they could/should be: compare https://github.com/cdiggins/myna-parser/blob/master/grammars with https://github.com/jneen/parsimmon/tree/master/examples
Yes comparing the JSON myna and JSON parsimmon examples there is a big advantage
in conciseness and clearness to myna.
Slower than I would have liked (https://sap.github.io/chevrotain/performance/)
Relatively or absolutely? Parsimmon is the 2nd faster on latest Chrome (V8).
which browser did you run the benchmark on? If you are using Safari, it has
severe regExp performance bugs that affect that benchmark.
Lacking some debugging tool: e.g. pretty printing of grammar, printing of the AST structure.
That is one of my main grips with parser combinators, I can't just place a breakpoint and debug
The code using standard means (step over/step into/...).
I did not like the reliance on regular expressions for primitive parsers
I see your point.
// easier to understand - Myna
this.fraction = m.seq(".", m.digit.zeroOrMore);
this.plusOrMinus = m.char("+-");
this.exponent = m.seq(m.char("eE"), this.plusOrMinus.opt, m.digits);
this.number = m.seq(this.plusOrMinus.opt, m.integer, this.fraction.opt, this.exponent.opt).ast;
// harder to read - Parsimmon (RegExps)
var numberLiteral =
token(P.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/))
.map(Number)
.desc('number');
//
from myna-parser.
It would be interesting to see how fast you can get Myna.
It looks like you may have two self imposed constraints in terms of performance:
by avoiding RegExps and also avoiding code generation.
from myna-parser.
Thanks for your feedback @bd82! I am going to be working hard on performance once I get a couple more grammars and tools built using Myna completed. I have a hypothesis that I can get a big boost to performance by applying rule rewriting during the RegisterGrammar
step which is akin to the performSelfAnalysis
used by Chevrotain parsers. Basically I will flatten nested rules where possible and use the lookahead rules which are hard to write but have better performance.
from myna-parser.
applying rule rewriting during the RegisterGrammar step which is akin to the performSelfAnalysis used by Chevrotain parsers. Basically I will flatten nested rules where possible and use the lookahead rules which are hard to write but have better performance.
Well you could possibly do more optimizations than Chevrotain because Myna seems to be
a more interpreted solution, Chevrotain augments an hand built parser to be easier to write.
So no rule rewriting can be done, only trying to find the fastest way to run the user's code.
You can try profiling a benchmark scenario using IRHydra2
http://mrale.ph/irhydra/2/
It can show you functions that have not been optimized by V8 and the reasons why.
This has allowed me to find a little trick to double Chevrotain's performance...
(Avoid creating new Parser instances).
from myna-parser.
Related Issues (20)
- explainjs listed as dependency
- Possible performance degradation under Chrome Canary 61 HOT 2
- Feature request: Karma and QUnit HOT 7
- Possible performance improvements HOT 2
- Add return types to standalone functions
- 2.4.0 no longer works in the browser. HOT 8
- Case insensitive keywords? HOT 5
- Myna module improperly exported
- Error recovery and continuation
- 2 small mistakes in the sample code in readme.md
- typescript declaration file absent
- Sample Usage of Myna in TypeScript HOT 7
- ParserError messages don't seem to be propogated HOT 3
- Question: how to check in sequence if there is a whitespace + symbol
- Example in the README file does not work out of the box.
- How to *use* ? HOT 7
- delay() rule ID number changes each time HOT 4
- Create railroad diagrams HOT 4
- Add Myna to JavaScript performance benchmarks HOT 2
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 myna-parser.