Giter Site home page Giter Site logo

Comments (12)

PhilippeSigaud avatar PhilippeSigaud commented on July 18, 2024

Pegged now use indices internally, instead of always returning the entire input in the output. Can you tell me if you see any difference in speed?

from pegged.

alexrp avatar alexrp commented on July 18, 2024

I need to catch some sleep now, but I'll give it a test run tomorrow!

from pegged.

alexrp avatar alexrp commented on July 18, 2024

I'm not sure why, but my grammar broke after updating Pegged. Is there any way to get some sort of info on what went wrong?

The grammar in question: https://github.com/lycus/cursive/blob/master/src/cursive/parsing/grammar.d

from pegged.

PhilippeSigaud avatar PhilippeSigaud commented on July 18, 2024

My mistake for not informing you (I sent the message to other Pegged users but forgot to tell you): I dropped the non-standard space-consuming behavior of sequences. To get a space-munching sequence, use the 'space arrow': <. What you did with your grammar (Spacing everywhere) is correct, just drop the '>' operator in your RealSuffix and IntegerSuffix, it's not needed anymore.

The docs are updated.

Nice grammar btw. For such a big grammar I now prefer to write it in a file and import the file:

enum gram = "my grammar";

void main()
{
    asModule("program", gram);
}

and then

import gram;

// use it

It compiles for me, but I don't know what program to give it to parse.
I'm not sure I understand your comment code:

LineComment <: Slash Slash (&(EOL / EOI) (EOL / EOI) / .*)

Shouldn't it be:

LineComment <: "//" (!(EOL/EOI) .)* (EOL/EOI)

?

Then define locally (in your grammar) Spaces to be:

Spaces <: Spacing / LineComment / BlockComment

And replace Spacing by Spaces in your grammar. Not perfect, but at least comments won't get parsed and can be inserted anywhere a blank is called for.

from pegged.

alexrp avatar alexrp commented on July 18, 2024

Thanks for the explanation! I've fixed the grammar. Now I'm having another problem, though: Generating the grammar is pretty much impossible on my desktop system. DMD instantly reaches 100% CPU and consumes close to all memory in the system (16 GB!). Do you have any idea why this is happening? It's odd, because I can build the grammar just fine on a server machine.

I'm not sure I understand your comment code:

I remember I was having some problems with comments, but I forget the details. I'll look into that later.

from pegged.

PhilippeSigaud avatar PhilippeSigaud commented on July 18, 2024

I guess CTFE doesn't free memory as the runtime does. Did you try to write it as a module?

asModule("myGrammar", string peg);

then use it as a standard module:

import myGramar;

from pegged.

alexrp avatar alexrp commented on July 18, 2024

I can try that tomorrow, but I don't think that it will make a difference; the problem is the grammar() call, which asModule() does anyway.

from pegged.

PhilippeSigaud avatar PhilippeSigaud commented on July 18, 2024

On Thu, Mar 22, 2012 at 19:42, Alex Rønne Petersen
[email protected]
wrote:

I can try that tomorrow, but I don't think that it will make a difference; the problem is the grammar() call, which asModule() does anyway.

I thought you were doing it at compile-time previously.

from pegged.

alexrp avatar alexrp commented on July 18, 2024

Ah, of course, that one does the computation at runtime... proof right there that I needed sleep. ;)

I tried it out, and it works very well (grammar generated in less than two seconds, 3317 lines). I just can't help but wonder how the CTFE generation can eat so many resources... In any case, feature request: I'd like to be able to specify the exact file name in addition to the module name to asModule(). Doable? (I need this in order to integrate this grammar generation approach properly in my build process.)

from pegged.

alexrp avatar alexrp commented on July 18, 2024

And performance:

$ time ./test2 test3.crs
real    6m12.649s
user    6m11.279s
sys 0m0.076s

It seems to have gotten worse. :( FWIW, during the parsing process, it uses virtually no memory but sits at 100% CPU the entire process.

from pegged.

PhilippeSigaud avatar PhilippeSigaud commented on July 18, 2024

asModule(string moduleName, string fileName, string grammarString): OK done.

For the speed, can you send me your grammar and test file? I'm doing a new branch on internal optimizations and I'm curious to see if I see any effet.

([email protected])

from pegged.

PhilippeSigaud avatar PhilippeSigaud commented on July 18, 2024

I merged a speed-up branch a few weeks ago and obtained 1-2 orders of magnitude improvement in speed. Then using memoization can add up to 40% speed increase and some other thingies also added 20-40% increase.

I'll continue to find new ways to improve parsing speed.

from pegged.

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.