-
Notifications
You must be signed in to change notification settings - Fork 72
Tidy the SAWCore parser #2331
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
Tidy the SAWCore parser #2331
Conversation
No functional change intended. Part 1; part 2 with purely whitespace will follow separately to make it easier to audit the overall changes.
(part 2 of legibility cleanup)
Previously, if you wrote "module where" at the top of a SAWCore file (instead of "module Foo where"), it was accepted by the grammar and then called Haskell "error" to bail out. Fix the grammar so this is a parse error, and change the error call involved to a panic. This degrades the message printed a bit, maybe, since there's no longer an explicit "empty module name" message; but it now includes the offending source position, which is quite a bit more important. Add a test. Note that the source position prints as rubbish; that's a different problem (#2140)
It's important for readability to keep the grammar and the actions visually separate, but also good to not become super-wide when doing so.
| IdentRec { Recursor Nothing $1 } | ||
| 'Prop' { Sort (pos $1) propSort noFlags } | ||
| Sort nat { Sort (pos $1) (mkSort (tokNat (val $2))) (val $1) } | ||
| AtomTerm '.' Ident { RecordProj $1 (val $3) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The { Sort (pos $1) (mkSort (tokNat (val $2))) (val $1) }
part is indented differently from the others—intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's so it fits the advertised edit width. Which isn't obvious from here.
'data' Ident VarCtx ':' LTerm 'where' '{' list(CtorDecl) '}' { DataDecl $2 $3 $5 $8 } | ||
| 'primitive' Ident ':' LTerm ';' { mkPrimitive $2 $4 } | ||
| 'axiom' Ident ':' LTerm ';' { mkAxiom $2 $4 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment here about { DataDecl $2 $3 $5 $8 }
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And that's to avoid indenting all the others by one more just because the LHS doesn't quite fit. I guess currently indenting all the others by one more would still fit the edit width (I think that wasn't true up front) so I could change it if you object strongly.
Make it more legible, fix a couple minor problems found while doing so.