-
Notifications
You must be signed in to change notification settings - Fork 28
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
Pp imrovements #470
Pp imrovements #470
Conversation
Thanks, that's very useful. Two comments: The commits don't seem to include the css file. The pretty-printing has to be in sync with CN's parser:
|
I didn't know that we had surface notation for updating structs, I'll update the printer to match. For I modified the CSS file in More generally on the properties of the pretty-printer:
|
Thanks! I think we use the same notation for both structs and records.
That's something we're considering – I think there should be an open issue related to that: it would make for a better user interface, because
Ah, sorry, I missed that.
Thanks! I wasn't aware of that mismatch, then we should fix those at some point.
Good point. Here, too, we should make the pretty-print produce the same output. Though here this might require us to remember the C-type annotation on the array shift from the frontend for the
Everything, I'd say. If we're not already doing that (including the places you listed) that's a bug. |
I think we probably don't want to make changes to the parser until #342 is merged. How do you want to proceed?
|
My opinion: it’s high impact to make the pretty printed output more readable. So we should merge this change now, and plan to align the parser later once #342 is merged. On Aug 8, 2024, at 11:38 AM, Iavor S. Diatchki ***@***.***> wrote:
I think we probably don't want to make changes to the parser until #342 is merged. How do you want to proceed?
We could keep the syntax changes (e.g., &p->x) with the plan to also update the parser after #342 is merged
I could undo them (reverting back to member_shift) but we'd still get the fewer parens
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
* This changes the `atomic` boolean parameter to a `prec` integer parameter specifying the precedence of the surrounding context. * We also change how some things are printed: - a lot fewer parens, based on precedence - suffix of numeric literals is separated by `'` (see also #337) - pointers are printed in base 16 - use `NULL` instead of `null` to match CN's input notation - custom printing for negated comparisons `x != y` instead of `!(x == y)` - use `%` instead of `rem` - use `^` instead of `xor_uf` - use `&` instead of `bw_and_uf` - use `|` instead of `bw_or_uf` - use `<<` instead of `shift_left` - use `>>` instead of `shift_right` - use `{ ...s, x = e }` for updating things. This is borrowed from JavaScript but it makes the precedence story simpler. - use `&p->x` instead of `member_shift<T>(p,x)` - use `&p[x]` instead of `array_shift<T>(p,x)` - use `cons(x,xs)` instead of `x :: xs`
To set field `x` of struct/record `s` to `v` we write: `{x: v, ..s}`
Just merged that. Regarding the parser, @kmemarian is that going to make your life harder (wrt to the Cerberus/CN separation) if we tweak or extend the CN parser now? |
Relevant issue for pointers carrying C types: #349 |
Changes in this PR:
Add 2 additional rewrites to remove double negations
A couple of small tweaks the CSS style for reports
A bunch of improvements to the pretty printer for terms, namely:
Changes the
atomic
boolean parameter to aprec
integerparameter specifying the precedence of the surrounding context.
We also change how some things are printed:
'
(see also [CN] Allow'
in numeric constants #337)NULL
instead ofnull
to match CN's input notationx != y
instead of!(x == y)
%
instead ofrem
^
instead ofxor_uf
&
instead ofbw_and_uf
|
instead ofbw_or_uf
<<
instead ofshift_left
>>
instead ofshift_right
{ ...s, x = e }
for updating things. This is borrowedfrom JavaScript but it makes the precedence story simpler.
&p->x
instead ofmember_shift<T>(p,x)
&p[x]
instead ofarray_shift<T>(p,x)
cons(x,xs)
instead ofx :: xs
~