dpp: add a syntax for parsing strings
@"foo" will expand to ecl_make_constant_base_string("foo", -1) now.
That saves some typing during testing when we want to feed a string to
the cl_format and other CL functions opearting on strings.
Now:
cl_format(3, @"~a: ~s", obj1, obj2);
Then:
cl_object str = ecl_make_constant_base_string("~a: ~s", -1);
cl_format(3, str, obj1, obj2);
This commit is contained in:
parent
379254456e
commit
b86a067788
1 changed files with 24 additions and 0 deletions
24
src/c/dpp.c
24
src/c/dpp.c
|
|
@ -351,6 +351,20 @@ read_symbol(int code)
|
|||
return name;
|
||||
}
|
||||
|
||||
char *
|
||||
read_string()
|
||||
{
|
||||
char c, *str = poolp;
|
||||
char end = '"';
|
||||
pushstr("ecl_make_constant_base_string(\"");
|
||||
do {
|
||||
c = readc();
|
||||
pushc(c);
|
||||
} while (c != end);
|
||||
pushstr(", -1)\0");
|
||||
return str;
|
||||
}
|
||||
|
||||
char *
|
||||
search_function(char *name)
|
||||
{
|
||||
|
|
@ -441,6 +455,9 @@ read_token(void)
|
|||
poolp--;
|
||||
} else if (c == '@') {
|
||||
pushc(c);
|
||||
} else if (c == '"') {
|
||||
read_string();
|
||||
poolp--;
|
||||
} else {
|
||||
char *name;
|
||||
unreadc(c);
|
||||
|
|
@ -933,6 +950,13 @@ main_loop(void)
|
|||
fprintf(out,"%s",p);
|
||||
poolp = tmp;
|
||||
goto LOOP;
|
||||
} else if (c == '"') {
|
||||
char *p;
|
||||
char * tmp = poolp;
|
||||
p = read_string();
|
||||
fprintf(out,"%s",p);
|
||||
poolp = tmp;
|
||||
goto LOOP;
|
||||
} else if (c != '(') {
|
||||
char *p;
|
||||
char * tmp = poolp;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue