Free Hero Mesh

Check-in [0548d34afe]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Add the variant of the {edit} macro to edit an argument of a macro which is currently being expanded.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0548d34afe1a2755f9bb0aa0213f6c5f9507f8e8
User & Date: user on 2023-03-29 03:22:33
Other Links: manifest | tags
Context
2023-03-29
19:48
Allow arguments to numeric arithmetic/bitwise macros to be directions and keys as well as numbers. check-in: ee285414da user: user tags: trunk
03:22
Add the variant of the {edit} macro to edit an argument of a macro which is currently being expanded. check-in: 0548d34afe user: user tags: trunk
2023-03-14
20:53
Optimize message blocks that begin with a goto instruction to a label that comes before it. check-in: 7cde381dd5 user: user tags: trunk
Changes

Modified class.c from [f3693b1dc0] to [16b649f4e6].

1043
1044
1045
1046
1047
1048
1049













1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062

1063
1064
1065
1066
1067
1068
1069
          nxttok();
          if(!(tokent&TF_NAME) || tokenv!=OP_STRING) ParseError("String literal expected\n");
          define_macro(look_hash_mac(),0);
          goto again;
        case MAC_EDIT:
          if(!macros) ParseError("Cannot edit nonexistent macro\n");
          nxttok();













          if(!(tokent&TF_NAME) || tokenv!=OP_STRING) ParseError("String literal expected\n");
          n=glohash[look_hash_mac()].id;
          if(n<0xC000 || n>MAX_MACRO+0xC000-1 || !macros[n-0xC000]) ParseError("Undefined macro: {%s}\n",tokenstr);
          nxttok();
          n-=0xC000;
          if(macros[n]->t&(TF_MACRO|TF_EOF)) ParseError("Invalid edit token\n");
          free(macros[n]->str);
          macros[n]->t=tokent;
          macros[n]->v=tokenv;
          macros[n]->str=0;
          if(*tokenstr) {
            macros[n]->str=strdup(tokenstr);
            if(!macros[n]->str) fatal("Allocation failed\n");

          }
          if(main_options['M']) {
            int i;
            printf("M= @%4d %04X %08X \"",linenum,tokent,tokenv);
            for(i=0;tokenstr[i];i++) {
              if(tokenstr[i]<32 || tokenstr[i]>126) printf("<%02X>",tokenstr[i]&255);
              else putchar(tokenstr[i]);







>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
>







1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
          nxttok();
          if(!(tokent&TF_NAME) || tokenv!=OP_STRING) ParseError("String literal expected\n");
          define_macro(look_hash_mac(),0);
          goto again;
        case MAC_EDIT:
          if(!macros) ParseError("Cannot edit nonexistent macro\n");
          nxttok();
          if(tokent==TF_INT) {
            if(!macstack) ParseError("Empty macro stack\n");
            n=tokenv-1;
            nxttok();
            if(n<0 || macstack->n<=n || !macstack->args[n]) ParseError("Cannot edit nonexistent argument %u\n",n+1);
            macstack->args[n]->t=tokent;
            macstack->args[n]->v=tokenv;
            macstack->args[n]->str=0;
            if(*tokenstr) {
              macstack->args[n]->str=strdup(tokenstr);
              if(!macstack->args[n]->str) fatal("Allocation failed\n");
            }
          } else {
            if(!(tokent&TF_NAME) || tokenv!=OP_STRING) ParseError("String literal expected\n");
            n=glohash[look_hash_mac()].id;
            if(n<0xC000 || n>MAX_MACRO+0xC000-1 || !macros[n-0xC000]) ParseError("Undefined macro: {%s}\n",tokenstr);
            nxttok();
            n-=0xC000;
            if(macros[n]->t&(TF_MACRO|TF_EOF)) ParseError("Invalid edit token\n");
            free(macros[n]->str);
            macros[n]->t=tokent;
            macros[n]->v=tokenv;
            macros[n]->str=0;
            if(*tokenstr) {
              macros[n]->str=strdup(tokenstr);
              if(!macros[n]->str) fatal("Allocation failed\n");
            }
          }
          if(main_options['M']) {
            int i;
            printf("M= @%4d %04X %08X \"",linenum,tokent,tokenv);
            for(i=0;tokenstr[i];i++) {
              if(tokenstr[i]<32 || tokenstr[i]>126) printf("<%02X>",tokenstr[i]&255);
              else putchar(tokenstr[i]);

Modified class.doc from [c34c71c5cb] to [f144cf4bb5].

180
181
182
183
184
185
186
187
188
189


190
191
192
193
194
195
196
  expanded during each use. A macro argument token with a single backslash
  expands to the argument in that position, while a macro argument tokens
  with multiple tokens becomes the token with one less backslash. It is
  permitted to redefine existing macros as well as new ones.

{edit <string> <token>}
  Edit a macro. This changes the first token of the definition of the macro
  (which must not be another macro) to the specified token (which also must
  not be another macro). The token is expanded, and must be a single token
  once it is expanded; that is what it will be replaced with.



{include <string>}
  Include text from another file into this one. You cannot use {include}
  inside of another macro or in a macro argument. The file must be in the
  current directory, and its name must contain only letters, digits, dot,
  underscore, and minus signs, and must start with a letter or digit. If
  it is a composite puzzle set, then the name must end with ".include",







|
|
|
>
>







180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
  expanded during each use. A macro argument token with a single backslash
  expands to the argument in that position, while a macro argument tokens
  with multiple tokens becomes the token with one less backslash. It is
  permitted to redefine existing macros as well as new ones.

{edit <string> <token>}
  Edit a macro. This changes the first token of the definition of the macro
  (which must not be another macro) to the specified token. The token is
  expanded, and must be a single token once it is expanded; that is what it
  will be replaced with. There is a variant with a number in place of a
  string; this will replace the argument of the macro which is currently
  being expanded.

{include <string>}
  Include text from another file into this one. You cannot use {include}
  inside of another macro or in a macro argument. The file must be in the
  current directory, and its name must contain only letters, digits, dot,
  underscore, and minus signs, and must start with a letter or digit. If
  it is a composite puzzle set, then the name must end with ".include",