core: Remove string.c.
* string.c: Remove. * mes.c (eval_apply): Remove caller. * GNUmakefile (mes.o): Remove dependency on string. * module/mes/psyntax-0.mes (eval): Handle "noexpand". * module/mes/type-0.mes (string->symbol, symbol->list, symbol->string): New function.
This commit is contained in:
parent
151a07ded3
commit
95fd6646dc
|
@ -34,7 +34,6 @@ mes.o: lib.c lib.h lib.i lib.environment.i
|
||||||
mes.o: math.c math.h math.i math.environment.i
|
mes.o: math.c math.h math.i math.environment.i
|
||||||
mes.o: posix.c posix.h posix.i posix.environment.i
|
mes.o: posix.c posix.h posix.i posix.environment.i
|
||||||
mes.o: reader.c reader.h reader.i reader.environment.i
|
mes.o: reader.c reader.h reader.i reader.environment.i
|
||||||
mes.o: string.c string.h string.i string.environment.i
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f mes mes.o *.environment.i *.symbols.i *.environment.h *.cat a.out
|
rm -f mes mes.o *.environment.i *.symbols.i *.environment.h *.cat a.out
|
||||||
|
|
9
mes.c
9
mes.c
|
@ -157,7 +157,6 @@ SCM r3 = 0; // param 3
|
||||||
#include "mes.h"
|
#include "mes.h"
|
||||||
#include "posix.h"
|
#include "posix.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
#include "string.h"
|
|
||||||
|
|
||||||
#define CAR(x) g_cells[x].car
|
#define CAR(x) g_cells[x].car
|
||||||
#define CDR(x) g_cells[x].cdr
|
#define CDR(x) g_cells[x].cdr
|
||||||
|
@ -507,12 +506,9 @@ eval_apply ()
|
||||||
default: return r1;
|
default: return r1;
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_expand:
|
|
||||||
if (TYPE (CAR (r1)) == STRING && string_to_symbol (CAR (r1)) == cell_symbol_noexpand)
|
|
||||||
return cadr (r1);
|
|
||||||
|
|
||||||
SCM macro;
|
SCM macro;
|
||||||
SCM expanders;
|
SCM expanders;
|
||||||
|
macro_expand:
|
||||||
if (TYPE (r1) == PAIR
|
if (TYPE (r1) == PAIR
|
||||||
&& (macro = lookup_macro (car (r1), r0)) != cell_f)
|
&& (macro = lookup_macro (car (r1), r0)) != cell_f)
|
||||||
{
|
{
|
||||||
|
@ -1087,7 +1083,6 @@ mes_builtins (SCM a)
|
||||||
#include "math.i"
|
#include "math.i"
|
||||||
#include "posix.i"
|
#include "posix.i"
|
||||||
#include "reader.i"
|
#include "reader.i"
|
||||||
#include "string.i"
|
|
||||||
|
|
||||||
#include "display.environment.i"
|
#include "display.environment.i"
|
||||||
#include "lib.environment.i"
|
#include "lib.environment.i"
|
||||||
|
@ -1095,7 +1090,6 @@ mes_builtins (SCM a)
|
||||||
#include "mes.environment.i"
|
#include "mes.environment.i"
|
||||||
#include "posix.environment.i"
|
#include "posix.environment.i"
|
||||||
#include "reader.environment.i"
|
#include "reader.environment.i"
|
||||||
#include "string.environment.i"
|
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
@ -1211,7 +1205,6 @@ dump ()
|
||||||
#include "math.c"
|
#include "math.c"
|
||||||
#include "posix.c"
|
#include "posix.c"
|
||||||
#include "reader.c"
|
#include "reader.c"
|
||||||
#include "string.c"
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
(define (interaction-environment) (current-module))
|
(define (interaction-environment) (current-module))
|
||||||
|
|
||||||
(define (eval x . environment)
|
(define (eval x . environment)
|
||||||
(eval-env x (if (null? environment) (current-module) (car environment))))
|
(eval-env (if (and (pair? x) (equal? (car x) "noexpand")) (cadr x) x)
|
||||||
|
(if (null? environment) (current-module) (car environment))))
|
||||||
|
|
||||||
(define annotation? (lambda (x) #f))
|
(define annotation? (lambda (x) #f))
|
||||||
(define (self-evaluating? x)
|
(define (self-evaluating? x)
|
||||||
|
|
|
@ -120,5 +120,15 @@
|
||||||
(define (string->list s)
|
(define (string->list s)
|
||||||
(core:car s))
|
(core:car s))
|
||||||
|
|
||||||
|
(define (string->symbol s)
|
||||||
|
(if (not (pair? (core:car s))) '()
|
||||||
|
(make-symbol (core:car s))))
|
||||||
|
|
||||||
|
(define (symbol->list s)
|
||||||
|
(core:car s))
|
||||||
|
|
||||||
|
(define (symbol->string s)
|
||||||
|
(apply string (symbol->list s)))
|
||||||
|
|
||||||
(define (string-append . rest)
|
(define (string-append . rest)
|
||||||
(apply string (apply append (map1 string->list rest))))
|
(apply string (apply append (map1 string->list rest))))
|
||||||
|
|
48
string.c
48
string.c
|
@ -1,48 +0,0 @@
|
||||||
/* -*-comment-start: "//";comment-end:""-*-
|
|
||||||
* Mes --- Maxwell Equations of Software
|
|
||||||
* Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
|
|
||||||
*
|
|
||||||
* This file is part of Mes.
|
|
||||||
*
|
|
||||||
* Mes is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or (at
|
|
||||||
* your option) any later version.
|
|
||||||
*
|
|
||||||
* Mes is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
SCM
|
|
||||||
string_to_symbol (SCM x)
|
|
||||||
{
|
|
||||||
assert (TYPE (x) == STRING);
|
|
||||||
return STRING (x) == cell_nil ? cell_nil : make_symbol (STRING (x));
|
|
||||||
}
|
|
||||||
|
|
||||||
SCM
|
|
||||||
symbol_to_string (SCM x)
|
|
||||||
{
|
|
||||||
assert (TYPE (x) == SYMBOL);
|
|
||||||
return MAKE_STRING (STRING (x));
|
|
||||||
}
|
|
||||||
|
|
||||||
SCM
|
|
||||||
keyword_to_symbol (SCM x)
|
|
||||||
{
|
|
||||||
assert (TYPE (x) == KEYWORD);
|
|
||||||
return make_symbol (STRING (x));
|
|
||||||
}
|
|
||||||
|
|
||||||
SCM
|
|
||||||
symbol_to_keyword (SCM x)
|
|
||||||
{
|
|
||||||
assert (TYPE (x) == SYMBOL);
|
|
||||||
g_cells[tmp_num].value = KEYWORD;
|
|
||||||
return make_cell (tmp_num, STRING (x), 0);
|
|
||||||
}
|
|
Loading…
Reference in New Issue