Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a parser as python code #20

Open
KOLANICH opened this issue Nov 23, 2017 · 6 comments
Open

Generate a parser as python code #20

KOLANICH opened this issue Nov 23, 2017 · 6 comments
Labels

Comments

@KOLANICH
Copy link
Contributor

Parglare is damn slow. Generating parser is also damn slow. It may be useful both from speed and debug perspective to serialize the generated parser into a python file.

@igordejanovic
Copy link
Owner

Parser table serialization is something that I plan to do soon.

What have you tried to do and get slow parsing? Which parser did you use? LR or GLR? parglare is not optimized yet but for my use-cases is fast enough. Maybe you are using GLR and have a lot of non-determinism in the grammar so parglare builds a lot of trees, i.e. investigates a lot of possible interpretations. I can't help any further without more input.

@KOLANICH
Copy link
Contributor Author

KOLANICH commented Nov 24, 2017

I'm using LR for a grammar more complex than a simple expression language. In fact I have converted a LL(?) grammar (more than 200 lines) for CoCo/R into parglare one because it used some extensions I have not found in publicly available implementations of CoCo/R, such as "zero or more repeats". A try of "compile grammar" -> "gen parser" -> "test on file" pipeline takes nearly a minute with cpython on the hardware available to me at work (I remember that the CPU is some Celeron with SSE2, but without x86_64 ). There are some ambiguites, I know that I would have to use glr somewhen, but it is slow even in LR mode.

@igordejanovic
Copy link
Owner

igordejanovic commented Nov 24, 2017

How big is the file you are parsing? For LR you should have at least 300Kb/sec more-less depending on the language. GLR has additional overhead and is at the moment approximately 5 times slower.

Can you publicly share your code, grammars, input files? If not can you do some measurements like time needed for the parser to initialize, parsing speed in Kb/sec.
I haven't yet optimized parglare extensively but I'm keeping an eye on performance so I would like to take a look.

@KOLANICH
Copy link
Contributor Author

KOLANICH commented Nov 24, 2017

importing a grammar takes 1.3 sec, generating a parser takes 154 sec .

@igordejanovic
Copy link
Owner

igordejanovic commented Sep 13, 2018

Related to #52 and #36

@igordejanovic
Copy link
Owner

First version of table caching is on the master branch. Please see the updates in the HISTORY.md and the docs. Please test with your code and let me know it you have any trouble.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants