Closed ascherer closed 1 year ago
If you really, absolutely want to place function declarations and definitions together with a force
d line break, you can use @t}\6\4\4{@>
.
Perhaps you could add a “super backup” macro to cwebmac
that undoes all indentation and ensures the next line begins at the left margin. Then have CWEAVE put it at the beginning of function definitions/declarations. However, this would have the effect of removing support for nested function definitions/declaration (a nonstandard extension to C, but I think the current grammar allows them).
The grammar and implementation being as fragile as it is, I will first set up a (small) set of test cases for “fixed” issues (like your testthings.w
and my if.w
codes). Then I'd have to study the @2
pragma to see in detail what's going on with the insert
and where and why it gets merged into decl_head
and fn_decl
.
At the moment, I'd rather have “normal” CWEB programs format OK, rather than hacking around the peculiar MMIX sources (which I really don't like in general).
I've made progress by fixing major parts of MMIX.
Note that C23 will deprecate K&R function headers anyway.
DEK uses the curious construct
in MMIX modules
mmixal.w
,mmix-arith.w
,mmix-config.w
,mmix-io.w
,mmix-mem.w
,mmix-sim.w
, andmmmix.w
.The new CWEB grammar for support of both K&R and ANSI functions indents the
Leaving out the
@t}\6{@>
as inmmotype.w
is the natural solution.Overall, the MMIX code is quite messy in this respect, intermingling function declarations and definitions and global (non-static!) variables.
A significantly better approach is used in
mmix-pipe.w
, separating@<Prototypes@>
and@<Subroutines@>
(internal and external).