-
Notifications
You must be signed in to change notification settings - Fork 170
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
EBNF-style grammar for Souper's text format? #782
Comments
looks good at a quick scan! yes, we'd be happy to have a text version of this in the repo, but I'd prefer if it was one that could be reasonably checked against the souper parser, for example by some differential testing (that I'd be likely to find a bit of time to work on) |
To clarify: you mean differential testing the hand written parser vs. a parser mechanically generated from the grammar with yacc (or similar)? |
ideally, running a yacc-equivalent tool on the grammar and then doing some testing to see if it accepts the same set of strings as the souper parser does though now that I think about it this might not be easy since the souper parser also does typechecking etc. |
Yeah but we should at least be able to do it unidirectionally:
|
FWIW, my library lives at https://github.com/fitzgen/souper-ir and can now deterministically round-trip every I also updated the grammar in the OP based on some changes I found while implementing my library. |
Also, my parser is hand-written as well. Not mechanically generated from the grammar.. |
The grammar I originally wrote here allows lines like this:
specifically because it has the production
but it seems that souper doesn't actually allow lines where you assign a constant value to a variable. Would this be difficult to support? |
I don't think so, but here we're sort of just following LLVM which also disallows this. Is it hard for you to push these constants into the uses, so we don't have to define values of constant type? |
Not too hard, I think I actually have it working already. Will need to publish a breaking change of the |
I've got everything parsing okay now -- how can I verify whether souper is successfully populating redis? This is the first time I've ever used redis, but I would expect that the
|
your command is close to correct-- please remove |
if you want to populate the cache but not do synthesis I think |
Does this not support parsing multiple LHSes from one file?
|
I'm pretty sure it's supposed to, please drop your file (or at least the first two LHSs in it) here and I'll look at it later |
Thanks for your help! First few LHSes are:
Full files: |
I'm guessing you're missing an option that makes souper expect (only) LHSs, but I don't know what it is right now sorry our command lines are such a mess, use cases for these tools has drifted over time ugh |
Hello! I am writing a parser and stringifier for Souper's text format, and it would have been super helpful to me if there was a grammar when I started, so I've been sketching a hopefully-mostly-correct grammar as I go. I think it is fairly complete at this point. I was hoping to share it with y'all to see if there are any obvious bugs in the grammar, and ask whether you're interested in merging this into the repo's docs (and improving it to more exactly match Souper's parser / maintaining it over time as the text format changes).
EBNF-esque grammar for Souper's Text Format
(Note that I have not fed this grammar through any mechanical tool like yacc, and it is in a bit of a EBNF pseudocode rather than any particular dialect accepted by any particular tool.)
The text was updated successfully, but these errors were encountered: