<div dir="ltr">Yeah, I agree it does make sense to do this kind of merging with examples like the one you posted or else you get very very bad performance in matching. And the merging is coming about because of the way the language is structured; it isn't accidental "lucky" merging; you expect the same productions to show up multiple times because of the way the grammars are constructed.<div>
<br></div><div style>Overall, I agree with you that this is a reasonable request. I would be happier if I could say that Redex's module language were anywhere close to being ready because if it were, there would be a better way to do this. But in the meantime, I think your extension is a good one. Your email suggests that you are unaffiliated but I think you're actually at Northeastern? Can someone there help you make this push? If not, I'd be happy to do it.</div>
<div style><br></div><div style>Meanwhile, as to your Redex code, two points about reduction-semantics style: you should put both "v" and "E" into the extension not the originals: typically both concepts are a part of standard reduction. But, if you have a need of values in the original language, (for, say, defining Eval) then you should make it a separate non-terminal, not a production of 'e'. In your specific example, you run into trouble if you want to make pair strict, since you want only (pair v v) in the v non-terminal, but (pair e e) in the e non-terminal. FWIW.</div>
<div style><br></div><div style>Robby</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 28, 2013 at 3:04 PM, William J. Bowman <span dir="ltr"><<a href="mailto:wjb@williamjbowman.com" target="_blank">wjb@williamjbowman.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">By the way, when I was tinkering, I originally got my example working<br>
*without* merging nts (lines 1967-1983). I only added it after<br>
inspecting the output of `compiled-lang-lang'. The resulting<br>
union-language had the same nonterminal in a language several times with<br>
overlapping right-hand-sides, so I merged them<br>
<div class="im HOEnZb"><br>
William Bowman<br>
<br>
On Thu, Feb 28, 2013 at 02:05:59PM -0600, Robby Findler wrote:<br>
</div><div class="HOEnZb"><div class="h5">> The reason I didn't do that is very much related to lines 1967-1983 in your<br>
> diff.<br>
><br>
> That isn't a good idea: what you really want to do there is check to see if<br>
> different patterns generate the same languages or not. But that's not<br>
> something that is easily done (I'm guessing it is computable, but very very<br>
> expensive. It may not be computable, tho, for all I know.)<br>
><br>
> One could allow unioning by just keeping all productions, and I guess I<br>
> wouldn't mind an extension to define-union-language via a keyword that did<br>
> that, tho.<br>
><br>
> In your case, is there not a way to refactor your grammars so that you<br>
> don't need this capability? Could you maybe make a small, representative<br>
> example to post to the list? I find that kind of thing to be quite helpful<br>
> for me to understand what the best change to Redex is.<br>
><br>
> Robby<br>
><br>
><br>
><br>
> On Thu, Feb 28, 2013 at 1:46 PM, William J. Bowman<br>
> <<a href="mailto:wjb@williamjbowman.com">wjb@williamjbowman.com</a>>wrote:<br>
><br>
> > Hello all,<br>
> ><br>
> > I've been hacking on some languages in Redex, and found myself<br>
> > abstracting commons parts into base languages, and gradually building new<br>
> > languages via `define-extended-language' and `define-union-language'.<br>
> > Unfortunately, I hit a wall when I discovered `define-union-language'<br>
> > doesn't like to union languages that define the same nonterminals.<br>
> ><br>
> > Consider this toy example: <a href="https://gist.github.com/bluephoenix47/5054403" target="_blank">https://gist.github.com/bluephoenix47/5054403</a><br>
> ><br>
> > This seems like a sensible thing to want to do, so I forked racket wrote a<br>
> > patch:<br>
> ><br>
> > <a href="https://github.com/bluephoenix47/racket/commit/0a7781b2be2643778f8d8d10d771ab1ce2dc622b" target="_blank">https://github.com/bluephoenix47/racket/commit/0a7781b2be2643778f8d8d10d771ab1ce2dc622b</a><br>
> ><br>
> > Unfortunately, several Redex tests fail (<a href="http://sprunge.us/fPHU" target="_blank">http://sprunge.us/fPHU</a>) because<br>
> > they expect an error when languages which define the same nonterminals<br>
> > are used in `define-union-language'.<br>
> ><br>
> > Is this *desired* behavior? If so, why? It seems very reasonable to want<br>
> > to merge the nonterminals of languages.<br>
> ><br>
> > --<br>
> ><br>
> > William J. Bowman<br>
> ><br>
> > _________________________<br>
> > Racket Developers list:<br>
> > <a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
> ><br>
> ><br>
</div></div></blockquote></div><br></div>