Index: class.c ================================================================== --- class.c +++ class.c @@ -136,10 +136,11 @@ #define MAC_BOR 0xFFC6 #define MAC_BXOR 0xFFC7 #define MAC_BNOT 0xFFC8 #define MAC_CAT 0xFFC9 #define MAC_BIT 0xFFCA +#define MAC_MAKE 0xFFCB #define MAC_VERSION 0xFFE0 #define MAC_DEFINE 0xFFE1 #define MAC_INCLUDE 0xFFE2 #define MAC_CALL 0xFFE3 #define MAC_APPEND 0xFFE4 @@ -351,11 +352,11 @@ TokenList*tl=0; pr=0; tokent=macstack->tok->t; if(tokent&TF_EOF) ParseError("Unexpected end of file in macro expansion\n"); tokenv=macstack->tok->v; - *tokenstr=0; + if(tokent!=(TF_MACRO|TF_CLOSE)) *tokenstr=0; if(macstack->tok->str) strcpy(tokenstr,macstack->tok->str); if(main_options['M']) { printf("M* Macro %04X %08X \"",tokent,tokenv); for(i=0;tokenstr[i];i++) { if(tokenstr[i]<32 || tokenstr[i]>126) printf("<%02X>",tokenstr[i]&255); @@ -834,10 +835,129 @@ if(tokent!=TF_INT) ParseError("Number expected\n"); if(tokenv<32) n|=1<MAX_VERSION) ParseError("Version number out of range\n"); @@ -1971,10 +2091,11 @@ strcpy(tokenstr,"bor"); glohash[look_hash_mac()].id=MAC_BOR; strcpy(tokenstr,"bxor"); glohash[look_hash_mac()].id=MAC_BXOR; strcpy(tokenstr,"bnot"); glohash[look_hash_mac()].id=MAC_BNOT; strcpy(tokenstr,"cat"); glohash[look_hash_mac()].id=MAC_CAT; strcpy(tokenstr,"bit"); glohash[look_hash_mac()].id=MAC_BIT; + strcpy(tokenstr,"make"); glohash[look_hash_mac()].id=MAC_MAKE; strcpy(tokenstr,"version"); glohash[look_hash_mac()].id=MAC_VERSION; strcpy(tokenstr,"define"); glohash[look_hash_mac()].id=MAC_DEFINE; strcpy(tokenstr,"include"); glohash[look_hash_mac()].id=MAC_INCLUDE; strcpy(tokenstr,"call"); glohash[look_hash_mac()].id=MAC_CALL; strcpy(tokenstr,"append"); glohash[look_hash_mac()].id=MAC_APPEND; Index: class.doc ================================================================== --- class.doc +++ class.doc @@ -172,10 +172,16 @@ {include } Include text from another file into this one. You cannot use {include} inside of another macro or in a macro argument. +{make } + Make a synthetic token; see the below section about synthetic tokens for + details. The second argument can be a number, or a direction or key name + which is treated as a number, or a string. In most cases, a number will + be converted to a string with its unsigned decimal representation. + {mod } Modulo. {version } Expands into nothing. The number must be zero, otherwise it is an error. @@ -191,10 +197,42 @@ {define "H" \1} {call "2"|"1"|"1"} Note: Macro names are entirely independent from token names. + +=== Synthetic tokens === + +The possible modes of synthetic tokens are: + + ":" A label with the specified name. + "=:" Go to a label with a specified name. + ",:" Subroutine call a label with a specified name. + "@" A global variable. + "=@" Write a global variable. + "%" A local variable. + "=%" Write a local variable. + "#" A user-defined message. + "$" A class. + "&" A user-defined function. + "^" A user flag (read self, or definition). + "=^" A user flag (write self). + ",^" A user flag (read object). + "=,^" A user flag (write object). + "'" A key token; either by number or by name. + "D" A direction; only the low 4-bits are used. + "+" A number interpreted as decimal. + "=+" A number interpreted as binary. + ",+" A number interpreted as hexadecimal. + "=,+" A number interpreted as octal. + "C" A string with a single character of the specified code. + ",C" A string with a quiz button of the character with the code. + "A" The ASCII code of the first character of the string. + +Note that as the argument, you can use {cat} to convert other tokens +to strings if needed. + === Global definitions === These are the global definitions in the class definition file.