C:/Users/Dennis/src/lang/russell.orig/src/RIC_to_C/strings.h

Go to the documentation of this file.
00001 /* Strings are either represented as in C, except that they may not start */
00002 /* with HDR_MARK or REF_MARK, or they are represented as a pointer to a   */
00003 /* to an str_hdr structure.                                               */
00004 /* In the latter case, the whole string is the                            */
00005 /* concatenation of all the leaves of the binary tree formed by the       */
00006 /* str_hdr structures.                                                    */
00007 
00008 # define HDR_MARK '\201'  /* Meta Control-A */
00009 
00010 # define CS_NIL ((char *)0)
00011 
00012 struct str_hdr {
00013     char hdr_mark;  /* always equal to HDR_MARK */
00014     char * first_part;      /* Either or both may be struct str_hdr * */
00015     char * last_part;       /* At most one may be an empty string.    */
00016 };
00017 
00018 /* Macros to quickly get the first few characters of a string        */
00019 /* These set the second argument to NULL for one past the end of the */
00020 /* string.  They set it to garbage if more than 1 character past the */
00021 /* end is demanded.                                                  */
00022 static char charbuf[4];
00023 
00024 # define is_empty(s) (*(s) == '\0')
00025 
00026 # define GET_FIRST(s,c) \
00027     if (*s != HDR_MARK) { \
00028         c = *s; \
00029     } else { \
00030         charbuf[0] = '\0'; \
00031         str_firstn(charbuf, 1, s); \
00032         c = charbuf[0]; \
00033     }
00034 
00035 # define GET_SECOND(s,c) \
00036     if (*s != HDR_MARK) { \
00037         c = s[1]; \
00038     } else { \
00039         charbuf[0] = '\0'; \
00040         str_firstn(charbuf, 2, s); \
00041         c = charbuf[1]; \
00042     }
00043 
00044 # define GET_THIRD(s,c) \
00045     if (*s != HDR_MARK) { \
00046         c = s[2]; \
00047     } else { \
00048         charbuf[0] = '\0'; \
00049         str_firstn(charbuf, 3, s); \
00050         c = charbuf[2]; \
00051     }
00052 
00053 char * concat();
00054 
00055 char * flatten();
00056 
00057 char * placeholder();
00058 
00059 void set_ph();

Generated on Fri Jan 25 10:39:47 2008 for russell by  doxygen 1.5.4