Re: [racket-users] Parenthesizing infix expressions in Redex renderings?

2021-02-26 Thread David Thrane Christiansen
Hi Robby,

I suppose a system that optionally annotated each alternative for a
nonterminal with precedence and associativity would be the maximally
featureful way to go here, with unannotated alternatives being
parenthesized like today. Something akin to #:binding-forms, I guess. But I
haven't dug enough into the current pict rendering to know if that would
fit in nicely to the current customization system.

/David

Den ons. 24. feb. 2021 kl. 20.38 skrev Robby Findler <
ro...@cs.northwestern.edu>:

> Yeah, I've been meaning to integrate those parts of that library into
> Redex proper but just haven't found the time.
>
> Also, I've thought it would be nice if Redex were able to look at the
> context of a particular, say, "or" or "then" expression and figure out if
> it needed parens. Sadly, for now you have to specialize the rewriting based
> on specific examples you're rendering (or just have too many parens, sigh).
>
> Robby
>
>
> On Wed, Feb 24, 2021 at 4:46 AM David Thrane Christiansen <
> da...@davidchristiansen.dk> wrote:
>
>> Thanks Ryan!
>>
>> There's all sorts of nice goodies in that library, like
>> current-atomic-rewriters and friends.
>>
>> David
>>
>> Den ons. 24. feb. 2021 kl. 11.29 skrev Ryan Culpepper <
>> rmculpepp...@gmail.com>:
>>
>>> The `binary-rw` function from unstable/gui/redex library has some
>>> support for optionally parenthesizing its arguments.
>>>
>>> Ryan
>>>
>>>
>>> On Wed, Feb 24, 2021 at 11:07 AM David Thrane Christiansen <
>>> da...@davidchristiansen.dk> wrote:
>>>
 Hello all,

 I'm working on coding up a little language model in Redex, and I'd like
 to get it to render things in the form that my colleagues are used to. This
 means some infix operators as well as dealing with parenthesizing based on
 operator precedence.

 Here's a boiled-down sample of what I'm up to:

 #lang racket

 (require redex pict)

 (define-language L
   (C success (then C C) (or C C)))

 (with-compound-rewriters
   (['or (match-lambda [(list _ _ x y _) (list "" x " or " y "")])]
['then (match-lambda [(list _ _ x y _) (list "" x " then " y "")])])
   (vl-append
20
(render-language L)
(render-term L (then (or success success) success

 I've attached the result. The resulting rendering of L looks
 appropriate, but the nesting of then and or in the rendered term does not
 indicate the nesting. I'd like to be able to specify precedence and
 associativity and have parentheses inserted appropriately; failing that, a
 reasonable backup would be parenthesizing sub-expressions that are not
 atomic.

 Can anyone point me at the right resource to use to figure out how to
 do this?

 Thank you!

 David

 --
 You received this message because you are subscribed to the Google
 Groups "Racket Users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to racket-users+unsubscr...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/racket-users/CAF_itEtHuJP6i%3DR3_ggKTn1%3DRDmswZfCiFMYJqBwcHqpXB7fpw%40mail.gmail.com
 
 .

>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAF_itEt9JUSZBUZ_09keQmXpUo0HJbYahN4dXD%2Bjp8jp9A2cXw%40mail.gmail.com
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAF_itEs7f9MQ%2BrRjZx6N_6cNdbc7CsYyfc14HSpPJ3vKdOPzFg%40mail.gmail.com.


Re: [racket-users] Parenthesizing infix expressions in Redex renderings?

2021-02-24 Thread Robby Findler
Yeah, I've been meaning to integrate those parts of that library into Redex
proper but just haven't found the time.

Also, I've thought it would be nice if Redex were able to look at the
context of a particular, say, "or" or "then" expression and figure out if
it needed parens. Sadly, for now you have to specialize the rewriting based
on specific examples you're rendering (or just have too many parens, sigh).

Robby


On Wed, Feb 24, 2021 at 4:46 AM David Thrane Christiansen <
da...@davidchristiansen.dk> wrote:

> Thanks Ryan!
>
> There's all sorts of nice goodies in that library, like
> current-atomic-rewriters and friends.
>
> David
>
> Den ons. 24. feb. 2021 kl. 11.29 skrev Ryan Culpepper <
> rmculpepp...@gmail.com>:
>
>> The `binary-rw` function from unstable/gui/redex library has some support
>> for optionally parenthesizing its arguments.
>>
>> Ryan
>>
>>
>> On Wed, Feb 24, 2021 at 11:07 AM David Thrane Christiansen <
>> da...@davidchristiansen.dk> wrote:
>>
>>> Hello all,
>>>
>>> I'm working on coding up a little language model in Redex, and I'd like
>>> to get it to render things in the form that my colleagues are used to. This
>>> means some infix operators as well as dealing with parenthesizing based on
>>> operator precedence.
>>>
>>> Here's a boiled-down sample of what I'm up to:
>>>
>>> #lang racket
>>>
>>> (require redex pict)
>>>
>>> (define-language L
>>>   (C success (then C C) (or C C)))
>>>
>>> (with-compound-rewriters
>>>   (['or (match-lambda [(list _ _ x y _) (list "" x " or " y "")])]
>>>['then (match-lambda [(list _ _ x y _) (list "" x " then " y "")])])
>>>   (vl-append
>>>20
>>>(render-language L)
>>>(render-term L (then (or success success) success
>>>
>>> I've attached the result. The resulting rendering of L looks
>>> appropriate, but the nesting of then and or in the rendered term does not
>>> indicate the nesting. I'd like to be able to specify precedence and
>>> associativity and have parentheses inserted appropriately; failing that, a
>>> reasonable backup would be parenthesizing sub-expressions that are not
>>> atomic.
>>>
>>> Can anyone point me at the right resource to use to figure out how to do
>>> this?
>>>
>>> Thank you!
>>>
>>> David
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Racket Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to racket-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/racket-users/CAF_itEtHuJP6i%3DR3_ggKTn1%3DRDmswZfCiFMYJqBwcHqpXB7fpw%40mail.gmail.com
>>> 
>>> .
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAF_itEt9JUSZBUZ_09keQmXpUo0HJbYahN4dXD%2Bjp8jp9A2cXw%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAL3TdOPbTBf6eSm14anTdgh1s2siUE8RRr0yuYC3zxs3msoEvg%40mail.gmail.com.


Re: [racket-users] Parenthesizing infix expressions in Redex renderings?

2021-02-24 Thread David Thrane Christiansen
Thanks Ryan!

There's all sorts of nice goodies in that library, like
current-atomic-rewriters and friends.

David

Den ons. 24. feb. 2021 kl. 11.29 skrev Ryan Culpepper <
rmculpepp...@gmail.com>:

> The `binary-rw` function from unstable/gui/redex library has some support
> for optionally parenthesizing its arguments.
>
> Ryan
>
>
> On Wed, Feb 24, 2021 at 11:07 AM David Thrane Christiansen <
> da...@davidchristiansen.dk> wrote:
>
>> Hello all,
>>
>> I'm working on coding up a little language model in Redex, and I'd like
>> to get it to render things in the form that my colleagues are used to. This
>> means some infix operators as well as dealing with parenthesizing based on
>> operator precedence.
>>
>> Here's a boiled-down sample of what I'm up to:
>>
>> #lang racket
>>
>> (require redex pict)
>>
>> (define-language L
>>   (C success (then C C) (or C C)))
>>
>> (with-compound-rewriters
>>   (['or (match-lambda [(list _ _ x y _) (list "" x " or " y "")])]
>>['then (match-lambda [(list _ _ x y _) (list "" x " then " y "")])])
>>   (vl-append
>>20
>>(render-language L)
>>(render-term L (then (or success success) success
>>
>> I've attached the result. The resulting rendering of L looks appropriate,
>> but the nesting of then and or in the rendered term does not indicate the
>> nesting. I'd like to be able to specify precedence and associativity and
>> have parentheses inserted appropriately; failing that, a reasonable backup
>> would be parenthesizing sub-expressions that are not atomic.
>>
>> Can anyone point me at the right resource to use to figure out how to do
>> this?
>>
>> Thank you!
>>
>> David
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/racket-users/CAF_itEtHuJP6i%3DR3_ggKTn1%3DRDmswZfCiFMYJqBwcHqpXB7fpw%40mail.gmail.com
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAF_itEt9JUSZBUZ_09keQmXpUo0HJbYahN4dXD%2Bjp8jp9A2cXw%40mail.gmail.com.


Re: [racket-users] Parenthesizing infix expressions in Redex renderings?

2021-02-24 Thread Ryan Culpepper
The `binary-rw` function from unstable/gui/redex library has some support
for optionally parenthesizing its arguments.

Ryan


On Wed, Feb 24, 2021 at 11:07 AM David Thrane Christiansen <
da...@davidchristiansen.dk> wrote:

> Hello all,
>
> I'm working on coding up a little language model in Redex, and I'd like to
> get it to render things in the form that my colleagues are used to. This
> means some infix operators as well as dealing with parenthesizing based on
> operator precedence.
>
> Here's a boiled-down sample of what I'm up to:
>
> #lang racket
>
> (require redex pict)
>
> (define-language L
>   (C success (then C C) (or C C)))
>
> (with-compound-rewriters
>   (['or (match-lambda [(list _ _ x y _) (list "" x " or " y "")])]
>['then (match-lambda [(list _ _ x y _) (list "" x " then " y "")])])
>   (vl-append
>20
>(render-language L)
>(render-term L (then (or success success) success
>
> I've attached the result. The resulting rendering of L looks appropriate,
> but the nesting of then and or in the rendered term does not indicate the
> nesting. I'd like to be able to specify precedence and associativity and
> have parentheses inserted appropriately; failing that, a reasonable backup
> would be parenthesizing sub-expressions that are not atomic.
>
> Can anyone point me at the right resource to use to figure out how to do
> this?
>
> Thank you!
>
> David
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/CAF_itEtHuJP6i%3DR3_ggKTn1%3DRDmswZfCiFMYJqBwcHqpXB7fpw%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CANy33qmAv_KzhBj_%2B3NezyXgt6vAzL_M6dF0J9S%3DRZkQyA1HSQ%40mail.gmail.com.


[racket-users] Parenthesizing infix expressions in Redex renderings?

2021-02-24 Thread David Thrane Christiansen
Hello all,

I'm working on coding up a little language model in Redex, and I'd like to
get it to render things in the form that my colleagues are used to. This
means some infix operators as well as dealing with parenthesizing based on
operator precedence.

Here's a boiled-down sample of what I'm up to:

#lang racket

(require redex pict)

(define-language L
  (C success (then C C) (or C C)))

(with-compound-rewriters
  (['or (match-lambda [(list _ _ x y _) (list "" x " or " y "")])]
   ['then (match-lambda [(list _ _ x y _) (list "" x " then " y "")])])
  (vl-append
   20
   (render-language L)
   (render-term L (then (or success success) success

I've attached the result. The resulting rendering of L looks appropriate,
but the nesting of then and or in the rendered term does not indicate the
nesting. I'd like to be able to specify precedence and associativity and
have parentheses inserted appropriately; failing that, a reasonable backup
would be parenthesizing sub-expressions that are not atomic.

Can anyone point me at the right resource to use to figure out how to do
this?

Thank you!

David

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAF_itEtHuJP6i%3DR3_ggKTn1%3DRDmswZfCiFMYJqBwcHqpXB7fpw%40mail.gmail.com.