00001 # include "parm.h"
00002
00003 # include "stree/ststructs.mh"
00004
00005 extern NODE * sig_const;
00006 extern int indx_empty;
00007 extern int indx_sconc;
00008 extern int indx_pconc;
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 NODE *
00021 expand_str(string)
00022 NODE * string;
00023 {
00024 char * next_char;
00025 NODE * expansion;
00026 NODE * id_node;
00027 NODE * conc_op;
00028 char * const_template = "'X'";
00029
00030 # ifdef DEBUG
00031 if (string -> sel_type == NIL) {
00032 dbgmsg("expand_str: missing selection type\n");
00033 abort();
00034 }
00035 # endif
00036 next_char = string -> str_string;
00037
00038 switch (string -> kind) {
00039 case QSTR:
00040 id_node = mknode(LETTERID, indx_empty);
00041 initfld(&(id_node -> sel_type), string -> sel_type);
00042 id_node -> id_def_found = TRUE;
00043 break;
00044 case UQSTR:
00045 # ifdef DEBUG
00046 if (*next_char == '\0') {
00047 dbgmsg("expand_str: empty unquoted string\n");
00048 }
00049 # endif
00050 const_template[1] = * next_char++;
00051 id_node = mknode(LETTERID, stt_enter(const_template,4));
00052 initfld(&(id_node -> sel_type), string -> sel_type);
00053 id_node -> id_def_found = TRUE;
00054 break;
00055 # ifdef DEBUG
00056 default:
00057 dbgmsg("expand_str: bad string node\n");
00058 # endif
00059 }
00060 expansion = mknode(APPLICATION, id_node, emptylist());
00061
00062 if (*next_char) {
00063
00064 switch(string -> kind) {
00065 case QSTR:
00066 conc_op = mknode(LETTERID, indx_sconc);
00067 break;
00068 case UQSTR:
00069 conc_op = mknode(LETTERID, indx_pconc);
00070 break;
00071 }
00072 initfld(&(conc_op -> sel_type), string -> sel_type);
00073 conc_op -> id_def_found = TRUE;
00074 }
00075
00076
00077 while (*next_char) {
00078 const_template[1] = * next_char++;
00079 id_node = mknode(LETTERID, stt_enter(const_template,4));
00080 initfld(&(id_node -> sel_type), string -> sel_type);
00081 id_node -> id_def_found = TRUE;
00082 expansion = mknode( APPLICATION,
00083 conc_op,
00084 mklist( expansion,
00085 mknode( APPLICATION,
00086 id_node,
00087 emptylist()
00088 ),
00089 -1
00090 )
00091 );
00092 }
00093 return(expansion);
00094 }