Giter VIP home page Giter VIP logo

Comments (5)

cdiggins avatar cdiggins commented on May 28, 2024

Hi Shahar,

Good job with the Chevrotain library.

Here is what I felt was missing from the Parsimmon library:

from myna-parser.

bd82 avatar bd82 commented on May 28, 2024

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.

bd82 avatar bd82 commented on May 28, 2024

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.

cdiggins avatar cdiggins commented on May 28, 2024

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.

bd82 avatar bd82 commented on May 28, 2024

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)

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.