Commit Graph

15 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 9fc27ee25a mes: Single environment lookup for variables, SICP chapter 3.
* src/mes.c (t): Add TVARIABLE.
  (scm_vm_eval_deref): New vm special.
  (make_vref_): New internal function.
  (eval_apply): WIP: replace symbols with their variable reference.
* src/gc.c (gc_loop): Handle TVARIABLE.
* src/lib.c (display_helper): Handle TVARIABLE.
* module/mes/type-0.mes (<cell:variable>): New variable.
  (cell:type-alist): Add it.
  (variable?): New function.
* module/mes/display.mes (display): Handle <variable>.
2017-12-09 08:33:50 +01:00
Jan Nieuwenhuizen 91070593e9 mes: More informative error reporting for number asserts.
* src/math.c (assert_number): New function.  Update assert () users.
2018-01-25 07:00:48 +01:00
Jan Nieuwenhuizen d176d1bf6c core: Display and write string and char compliance.
* src/lib.c (display_helper): Display and write char and string compliance.
2018-01-22 23:45:46 +01:00
Jan Nieuwenhuizen 5a7db9749d mes: display: Support keyword.
* src/lib.c (display_helper): Support keyword.
2018-02-03 21:57:30 +01:00
Jan Nieuwenhuizen 3161f039b2 mes: display: vector.
* src/lib.c (display_helper): Display vector.
2018-01-12 18:24:42 +01:00
Jan Nieuwenhuizen 63e8b49d9e mes: display: closure names.
* src/lib.c (display_helper): Display closure names.
2018-01-14 09:11:19 +01:00
Jan Nieuwenhuizen a5ede4d4d6 mes: Better error reporting.
* src/lib.c (write_error_): New function.
* src/mes.c (error, check_apply): Use it.
  (append2, set_car_x): Upon error, call error (WAS: assert).
2018-01-07 16:08:11 +01:00
Jan Nieuwenhuizen 81404179c1 mes: Add write, core:write.
* src/lib.c (display_helper, fdisplay_): Add parameter, write_p.
  Update callers.  When write_p: write quoted strings.
  (write_, write_port_): New function.
* module/mes/read-0.mes (write): New function.
2018-01-01 21:10:15 +01:00
Jan Nieuwenhuizen 08562b168d test: Add syntax tests.
* tests/syntax.test: New file.
* tests/syntax.test-guile: New file.

