From 37b86df09ff381bcc4f60802d43e57bd9bfcac73 Mon Sep 17 00:00:00 2001 From: Ori Bernstein Date: Tue, 17 Mar 2020 22:03:25 -0700 Subject: Improve the posix preprocessor. This fixes token pasting, making it expand when it should expand, and paste before expansion when it should paste before expanding. #define CAT(a, b) a ## b #define BAR 3 #define FOO CAT(BAR, 3) FOO now produces 33, while #define CAT(a, b) a ## b #define EOF (-1) #define NOP(x) x NOP(CAT(foo, EOF)) CAT(,EOF) CAT(,) produces fooEOF (-1) respectively. --- sys/src/cmd/cpp/test.expected | 49 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 sys/src/cmd/cpp/test.expected (limited to 'sys/src/cmd/cpp/test.expected') diff --git a/sys/src/cmd/cpp/test.expected b/sys/src/cmd/cpp/test.expected new file mode 100644 index 000000000..bf4b3aa99 --- /dev/null +++ b/sys/src/cmd/cpp/test.expected @@ -0,0 +1,49 @@ +#line 1 "/usr/ori/src/cpp/test.c" + + + +x fooEOF y +x EOFfoo y +x(-1) y +y foo x +x foo y +X y + + + foobar + + +foo ## bar + + + ablahb + + + + 33 + + +#line 32 "/usr/ori/src/cpp/test.c" + + + + + a,b + + + + + + + + + + + + + + + + f(2 * (y+1)) + f(2 * (f(2 * (z[0])))) % f(2 * (0)) + t(1); + f(2 * (2+(3,4)- 0,1)) | f(2 * (~ 5)) & f(2 * (0,1))^ m(0,1); +#line 55 "/usr/ori/src/cpp/test.c" -- cgit v1.2.3