[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proposal: simplify prologue alternatives into %code

From: Paolo Bonzini
Subject: Re: proposal: simplify prologue alternatives into %code
Date: Thu, 04 Jan 2007 09:03:58 +0100
User-agent: Thunderbird (Macintosh/20061207)

b. What Java user thinks "requires" means "imports"? Yes, it makes sense when you think about it, but isn't "imports" more obvious and easier to remember? Similarly, what Java user thinks "provides" means "additional package-visible classes", which the epilogue handles anyway? I wonder if "requires" should be eliminated for Java. In any case, I think these Java issues demonstrate why it would be nice if the prologue alternatives were not distinct grammar directives: developers of new skeletons wouldn't feel as compelled to try to force their new square pegs into our old round holes.

Okay, so we'd have only %code, %code "imports", and the epilogue.

I would love to have "%code" be synonym with a particular QUALIFIER, rather than a separate muscle. Bonus points if you can make it skeleton-defined: so, in Java, %code would be synonym with %code "methods"; in C/C++, with %code "prototypes" (made up, but you get the idea).

Here is the implementation I suggest. %code "foo" would append to the b4_code_blocks muscle something like

b4_code([foo], [...

Note that all the code would go to the same muscle.
Then, c.m4 would do something like

b4_define_code([requires], [B4_DIVERT_REQUIRES])
b4_define_code([provides], [B4_DIVERT_PROVIDES])
b4_define_code([top], [B4_DIVERT_TOP])
b4_define_code_default([prototypes], [B4_DIVERT_PROTOTYPES])

b4_define_code would be defined like this in bison.m4

m4_define([b4_code], [m4_ifelse([$1], ]$1[, [$2], [])])dnl

and b4_define_code_default like this

m4_define([b4_code], [m4_ifelse([$1], ]$1[, [$2], [], [$2], [])])dnl

The code blocks would be recalled simply with m4_undivert.

I propose that the former directive would *append* to any code already associated with QUALIFIER; this would mimic the behavior of %{CODE%} and of the existing prologue alternative directives.


5. Hans suggested we drop the quotes around "QUALIFIER" or "NAME". I think that idea may have some merit, but lets debate this detail only after resolving the larger issues here.

I have no real preference.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]