fixup: 1b0696f9 (Jan Nieuwenhuizen 2018-01-01 15:53:13 +0100 40) ,        (lambda ()
2018-01-01 15:53:13 +01:00
Jan Nieuwenhuizen eb0505300c mes: Fix display of closure.
* module/mes/display.mes (display): Drop extra ( at start of *closure*, *circ*.
* src/lib.c (display_helper): Likewise.
2017-12-11 07:06:21 +01:00
Jan Nieuwenhuizen ccddde9a84 mescc: Output performance hacks: use core:display.
* src/lib.c (display_): Write to g_stdout (WAS: STDOUT).
* module/mes/guile.scm (guile): Declare and export core:display core:display-error.
* module/mes/M1.mes (object->M1): Use core:display and string-append
  instead of format.
* module/mes/guile.mes (with-input-from-string): Add debugging.
  (open-input-string): Likewise.
  (read-string): Likewise.  Re-implement.
  (drain-input): Use read-string.
2017-12-09 20:10:57 +01:00
Jan Nieuwenhuizen 808af5001f mlibc: New library layout; remove duplication.
* lib/libc+tcc-gcc.c: New file: Libc bits for GCC from libc-mes+tcc.c.
* lib/libc+tcc-mes.c: New file: Libc bits for MesCC from libc-mes+tcc.c.
* lib/libc+tcc.c: New file: Libc bits from libc-mes+tcc.c.
* lib/libc.c: New file: Merged from libc-mes.c, libc-gcc.c.
  (abtoi): New function: Rename from _atoi.
* lib/linux+tcc-gcc.c: New file:  Linux bits from libc-gcc+tcc.c.
* lib/linux+tcc-mes.c: New file: Linux bits from libc-mes+tcc.c.
* lib/linux-gcc.c: New file: Linux bits from libc-gcc.c.
* lib/linux-mes.c: New file: Linux bits from libc-mes.c.
* lib/mini-libc-gcc.c: New file.
* lib/mini-libc.c: New file: Libc bits from mini-libc-mes.c.
* lib/mini-linux-gcc.c: New file.
* lib/mini-linux-mes.c: New file: Linux bits from mini-libc-mes.c.
* lib/libc-gcc.c: Remove duplication using include now.
* lib/libc-mes.c: Likewise.
* lib/mini-libc-mes.c: Likewise.
* include/stdio.h (puts)[POSIX]: Remomve macro.
  (fputc, fputs)[!POSIX]: New macro.
  (fputc, fputs): Remove declaration.
* scaffold/tests/7j-strtoull.c (strtoull, test): Use abtoi.
* src/lib.c (fputs)[__MESC__]: Remove define.
* guile/guix/make.scm: Update for new library layout.
* make.scm: Likewise.
* build.sh: Likewise.
* install.sh: Likewise.
2017-12-03 13:56:21 +01:00
Jan Nieuwenhuizen 6af7556d51 mescc: C99 header files and declaraions.
* libc/include/assert.h (assert_fail):
* libc/include/stdio.h:
+int eputs (char const* s);
+int fputs (char const* s);
+int puts (char const* s);
+int putchar (int c);
+int fputc (int c, int fd);
+int getchar ();
* libc/include/stdlib.h:
+char* getenv (char const* s)
+int atoi (char const *s);
+int *malloc (size_t);
+int *realloc (int *p, int size);
* libc/include/unistd.h (access):
* src/lib.c (display_helper):
* src/mes.c (read_input_file_env):
* src/posix.c: Include unistd.h.
2017-05-23 07:16:08 +02:00
Jan Nieuwenhuizen fe727301c5 mescc: Support regular C99 compile, headers + mlibc.
* libc/include/assert.h: New file.
* libc/include/ctype.h: New file.
* libc/include/errno.h: New file.
* libc/include/fcntl.h: New file.
* libc/include/limits.h: New file.
* libc/include/mlibc.h: New file.
* libc/include/stdio.h: New file.
* libc/include/stdlib: New file.
* libc/include/string.h: New file.
* libc/include/unistd.h: New file.
* libc/mlibc.c: Remove declarations.
* make/bin.make (INCLUDES): Factor out standard includes.
* make/bin-mlibc.make: New file.
* scaffold/scaffold.make: Use it.
* src/src.make: Use it.
* module/language/c99/compiler.mes (ast-info): Handle more function declarations.
* scaffold/cons-mes.c: Remove mlibc definitionsa and mlibc.c include.
  Instead include <mlibc.h>.
* scaffold/hello.c: Likewise.
* scaffold/m.c: Likewise.
* scaffold/malloc.c: Likewise.
* scaffold/micro-mes.c: Likewise.
* scaffold/mini-mes.c: Likewise.
* scaffold/t.c: Likewise.
* scaffold/tiny-mes.c: Likewise.
* src/gc.c: Likewise.
* src/lib.c: Likewise.
* src/math.c: Likewise.
* src/mes.c: Likewise.
* src/posix.c: Likewise.
* src/reader.c: Likewise.
2017-05-02 23:30:46 +02:00
Jan Nieuwenhuizen 38d30a3e42 build: Refactor.
* GNUmakefile (OUT,QUIET,SUBDIRS): New variables.
  include make/common.make
* .gitignore: Remove toplevel targets.
* build-aux/compile-all.scm: Import from GNU Guix.
* configure (gulp-pipe): Check exit status.  Actually test for CC,
  CC32.
* make/bin.make: New file.
* make/check.make: New file.
* make/clean.make: New file.
* make/common.make: New file.
* make/compile.make: New file.
* make/guile.make: New file.
* make/mescc-guile.make: New file.
* make/mescc-mes.make: New file.
* make/reset.make: New file.
* lib/mlibc.c: Rename from top.
* lib/start.c: Rename from top.
* module/module.make: New file.
* scaffold/scaffold.make: New file.
* scripts/scripts.make: New file.
* src/mes.c: Rename from top.
* src/src.make: New file.
* src/mes.c: Rename from top.
* src/gc..c: Rename from top.
* src/lib.c: Rename from top.
* src/posix.c: Rename from top.
* src/reader.c: Rename from top.
* src/vector.c: Rename from top.
* tests/tests.make: New file.
2017-04-12 21:27:59 +02:00