Giter VIP home page Giter VIP logo

Comments (4)

cdiggins avatar cdiggins commented on May 28, 2024

I'm so sorry for the delay, somehow my Git notifications are not getting classified correctly. I need to change my email settings. I will need to get back to you on this in the evening.

PS: I am doing some heavy optimization in another branch, so far seeing very dramatic speed ups.

from myna-parser.

elidoran avatar elidoran commented on May 28, 2024

It's alright, I understand, we're all busy. I have plenty to do until you have time to get back to me on this. I'm mostly playing around with this stuff.

I'm glad to hear there are improvements on the way because:

  1. enhancements always seem to be an adventure
  2. I've been running a JSON parsing comparison of Myna, Chevrotain, Parsimmon, and a state machine processor I'm working on and Myna has been performing on the low end. I was waiting to hear about this Delay thing before mentioning it, but, you brought it up, so I thought I'd throw it out there.

Have a good day.

from myna-parser.

cdiggins avatar cdiggins commented on May 28, 2024

@elidoran I removed IDs in the latest version of Myna. In order to achieve what you wanted originally, would require that you augment your parse tree after creation with IDs created from the names. I hope this doesn't make your work too much harder.

from myna-parser.

elidoran avatar elidoran commented on May 28, 2024

Well, that's one way to go :)

Adapting it was easy. Instead of using the ID's it made I simply assigned ID's to them.

The Delay was still a problem tho. It is called more than once instead of resolving the first time.

So, I cached the choice() it is creating to return in the subsequent call.

Also, the first AST node matching the delayed rule does not have the ID set in its rule. So, I have to match that via its name the first time. After that, it has the ID on it.

Relevant part:

var choice
thing = M.delay(function() {
  console.log('delay()')
  return choice || (choice = M.choice(...))
})
other = M.blah()

thing.id = 1
other.id = 2

// in AST tree evaluator
switch (ast.rule.id) {
  case 1:
    // thing: ast.rule.id is 1 the second and later times
    console.log('later match ast.rule.id', ast.rule.id)
    break;
  case 2: /* other */ break;
  default:
    if (ast.rule.name === 'thing') {
      // ast.rule.id is undefined the first time only.
      // the next time it'll have the 1.
      console.log('first match ast.rule.id is', ast.rule.id)
    }
}

What I see for output is:

delay()
delay()
first match ast.rule.id is undefined
later match ast.rule.id 1

So, this is better. It only does delay() twice now and the ID works from the second time on.

Also, the newer version is faster. Great job.

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.