Alessandro Bonazzi
e075990ed3
Files correlati : Commento : Aggiunto il preprocessore c++ mcpp per sostituire il compilatore nella compilazione delle maschere.
52 lines
1.5 KiB
Raku
52 lines
1.5 KiB
Raku
/* n_27.t: Rescanning of a macro replace any macro call in the replacement
|
|
text after substitution of parameters by pre-expanded-arguments. This
|
|
re-examination may involve the succeding sequences from the source
|
|
file (what a queer thing!). */
|
|
|
|
/* 27.1: Cascaded use of object-like macros. */
|
|
/* 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8; */
|
|
#define NEST8 NEST7 + 8
|
|
#define NEST7 NEST6 + 7
|
|
#define NEST6 NEST5 + 6
|
|
#define NEST5 NEST4 + 5
|
|
#define NEST4 NEST3 + 4
|
|
#define NEST3 NEST2 + 3
|
|
#define NEST2 NEST1 + 2
|
|
#define NEST1 1
|
|
NEST8;
|
|
|
|
/* 27.2: Cascaded use of function-like macros. */
|
|
/* (1) + (1 + 2) + 1 + 2 + 1 + 2 + 3 + 1 + 2 + 3 + 4; */
|
|
#define FUNC4( a, b) FUNC3( a, b) + NEST4
|
|
#define FUNC3( a, b) FUNC2( a, b) + NEST3
|
|
#define FUNC2( a, b) FUNC1( a, b) + NEST2
|
|
#define FUNC1( a, b) (a) + (b)
|
|
FUNC4( NEST1, NEST2);
|
|
|
|
/* 27.3: An identifier generated by ## operator is subject to expansion. */
|
|
/* 1; */
|
|
#define glue( a, b) a ## b
|
|
#define MACRO_1 1
|
|
glue( MACRO_, 1);
|
|
|
|
#define sub( x, y) (x - y)
|
|
#define head sub(
|
|
#define math( op, a, b) op( (a), (b))
|
|
|
|
/* 27.4: 'sub' as an argument of math() is not pre-expanded, since '(' is
|
|
missing. */
|
|
/* ((a) - (b)); */
|
|
math( sub, a, b);
|
|
|
|
/* 27.5: Queer thing. */
|
|
/* (a - b); */
|
|
head a,b );
|
|
|
|
/* 27.6: Recursive macro (the 2nd 'm' is expanded to 'n' since it is in
|
|
source file). */
|
|
/* n; */
|
|
#define m n
|
|
#define n( a) a
|
|
m( m);
|
|
|