miniscm: string->symbol and symbol->string
This commit is contained in:
parent
194a1d01e3
commit
06d19b2867
|
@ -1218,6 +1218,8 @@ register pointer a, b;
|
|||
#define OP_STRINGREF 112
|
||||
#define OP_STRINGLEN 113
|
||||
#define OP_LIST2STRING 114
|
||||
#define OP_STRING2SYMBOL 115
|
||||
#define OP_SYMBOL2STRING 116
|
||||
|
||||
static FILE *tmpfp;
|
||||
static int tok;
|
||||
|
@ -1783,6 +1785,16 @@ register short op;
|
|||
} else {
|
||||
Error_0("char->integer: argument must be char");
|
||||
}
|
||||
case OP_STRING2SYMBOL: /* string->symbol */
|
||||
if (!isstring(car(args))) {
|
||||
Error_0("string->symbol: argument must be string");
|
||||
}
|
||||
s_return(mk_symbol(strvalue(car(args))));
|
||||
case OP_SYMBOL2STRING: /* symbol->string */
|
||||
if (!issymbol(car(args))) {
|
||||
Error_0("symbol->string: argument must by symbol");
|
||||
}
|
||||
s_return(mk_string(symname(car(args))));
|
||||
|
||||
default:
|
||||
sprintf(strbuff, "%d is illegal operator", operator);
|
||||
|
@ -2529,7 +2541,9 @@ pointer (*dispatch_table[])() = {
|
|||
opexe_2, /* OP_CHAR2INT */
|
||||
opexe_4, /* OP_STRINGREF */
|
||||
opexe_4, /* OP_STRINGLEN */
|
||||
opexe_list2string /* OP_LIST2STRING */
|
||||
opexe_list2string, /* OP_LIST2STRING */
|
||||
opexe_2, /* OP_STRING2SYMBOL */
|
||||
opexe_2 /* OP_SYMBOL2STRING */
|
||||
};
|
||||
|
||||
|
||||
|
@ -2692,6 +2706,8 @@ init_procs()
|
|||
mk_proc(OP_STRINGREF, "string-ref");
|
||||
mk_proc(OP_STRINGLEN, "string-length");
|
||||
mk_proc(OP_LIST2STRING, "list->string");
|
||||
mk_proc(OP_STRING2SYMBOL, "string->symbol");
|
||||
mk_proc(OP_SYMBOL2STRING, "symbol->string");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue