Comments (12)
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.
I need to catch some sleep now, but I'll give it a test run tomorrow!
from pegged.
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.
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.
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.
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.
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.
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.
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.
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.
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.
from pegged.
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)
- is it okay for the D grammar to compile in 10 minutes and use 45 gigs of ram? HOT 14
- Run-time parsing of Peg grammars HOT 1
- qualifiedIdentifier in dgrammar.d is not defined HOT 2
- Add equivalent of “important” blocks? HOT 3
- Release 0.4.5 HOT 2
- `pure` and `@safe` grammars/rules? HOT 3
- Can't fix this failure. HOT 2
- Grammar won't parse whole text, it stops short a few lines... HOT 1
- Comment syntax HOT 7
- Unwanted space consumption in rule parameter
- Syntax wrappers HOT 1
- How does one do Intellisense using a Pegged grammar? HOT 3
- Is there a way to break up a grammar into D classes, each with their own data to parse into & thus subgrammar? HOT 2
- I can't find the Wikipedia ParseTree handling code in the Pegged wiki any more... HOT 1
- Will there be a speed-up when using a Dlang switch-case and shorter pegged variable names? HOT 2
- Can we create a grammar induction algorithm based upon expected Pegged parsing failures? HOT 2
- How do you use dub + pegged + asModule? HOT 1
- Bump new version HOT 7
- Remove obsolete CI.
- How do you branch on complex names such as caseSensitiveLiteral!("let") (they get much more complicated) 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 pegged.