From: Thomas Walker Lynch Date: Tue, 13 May 2025 13:15:41 +0000 (-0700) Subject: #assign directive seems to work, still prints a lot of debug info, more testing needed X-Git-Url: https://git.reasoningtechnology.com/usr/lib/python2.7/encodings/idna.py?a=commitdiff_plain;h=975d5e551589abeea51311512f84f74ce566de33;p=RT-gcc #assign directive seems to work, still prints a lot of debug info, more testing needed --- diff --git "a/experiment\360\237\226\211/#assign_directive.c#" "b/experiment\360\237\226\211/#assign_directive.c#" new file mode 100644 index 0000000..76e1eb4 --- /dev/null +++ "b/experiment\360\237\226\211/#assign_directive.c#" @@ -0,0 +1,22 @@ +#include + +#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; +} diff --git "a/experiment\360\237\226\211/assign_directive.c" "b/experiment\360\237\226\211/assign_directive.c" index eb1e1d0..bb75d82 100644 --- "a/experiment\360\237\226\211/assign_directive.c" +++ "b/experiment\360\237\226\211/assign_directive.c" @@ -1,13 +1,13 @@ #include -#assign (Number)(0x2d9) +#assign ()(Number)(0x2d9) -#assign (NAME)(ONE) -#assign [NAME]( 1 ) +#assign ()(NAME)(ONE) +#assign ()[NAME]( 1 ) #undef NAME #define NAME TwentySeven -#assign [NAME]( +#assign ()[NAME]( Number / 27 ) diff --git "a/script_gcc_min-12\360\237\226\211/directives.cc" "b/script_gcc_min-12\360\237\226\211/directives.cc" index b94016d..26fea53 100644 --- "a/script_gcc_min-12\360\237\226\211/directives.cc" +++ "b/script_gcc_min-12\360\237\226\211/directives.cc" @@ -2923,20 +2923,6 @@ void print_token_list(const cpp_token *tokens ,size_t count){ /*-------------------------------------------------------------------------------- RT extention, directive `#assign` - cmd ::= "#assign" name body ; - - name ::= clause ; - body ::= clause ; - - clause ::= "(" literal? ")" | "[" expr? "]" ; - - literal ::= ; sequence parsed into tokens - expr ::= ; sequence parsed into tokens with recursive expansion of each token - - ; white space, including new lines, is ignored. - -will be deprecate `#macro` and modify `#assign` like this: - cmd ::= "#assign" params name body ; params ::= "(" param_list? ")" ; @@ -2967,29 +2953,6 @@ static void do_assign(cpp_reader *pfile){ _cpp_create_assign(pfile); -#if 0 - - - cpp_hashnode *node = lex_macro_node(pfile, true); - - if(node) - { - /* If we have been requested to expand comments into macros, - then re-enable saving of comments. */ - pfile->state.save_comments = - ! CPP_OPTION (pfile, discard_comments_in_macro_exp); - - if(pfile->cb.before_define) - pfile->cb.before_define (pfile); - - if( _cpp_create_assign(pfile, node) ) - if (pfile->cb.define) - pfile->cb.define (pfile, pfile->directive_line, node); - - node->flags &= ~NODE_USED; - } -#endif - } diff --git "a/script_gcc_min-12\360\237\226\211/macro.cc" "b/script_gcc_min-12\360\237\226\211/macro.cc" index 6b86e79..c80a523 100644 --- "a/script_gcc_min-12\360\237\226\211/macro.cc" +++ "b/script_gcc_min-12\360\237\226\211/macro.cc" @@ -4611,9 +4611,9 @@ bool _cpp_create_assign(cpp_reader *pfile){ unsigned int param_count; bool is_variadic; - if(!make_parameter_list(pfile ,¶ms ,¶m_count ,&is_variadic) + if (!make_parameter_list(pfile, ¶ms, ¶m_count, &is_variadic)) { return false; - + } /* Parse name clause into a temporary macro. @@ -4625,8 +4625,8 @@ bool _cpp_create_assign(cpp_reader *pfile){ ,_cpp_reserve_room( pfile, 0, sizeof(cpp_macro) ) ); name_macro->variadic = is_variadic; - name_macro->paramc = param_count; name_macro->parm.params = params; + name_macro->paramc = param_count; name_macro->fun_like = true; unsigned int num_extra_tokens = 0; @@ -4735,6 +4735,11 @@ 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->fun_like = true; + /* Install the assign macro under name_node. @@ -4764,6 +4769,7 @@ bool _cpp_create_assign(cpp_reader *pfile){ ,NODE_NAME(name_node) ); #endif + return true; } @@ -4771,3 +4777,12 @@ bool _cpp_create_assign(cpp_reader *pfile){ + + + + + + + + +