add +,/,*,=.
This commit is contained in:
parent
0ef7238600
commit
bfed3eb8b3
|
@ -16,7 +16,14 @@ mes.h: mes.c GNUmakefile
|
||||||
while read f; do\
|
while read f; do\
|
||||||
fun=$$(echo $$f | sed -e 's,^scm [*],,' -e 's,{.*,,');\
|
fun=$$(echo $$f | sed -e 's,^scm [*],,' -e 's,{.*,,');\
|
||||||
name=$$(echo $$fun | sed -e 's,^scm [\*],,' | grep -o '^[^ ]*');\
|
name=$$(echo $$fun | sed -e 's,^scm [\*],,' | grep -o '^[^ ]*');\
|
||||||
scm_name=$$(echo $$name | sed -e 's,_p$$,?,' -e 's,_x$$,!,' -e 's,^builtin_,,' -re 's,(.*)_$$,c:\1,' | sed -e 's,^less?$$,<,' -e 's,^minus$$,-,' -e 's,_,-,g');\
|
scm_name=$$(echo $$name | sed -e 's,_p$$,?,' -e 's,_x$$,!,' -e 's,^builtin_,,' -re 's,(.*)_$$,c:\1,' | sed \
|
||||||
|
-e 's,^divide$$,/,'\
|
||||||
|
-e 's,^is?$$,=,'\
|
||||||
|
-e 's,^less?$$,<,'\
|
||||||
|
-e 's,^minus$$,-,'\
|
||||||
|
-e 's,^multiply$$,*,'\
|
||||||
|
-e 's,^plus$$,+,'\
|
||||||
|
-e 's,_,-,g');\
|
||||||
args=$$(echo $$fun | grep -o 'scm [\*]' | wc -l);\
|
args=$$(echo $$fun | grep -o 'scm [\*]' | wc -l);\
|
||||||
echo "scm *$$fun;";\
|
echo "scm *$$fun;";\
|
||||||
echo "scm scm_$$name = {FUNCTION$$args, .name=\"$$scm_name\", .function$$args=&$$name};";\
|
echo "scm scm_$$name = {FUNCTION$$args, .name=\"$$scm_name\", .function$$args=&$$name};";\
|
||||||
|
|
48
mes.c
48
mes.c
|
@ -715,23 +715,41 @@ less_p (scm *a, scm *b)
|
||||||
scm *
|
scm *
|
||||||
minus (scm *a, scm *b)
|
minus (scm *a, scm *b)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
printf ("\nminus a=");
|
|
||||||
display (a);
|
|
||||||
printf (" b=");
|
|
||||||
display (b);
|
|
||||||
puts ("");
|
|
||||||
#endif
|
|
||||||
assert (a->type == NUMBER);
|
assert (a->type == NUMBER);
|
||||||
assert (b->type == NUMBER);
|
assert (b->type == NUMBER);
|
||||||
//return make_number (a->value - b->value);
|
return make_number (a->value - b->value);
|
||||||
scm *r = make_number (a->value - b->value);
|
}
|
||||||
#if DEBUG
|
|
||||||
printf (" ==> ");
|
scm *
|
||||||
display (r);
|
plus (scm *a, scm *b)
|
||||||
puts ("");
|
{
|
||||||
#endif
|
assert (a->type == NUMBER);
|
||||||
return r;
|
assert (b->type == NUMBER);
|
||||||
|
return make_number (a->value + b->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
scm *
|
||||||
|
divide (scm *a, scm *b)
|
||||||
|
{
|
||||||
|
assert (a->type == NUMBER);
|
||||||
|
assert (b->type == NUMBER);
|
||||||
|
return make_number (a->value / b->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
scm *
|
||||||
|
multiply (scm *a, scm *b)
|
||||||
|
{
|
||||||
|
assert (a->type == NUMBER);
|
||||||
|
assert (b->type == NUMBER);
|
||||||
|
return make_number (a->value * b->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
scm *
|
||||||
|
is_p (scm *a, scm *b)
|
||||||
|
{
|
||||||
|
assert (a->type == NUMBER);
|
||||||
|
assert (b->type == NUMBER);
|
||||||
|
return a->value == b->value ? &scm_t : &scm_f;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QUASIQUOTE
|
#if QUASIQUOTE
|
||||||
|
|
Loading…
Reference in a new issue