removes application of parameters to name and body parsing macros
authorThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Tue, 13 May 2025 14:01:32 +0000 (07:01 -0700)
committerThomas Walker Lynch <eknp9n@reasoningtechnology.com>
Tue, 13 May 2025 14:01:32 +0000 (07:01 -0700)
experimentđź–‰/#assign_directive.c# [deleted file]
experimentđź–‰/assign_directive.c
experimentđź–‰/assign_test_1.c [new file with mode: 0644]
experimentđź–‰/assign_test_2.c [new file with mode: 0644]
script_gcc_min-12đź–‰/directives.cc
script_gcc_min-12đź–‰/macro.cc

diff --git a/experimentđź–‰/#assign_directive.c# b/experimentđź–‰/#assign_directive.c#
deleted file mode 100644 (file)
index 76e1eb4..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <stdio.h>
-
-#assign ()(Number)(0x2d9)
-
-#assign ()(NAME)(ONE)
-#assign ()[ NAME() ](1)
-
-#undef NAME
-#define NAME TwentySeven
-#assign ()[NAME](
-  Number / 27
-)
-
-int main(void){
-#if 1
-  printf("forty-two: %x\n" ,Number);
-  printf("ONE: %x\n" ,ONE);
-  printf("TwentySeven: %x\n" ,TwentySeven);
-#endif
-  printf("And thus begins the dance.\n");
-  return 0;
-}
index bb75d82..76e1eb4 100644 (file)
@@ -3,7 +3,7 @@
 #assign ()(Number)(0x2d9)
 
 #assign ()(NAME)(ONE)
-#assign ()[NAME]( 1 )
+#assign ()[ NAME() ](1)
 
 #undef NAME
 #define NAME TwentySeven
diff --git a/experimentđź–‰/assign_test_1.c b/experimentđź–‰/assign_test_1.c
new file mode 100644 (file)
index 0000000..7253bc7
--- /dev/null
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+#assign () (ANSWER) [42]
+
+int main(void){
+    printf( "The answer is: %d\n", ANSWER() );
+    return 0;
+}
diff --git a/experimentđź–‰/assign_test_2.c b/experimentđź–‰/assign_test_2.c
new file mode 100644 (file)
index 0000000..26f6ffe
--- /dev/null
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+#assign (x) (IDENTITY) (x)
+
+int main(void){
+    printf("Identity of 5 is: %d\n", IDENTITY(5));
+    return 0;
+}
index 26fea53..e8a10c9 100644 (file)
@@ -2938,12 +2938,15 @@ void print_token_list(const cpp_token *tokens ,size_t count){
 
     ; white space, including new lines, is ignored.
 
-
      This differs from `#define`:
-       -#assign takes no arguments.
        -name clause must reduce to a valid #define name
        -the assign is defined after the body clause has been parsed
 
+and for the call:
+
+    macro_call     ::= identifier "(" argument_list? ")" 
+
+
 */
 
 extern bool _cpp_create_assign(cpp_reader *pfile);
index c80a523..ab8c717 100644 (file)
@@ -4624,10 +4624,10 @@ bool _cpp_create_assign(cpp_reader *pfile){
       ,cmk_macro
       ,_cpp_reserve_room( pfile, 0, sizeof(cpp_macro) ) 
     );
-    name_macro->variadic = is_variadic;
-    name_macro->parm.params = params;
-    name_macro->paramc = param_count;
-    name_macro->fun_like = true;
+    name_macro->variadic = false;
+    name_macro->paramc = 0;
+    name_macro->parm.params = NULL;
+    name_macro->fun_like = false;
 
     unsigned int num_extra_tokens = 0;
     const char *paste_op_error_msg =
@@ -4708,10 +4708,10 @@ bool _cpp_create_assign(cpp_reader *pfile){
       ,cmk_macro
       ,_cpp_reserve_room( pfile, 0, sizeof(cpp_macro) ) 
     );
-    body_macro->variadic = is_variadic;
-    body_macro->paramc = param_count;
-    body_macro->parm.params = params;
-    body_macro->fun_like = true;
+    body_macro->variadic = false;
+    body_macro->paramc = 0;
+    body_macro->parm.params = NULL;
+    body_macro->fun_like = false;
 
     parse_clause(
       pfile 
@@ -4735,9 +4735,9 @@ bool _cpp_create_assign(cpp_reader *pfile){
       ,body_macro->exp.tokens
       ,sizeof(cpp_token) * body_macro->count
     );
-    assign_macro->variadic = body_macro->variadic;
-    assign_macro->parm.params = body_macro->parm.params;
-    assign_macro->paramc = body_macro->paramc;
+    assign_macro->variadic = is_variadic;
+    assign_macro->parm.params = params;
+    assign_macro->paramc = param_count;
     assign_macro->fun_like = true;