mes.git
3 years agobootstrap: Regenerate.
Jan Nieuwenhuizen [Tue, 25 Apr 2017 04:43:20 +0000 (06:43 +0200)]
bootstrap: Regenerate.

* mes.mes: Regenerate.

3 years agocore: Set argv for mescc too.
Jan Nieuwenhuizen [Mon, 24 Apr 2017 05:22:04 +0000 (07:22 +0200)]
core: Set argv for mescc too.

* src/mes.c (main)[!__MESC__]: Remove branch.

3 years agobootstrap: Regenerate.
Jan Nieuwenhuizen [Mon, 24 Apr 2017 05:16:18 +0000 (07:16 +0200)]
bootstrap: Regenerate.

* mes.mes: Regenerate.

3 years agomescc: Avoid duplication of globals.
Jan Nieuwenhuizen [Sun, 23 Apr 2017 11:53:36 +0000 (13:53 +0200)]
mescc: Avoid duplication of globals.

* module/language/c99/compiler.mes (globals:add-string): New function.
  (expr->arg): Use it to avoid globals duplication.
  (expr->accu): Do not pre-add globals.

3 years agomescc: Fix global creation in AND/OR clause.
Jan Nieuwenhuizen [Sun, 23 Apr 2017 11:53:08 +0000 (13:53 +0200)]
mescc: Fix global creation in AND/OR clause.

* module/language/c99/compiler.mes (test->jump->info): Retain globals
  created in AND/OR test.

3 years agocore: Move some debugging to MES_DEBUG=2.
Jan Nieuwenhuizen [Mon, 17 Apr 2017 21:32:02 +0000 (23:32 +0200)]
core: Move some debugging to MES_DEBUG=2.

* module/mes/base-0.mes (load): Add ;;;.
* src/gc.c (gc_flip): Test on g_debug > 1.
  (gc): Likewise.
* src/mes.c (mes_builtins): Likewise.
  (main): Likewise.
* src/reader.c (dump): Likewise.

3 years agomescc: Add atoi.
Jan Nieuwenhuizen [Mon, 17 Apr 2017 21:29:54 +0000 (23:29 +0200)]
mescc: Add atoi.

* libc/mlibc.c (atoi): New function.
* module/mes/libc.mes (atoi): New function.
  (libc): Add it.

3 years agomescc: Add getenv.
Jan Nieuwenhuizen [Mon, 17 Apr 2017 00:24:20 +0000 (02:24 +0200)]
mescc: Add getenv.

* module/mes/libc-i386.mes (i386:_start): Push environment pointer.
* module/mes/libc.mes (g_environment): New global.
  (_env): New function.
  (_start): Use it to set g_environment.
  (getenv): New function.
* lib/mlibc.c (strncmp): New function.
  (getenv): Implement.
* lib/mstart.c (_start): Set g_environment.
* module/mes/libc.mes (strncmp): New function.
  (libc): Add it.
* scaffold/t.c: (array_ref): Test it.

3 years agomescc: Support pointer arrays and some arithmetic.
Jan Nieuwenhuizen [Mon, 17 Apr 2017 00:15:11 +0000 (02:15 +0200)]
mescc: Support pointer arrays and some arithmetic.

* module/language/c99/compiler.mes (.name): Support **; handle type size.
  (.statements): Likewise.
  (push-local-de-ref): Likewise.
  (push-ident-de-ref): Likewise.
  (expr->arg): Likewise.
  (ident->accu):  Likewise.
  (base->ident-address):  Likewise.
  (ident-add): Likewise.
  (expr->accu):  Likewise.
  (decl->type):  Likewise.
  (formal->text):  Likewise.
  (int->global, ident-address->accu, ident-address->base): New functions.
  (ast->info): Support *, *[] ** declarations.
  (push-local-de-de-ref,  push-ident-de-de-ref): New functions.
* module/mes/as-i386.mes (i386:push-byte-local-de-ref): Rename from
  i386:push-local-de-ref.  Update callers.
  (i386:push-local-de-ref, i386:push-byte-local-de-de-ref,
  i386:accu-mem-add): New functions.
* module/mes/as-i386.scm (mes): Export them.
* scaffold/t.c (array_test): Test it.

3 years agobootstrap: Regenerate.
Jan Nieuwenhuizen [Tue, 25 Apr 2017 21:18:29 +0000 (23:18 +0200)]
bootstrap: Regenerate.

* mes.mes: Regenerate.
* module/mes/read-0-32.mo: Regenerate.

3 years agoAdd access?
Jan Nieuwenhuizen [Sun, 16 Apr 2017 07:51:45 +0000 (09:51 +0200)]
Add access?

* libc/mlibc.c (access): New function.
* module/mes/libc-i386.mes (i386:access): New function.
  (i386:libc): Add it.
* src/posix.c (access_p): New function.
* module/mes/posix.mes: New file.
* module/mes/base-0.mes (mes): Include it.
* module/mes/read-0-32.mo: Regenerate.

3 years agobootstrap: Regenerate
Jan Nieuwenhuizen [Tue, 25 Apr 2017 21:44:23 +0000 (23:44 +0200)]
bootstrap: Regenerate

* module/mes/read-0-32.mo: Regenerate.

3 years agobuild: Refactor.
Jan Nieuwenhuizen [Wed, 12 Apr 2017 19:27:59 +0000 (21:27 +0200)]
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.

3 years agoRemove gc scaffolding.
Jan Nieuwenhuizen [Sat, 15 Apr 2017 14:50:03 +0000 (16:50 +0200)]
Remove gc scaffolding.

* tests/gc-0.test: Remove.
* tests/gc-1.test: Remove.
* tests/gc-2.test: Remove.
* tests/gc-2a.test: Remove.
* tests/gc-3.test: Remove.
* tests/gc-4.test: Remove.
* tests/gc-5.test: Remove.
* tests/gc-6.test: Remove.
* tests/gc.test:Remove.

3 years agomescc: Add fsync.
Jan Nieuwenhuizen [Sat, 15 Apr 2017 13:13:38 +0000 (15:13 +0200)]
mescc: Add fsync.

* module/mes/libc-i386.mes (i386:fsync): New function.
  (i386:libc): Export it.
* mlibc.c (fsync): New function.

3 years agocore/mini-mes: Merge merge mes.c and mini-mes.c.
Jan Nieuwenhuizen [Mon, 10 Apr 2017 17:13:20 +0000 (19:13 +0200)]
core/mini-mes: Merge merge mes.c and mini-mes.c.

* mes.c:
* scaffold/mini-mes.c:
* gc.c:
* GNUmakefile:

3 years agomescc: Allow usage of const by ignoring.
Jan Nieuwenhuizen [Mon, 10 Apr 2017 06:06:33 +0000 (08:06 +0200)]
mescc: Allow usage of const by ignoring.

* module/language/c99/compiler.mes (ast->info): Support const
  declarations (by ignoring them).
* lib.c (display_helper)[!__GNUC__]: Remove branch.
* posix.c (write_byte)[!__GNUC__]: Likewise.

3 years agoHACKING: Removed __MESC__ workarounds.
Jan Nieuwenhuizen [Mon, 10 Apr 2017 05:54:38 +0000 (07:54 +0200)]
HACKING: Removed __MESC__ workarounds.

* HACKING: Update pointer.

3 years agomescc: Support break in while.
Jan Nieuwenhuizen [Mon, 10 Apr 2017 04:59:50 +0000 (06:59 +0200)]
mescc: Support break in while.

* module/language/c99/compiler.mes (make): Add break field.
  (.break): New function.
  (clone): Support break field.
  (ast->info): Support break.
* scaffold/t.c (test): Test it.
* scaffold/mini-mes.c (lookup_symbol_): Use it; remove goto workaround.

3 years agomescc: Refactor switch.
Jan Nieuwenhuizen [Sun, 9 Apr 2017 04:52:39 +0000 (06:52 +0200)]
mescc: Refactor switch.

* module/language/c99/compiler.mes (case->jump-info): Refactor.
  Support multiple case statements.
* scaffold/t.c (swits): Test it.
* lib.c (display_helper)[__NYACC__]: Remove branch.

3 years agomini-mes: Merge with mes.c: lib.c, math.c, posix.c.
Jan Nieuwenhuizen [Sat, 8 Apr 2017 13:01:24 +0000 (15:01 +0200)]
mini-mes: Merge with mes.c: lib.c, math.c, posix.c.

* mes.c: Include math.c after posix.c.
  (assert_defined, check_formals, check_apply, load_env,
  bload_env): Move from lib.c
* scaffold/mini-mes.c: Include mini-lib.h, lib.c., mini-math.h,
  math.c, mini-posix.h, posix.c.
  (greater_p, less_p, is_p, minus, plus, divide, modulo, multiply,
  logior, ash): Remove.
  (ungetchar, peekchar, peek_byte, read_byte, write_byte,
  string_to_cstring, getenv_, open_input_file, current_input_port,
  set_current_input_port, force_output): Remove.
  (mes_builtins): include mini-lib.i, mini-lib.environment.i.
  mini-math.i, mini-math.environment.i mini-posix.i,
  mini-posix.environment.i.
* GNUmakefile (guile-mini-mes): Add dependencies.

3 years agomescc: Refactor assignment.
Jan Nieuwenhuizen [Sat, 8 Apr 2017 04:31:12 +0000 (06:31 +0200)]
mescc: Refactor assignment.

* module/language/c99/compiler.mes (expr->accu): Refactor assignment.
  Support multiple operators.
* scaffold/t.c (math_test): Test it.
* scaffold/mini-mes.c (minus, divide, modulo, multiply,
  logior)[!__GNUC__]: Remove branch.

3 years agomescc: Factor-out array-ref.
Jan Nieuwenhuizen [Fri, 7 Apr 2017 21:06:09 +0000 (23:06 +0200)]
mescc: Factor-out array-ref.

* module/language/c99/compiler.mes: Factor-out array-ref.

3 years agomescc: Refactor expr->base.
Jan Nieuwenhuizen [Fri, 7 Apr 2017 12:41:47 +0000 (14:41 +0200)]
mescc: Refactor expr->base.

* module/language/c99/compiler.mes (expr->base): Rename from
  expr->+base.  Use throughout.

3 years agomescc: Refactor binary operators.
Jan Nieuwenhuizen [Fri, 7 Apr 2017 12:31:35 +0000 (14:31 +0200)]
mescc: Refactor binary operators.

* module/language/c99/compiler.mes (binop->accu): Rename from
  compare->accu.  Update callers.
  (expr->accu): Use it for binary operators.
* scaffold/t.c (math_test): Test it.

3 years agomescc: Factor-out append-text.
Jan Nieuwenhuizen [Fri, 7 Apr 2017 07:53:56 +0000 (09:53 +0200)]
mescc: Factor-out append-text.

* module/language/c99/compiler.mes: Use append-text throughout.

3 years agomescc: Factor-out wrap-as.
Jan Nieuwenhuizen [Fri, 7 Apr 2017 07:36:30 +0000 (09:36 +0200)]
mescc: Factor-out wrap-as.

* module/language/c99/compiler.mes (wrap-as): Rename from wrap.  Use throughout.

3 years agomescc: Refactor comparisons.
Jan Nieuwenhuizen [Fri, 7 Apr 2017 05:06:35 +0000 (07:06 +0200)]
mescc: Refactor comparisons.

* module/language/c99/compiler.mes (compare->accu, append-text, wrap):
  New functions.
  (expr->accu): Use them to implement construct like 1 == inc (0).
* scaffold/t.c (math_test): Test them.

3 years agoHACKING: Removed gc.c, vector.c mescc workarounds.
Jan Nieuwenhuizen [Thu, 6 Apr 2017 21:15:59 +0000 (23:15 +0200)]
HACKING: Removed gc.c, vector.c mescc workarounds.

* HACKING: Update pointer and recipe.

3 years agomescc: Refactor array ref.
Jan Nieuwenhuizen [Thu, 6 Apr 2017 21:05:44 +0000 (23:05 +0200)]
mescc: Refactor array ref.

* module/language/c99/compiler.mes (expr->accu, expr->accu*): Remove
  duplication, use expression as array index.
* scaffold/t.c (struct_test): Test it.
* vector.c (vector_length, list_to_vector)[!__GNUC__]: Remove branch.

3 years agomescc: Refactor expressions.
Jan Nieuwenhuizen [Thu, 6 Apr 2017 07:12:50 +0000 (09:12 +0200)]
mescc: Refactor expressions.

* module/language/c99/compiler.mes (expr->accu, ast->info): Remove
  duplication, separate concerns.

3 years agomescc: Refactor pre/post inc/dec.
Jan Nieuwenhuizen [Wed, 5 Apr 2017 21:05:16 +0000 (23:05 +0200)]
mescc: Refactor pre/post inc/dec.

* module/language/c99/compiler.mes: Refactor pre/post inc/dec.

3 years agobootstrap: Regenerate.
Jan Nieuwenhuizen [Wed, 5 Apr 2017 20:43:41 +0000 (22:43 +0200)]
bootstrap: Regenerate.

* mes-mini-mes: Regenerate.
* module/mes/read-0-32.mes: Regenerate.

3 years agomescc: function call.
Jan Nieuwenhuizen [Wed, 5 Apr 2017 18:11:13 +0000 (20:11 +0200)]
mescc: function call.

* module/language/c99/compiler.mes (expr->accu): Move function call
  from ast->info.

3 years agomescc: Support expression as lhs array index.
Jan Nieuwenhuizen [Wed, 5 Apr 2017 12:24:34 +0000 (14:24 +0200)]
mescc: Support expression as lhs array index.

* module/language/c99/compiler.mes (expr->accu): Treat array index as expression.
* scaffold/t.c (struct_test): Test it.
* gc.c (gc_copy)[!__GNUC__]: Remove branch.
* vector.c (list_to_vector)[!__GNUC__]: Likewise.

3 years agomescc: Remove duplication.
Jan Nieuwenhuizen [Tue, 4 Apr 2017 12:37:17 +0000 (14:37 +0200)]
mescc: Remove duplication.

* module/language/c99/compiler.mes (expr->arg): Use expr->accu for
  most expressions.

3 years agoscripts: Support --help, --version.
Jan Nieuwenhuizen [Tue, 4 Apr 2017 07:53:05 +0000 (09:53 +0200)]
scripts: Support --help, --version.

* guile/mescc.scm: Support --help, --version.
* scripts/mescc.mes: Likewise.
* scripts/repl.mes: Likewise.

3 years agoscm: Do not quote list of strings.
Jan Nieuwenhuizen [Mon, 3 Apr 2017 05:19:38 +0000 (07:19 +0200)]
scm: Do not quote list of strings.

* module/mes/display.mes (display): Check value of write?, fixes
  quoting display string.

3 years agomescc: Do not return ELF text.
Jan Nieuwenhuizen [Mon, 3 Apr 2017 05:09:03 +0000 (07:09 +0200)]
mescc: Do not return ELF text.

* module/language/c99/compiler.mes (info->exe): Do not return ELF text.

3 years agobuild: Update Guix build and install.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 16:50:07 +0000 (18:50 +0200)]
build: Update Guix build and install.

* guix.scm (%source-dir): New variable.
  (git-file?): New function.
  (mes): Use them to simplify building/installing from git.
* make/install.make (READMES): Add INSTALL, README.
* (install): Install mescc.scm and read-0-32.mo.

3 years agobootstrap: Regenerate.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 10:41:33 +0000 (12:41 +0200)]
bootstrap: Regenerate.

* mes-mini-mes: First self-hosting binary.

3 years agoHACKING: scripts/mescc.mes scaffold/mini-mes runs.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 11:27:00 +0000 (13:27 +0200)]
HACKING: scripts/mescc.mes scaffold/mini-mes runs.

* HACKING: Update pointer and recipe.

3 years agomini-mes: Fix for assq.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 11:18:22 +0000 (13:18 +0200)]
mini-mes: Fix for assq.

* scaffold/mini-mes.c (assq): Use eq_p iso ==.  Fixes
  tests/display.test ("write alarm").

3 years agocore: Use 0.25% safety region.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 10:58:18 +0000 (12:58 +0200)]
core: Use 0.25% safety region.

* gc.c (gc_up_arena): Up GC_SAFETY too.
* scripts/repl.mes: Remove MES_ARENA override.

3 years agobootstrap: Regenerate.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 11:21:01 +0000 (13:21 +0200)]
bootstrap: Regenerate.

* module/mes/read-0-32.mo: Regenerate.

3 years agocore: Remove append.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 06:05:55 +0000 (08:05 +0200)]
core: Remove append.

* lib.c (append): Remove.
* scaffold/mini-mes.c (append): Remove.
* module/mes/base-0.mes (append): New function.
* module/mes/read-0.mo: Regenerate.
* module/mes/read-0-32.mo: Regenerate.

3 years agotest: Add test for append-map.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 06:04:25 +0000 (08:04 +0200)]
test: Add test for append-map.

* tests/srfi-1.test ("append-map"): New test.

3 years agocore: Check gc free harder.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 21:00:50 +0000 (23:00 +0200)]
core: Check gc free harder.

* gc.c (gc_check): New fuction.
* mes.c (eval_apply): Use it.

3 years agomescc: Fix by value assignment from array-of struct entry.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 21:12:37 +0000 (23:12 +0200)]
mescc: Fix by value assignment from array-of struct entry.

* module/language/c99/compiler.mes (expr->accu): Fix by value
  assignment from array-of struct entry.
* scaffold/t.c (struct_test): Test it.
* vector.c (make_vector, list_to_vector, vector_to_list): Use it;
  remove workarounds.
* gc.c (gc_copy): Likewise.

3 years agocore: Fix flush for _POSIX_SOURCE.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 18:25:03 +0000 (20:25 +0200)]
core: Fix flush for _POSIX_SOURCE.

* posix.c (write_byte, force_output)[_POSIX_SOURCE]: Use FILE*
  functions.  Fixes repl.mes.

3 years agocore: Increase MAX_ARENA_SIZE and GC safety.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 17:10:28 +0000 (19:10 +0200)]
core: Increase MAX_ARENA_SIZE and GC safety.

* mes.c (MAX_ARENA_SIZE): Double to 40000000.
 (GC_SAFETY): Set to 10000 cells (WAS: 1000).
* scaffold/mini-mes.c (MAX_ARENA_SIZE, GC_SAFETY): Likewise.
* gc.c (gc)[MES_DEBUG]: Also print safety area.

3 years agoHACKING: scripts/mescc.mes scaffold/t.c runs.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 15:07:28 +0000 (17:07 +0200)]
HACKING: scripts/mescc.mes scaffold/t.c runs.

3 years agocore: Increase GC safety.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 14:51:48 +0000 (16:51 +0200)]
core: Increase GC safety.

* mes.c (GC_SAFETY): Set to 1000 cells (WAS: 100).
* scaffold/mini-mes.c (GC_SAFETY): Likewise.

3 years agoHACKING: scripts/mescc.mes scaffold/tiny-mes.c runs.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 14:15:08 +0000 (16:15 +0200)]
HACKING: scripts/mescc.mes scaffold/tiny-mes.c runs.

3 years agoHACKING: scripts/mescc.mes scaffold/cons-mes.c runs.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 14:12:51 +0000 (16:12 +0200)]
HACKING: scripts/mescc.mes scaffold/cons-mes.c runs.

3 years agotest: Add nyacc cpp match tests; two fail.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 13:06:07 +0000 (15:06 +0200)]
test: Add nyacc cpp match tests; two fail.

* tests/match.test ("match nyacc 0", "match nyacc 1"): New tests.
 ("match nyacc simple", "match nyacc tkl0"): New tests; FAIL with Mes.
 (report): Set failure expectation to 2 for Mes.
* HACKING: Add to bugs.

3 years agoscm: Support test failure expectation.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 13:01:59 +0000 (15:01 +0200)]
scm: Support test failure expectation.

* module/mes/test.mes (result): Take second argument to mean expected
  failure count.

3 years agoscm: Evaluate arguments of OR only once.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 14:47:22 +0000 (16:47 +0200)]
scm: Evaluate arguments of OR only once.

* module/mes/base.mes (or): Evaluate arguments only once.
* module/mes/read-0.mes (or): Likewise.
* tests/base.test ("or only once"): Test it.
* module/mes/read-0-32.mo: Regenerate.

3 years agoscm: Have char-set-contains? strictly return boolean.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 07:36:34 +0000 (09:36 +0200)]
scm: Have char-set-contains? strictly return boolean.

* module/srfi/srfi-14.mes (char-set-contains?): Return #t rather than
  memq result.

3 years agoscm: Fix bug in assq-set!
Jan Nieuwenhuizen [Sat, 1 Apr 2017 05:23:10 +0000 (07:23 +0200)]
scm: Fix bug in assq-set!

* module/mes/scm.mes (assq-set!): Bugfix.

3 years agoscm: Add c????r.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 07:35:47 +0000 (09:35 +0200)]
scm: Add c????r.

* module/mes/base-0.mes (caar, cadr, cdar, cddr, map): Remove.  Update callers.
* module/mes/base.mes (): Remove.
* module/mes/base.mes (cadadr, cddadr, cdddar): New function.

3 years agoscm: Add access?
Jan Nieuwenhuizen [Fri, 31 Mar 2017 19:41:32 +0000 (21:41 +0200)]
scm: Add access?

* module/mes/guile.mes (access?): New dummy function.  Fixes Nyacc's #include.

3 years agodoc: Add Roamdmap.
Jan Nieuwenhuizen [Wed, 29 Mar 2017 06:05:18 +0000 (08:05 +0200)]
doc: Add Roamdmap.

* HACKING: Add roadmap.

3 years agoscm: Add open-input-string, read-string.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 10:51:35 +0000 (12:51 +0200)]
scm: Add open-input-string, read-string.

* module/mes/guile.mes (open-input-string, read-string): New functions.
* tests/guile.test: New file.
* GNUmakefile (TESTS): Add it.

3 years agobuild: Cleanup, use gcc-specific snarfing.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 15:01:22 +0000 (17:01 +0200)]
build: Cleanup, use gcc-specific snarfing.

* .gitignore: Ignore *.o-32, mes-mini-mes.
* scripts/nyacc-calc.mes: Remove.
* scripts/nyacc.mes: Remove.
* scripts/paren.mes: Remove.
* make/install.make (install): Remove them.
p* module/mes/mes-0.mes: Remove.
* module/mes/loop-0.mes: Remove.
* build-aux/mes-snarf.scm (main): Add --mini option.
* GNUmakefile (mini-mes): Use it.

3 years agocore: Fix error message when macro is missing.
Jan Nieuwenhuizen [Mon, 27 Mar 2017 18:14:48 +0000 (20:14 +0200)]
core: Fix error message when macro is missing.

* mes.c (scm_vm_eval_check_func): New symbol.
  (eval_apply): In eval, evaluate car before evlis.  Fixes error
  message when macro match is missing in (match ... (car x)).
  (mes_symbols): Add cell_call_with_values, cell_current_module to environment.
* scaffold/mini-mes.c (eval_apply): Likewise.

3 years agotest: Add pmatch tests.
Jan Nieuwenhuizen [Wed, 29 Mar 2017 06:07:51 +0000 (08:07 +0200)]
test: Add pmatch tests.

* tests/pmatch.test: New file.
* GNUmakefile (TESTS): Add it.

3 years agonyacc: prefix globals.
Jan Nieuwenhuizen [Tue, 28 Mar 2017 18:26:16 +0000 (20:26 +0200)]
nyacc: prefix globals.

3 years agoscm: Bugfix display of named characters: add port.
Jan Nieuwenhuizen [Mon, 27 Mar 2017 19:41:44 +0000 (21:41 +0200)]
scm: Bugfix display of named characters: add port.

* module/mes/display.mes (display): Typo, add port.

3 years agonyacc: Add missing (mes pmatch) include.
Jan Nieuwenhuizen [Mon, 27 Mar 2017 19:01:22 +0000 (21:01 +0200)]
nyacc: Add missing (mes pmatch) include.

* module/nyacc/lang/c99/cpp.mes (mes): Include (mes pmatch).

3 years agonyacc: Use pmatch rather than match for cpp.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 10:16:09 +0000 (12:16 +0200)]
nyacc: Use pmatch rather than match for cpp.

* module/nyacc/lang/c99/cpp.scm (nyacc lang c99 cpp): Import (system
  base pmatch) rather than (ice-9 match).
  (rtokl->string): Rewrite using pmatch.

3 years agoscm: Bugfix drain-input.
Jan Nieuwenhuizen [Mon, 27 Mar 2017 19:00:49 +0000 (21:00 +0200)]
scm: Bugfix drain-input.

* module/mes/guile.mes (drain-input): Bugfix: return string.

3 years agoscm: Add assoc-set!
Jan Nieuwenhuizen [Mon, 27 Mar 2017 05:01:15 +0000 (07:01 +0200)]
scm: Add assoc-set!

* module/mes/scm.mes (assoc-set!): New function.
* tests/scm.test ("assoc-set!", "assoc-set! new"): New tests.

3 years agoscm: Add compose.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 22:35:36 +0000 (00:35 +0200)]
scm: Add compose.

* module/mes/scm.mes (compose): New function.
* tests/scm.test ("compose"): New test.

3 years agoscm: Support reading negative hex numbers.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 22:11:05 +0000 (00:11 +0200)]
scm: Support reading negative hex numbers.

* module/mes/read-0.mes (read-hex): Support negative hex numbers.
* tests/math.test ("#x-10"): New test.
* tests/read.test: Add test.

3 years agoscm: Support map4.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 21:48:15 +0000 (23:48 +0200)]
scm: Support map4.

* module/mes/base-0.mes (map): Remove.  Update callers.
* module/mes/base.mes (map): Support map4.

3 years agonyacc: Add simple split-cppdef for Mes.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 21:09:44 +0000 (23:09 +0200)]
nyacc: Add simple split-cppdef for Mes.

* module/nyacc/lang/c99/body.scm: Add non-regexp split-cppdef for Mes.

3 years agoscm: Add with-throw-handler hack.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 21:09:11 +0000 (23:09 +0200)]
scm: Add with-throw-handler hack.

* module/mes/catch.mes (with-throw-handler): Add hack for Nyacc 0.75

3 years agoscm: Add list->char-set.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 20:33:51 +0000 (22:33 +0200)]
scm: Add list->char-set.

* module/srfi/srfi-14.mes (list->char-set): New function.
* tests/srfi-14.test ("list->char-set!"): Test it.

3 years agomini-mes: Debugging to stderr.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 20:12:24 +0000 (22:12 +0200)]
mini-mes: Debugging to stderr.

* scaffold/mini-mes.c (error, bload_env, main): Send debug info to
  stderr.

throw/catch dinges: URG

3 years agoscripts: Allow running with any mes.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 20:09:24 +0000 (22:09 +0200)]
scripts: Allow running with any mes.

* scripts/mescc.mes: Run $MES if set, default to ../scripts/mes.
* scripts/repl.mes: Likewise.

3 years agomini-mes: Include and enable gc.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 14:03:41 +0000 (16:03 +0200)]
mini-mes: Include and enable gc.

* scaffold/mini-mes.c: Set MES_GC=1.
 (ARENA_SIZE)[MES_GC]: Reduce to 10,000 cells (WAS: 1,000,000,000
 chars).
 (g_news): New global.
 (NTYPE, NCAR, NVALUE, NLENGTH, NCDR, NVECTOR): New macros.
 (mes_symbols)[MES_GC]: Call gc_init_news.
 (mes_builtins): Include gc.i, gc.environment.i.

3 years agomini-mes: Workarounds for gc.c.
Jan Nieuwenhuizen [Sat, 1 Apr 2017 21:30:45 +0000 (23:30 +0200)]
mini-mes: Workarounds for gc.c.

* gc.c (gc_copy)[!__GNUC__]: Avoid by value assignment from array-of
  struct entry.
* scaffold/mini-mes.c (gc_init_cells): Workarounds.

3 years agocore: Prepare gc.c for mescc, non-POSIX_SOURCE.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 13:55:12 +0000 (15:55 +0200)]
core: Prepare gc.c for mescc, non-POSIX_SOURCE.

* mes.c (NLENGTH, NVALUE, NVECTOR): New macros.
  (mes_builtins): Add comment on .i include order.
* module/language/c99/compiler.mes (mescc): Add define _POSIX_SOURCE=0.
* gc.c (gc_up_arena, gc_flip, gc_loop, gc)[!_POSIX_SOURCE]: Use eputs
  rather than fprintf.
  (gc_loop): Use CAR, TYPE, NVECTOR rather than .car, .type, .vector.
* gc.c (gc_up_arena)[!_POSIX_SOURCE]: Add non-POSIX mlib.c
  implementation.

3 years agomescc: Bugfix for realloc.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 13:49:45 +0000 (15:49 +0200)]
mescc: Bugfix for realloc.

* module/mes/libc.mes (realloc): Thinko.

3 years agomescc: Bugfix for neg.
Jan Nieuwenhuizen [Sat, 25 Mar 2017 18:03:03 +0000 (19:03 +0100)]
mescc: Bugfix for neg.

* module/language/c99/compiler.mes (expr->accu): Fix neg.
* scaffold/t.c (math_test): Test it.
* scaffold/mini-mes.c (ash): Remove workaround.

3 years agomescc: Support rshift, have guile-mini-mes pass math test.
Jan Nieuwenhuizen [Sat, 25 Mar 2017 17:48:40 +0000 (18:48 +0100)]
mescc: Support rshift, have guile-mini-mes pass math test.

* module/mes/as-i386.mes (i386:accu>>base): New function.
* module/mes/as-i386.scm (mes): Export it.
* module/language/c99/compiler.mes (expr->accu): Support rshift.
* scaffold/t.c (math_test): Test it.
* scaffold/mini-mes.c (ash): Use it.

3 years agotest: Enable vector read test.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 14:47:18 +0000 (16:47 +0200)]
test: Enable vector read test.

* tests/read.test: Enable vector read test.

3 years agomini-mes: Support vectors.
Jan Nieuwenhuizen [Sat, 25 Mar 2017 13:05:17 +0000 (14:05 +0100)]
mini-mes: Support vectors.

* scaffold/mini-mes.c (REF, MAKE_REF): New macro.
  Include vector.h, vector.c.
  (mes_builtins): Include vector.i, vector.environment.i.

3 years agomini-mes: Workarounds for vector.c.
Jan Nieuwenhuizen [Sat, 25 Mar 2017 16:15:07 +0000 (17:15 +0100)]
mini-mes: Workarounds for vector.c.

* vector.c (make_vector, vector_set_x, list_to_vector)[!__GNUC__]: Avoid
  by value assignment from array-of struct entry.

3 years agocore: prepare vector.c for mescc.
Jan Nieuwenhuizen [Sat, 25 Mar 2017 13:04:48 +0000 (14:04 +0100)]
core: prepare vector.c for mescc.

* vector.c (make_vector, vector_set_x, vector_to_list): Use REF, VALUE
  rather than .ref, .value.

3 years agomini-mes: Fully remove reader from core.
Jan Nieuwenhuizen [Sat, 25 Mar 2017 14:58:44 +0000 (15:58 +0100)]
mini-mes: Fully remove reader from core.

* scaffold/mini-mes.c (lookup_): Remove.
* mes.c: Likewise.
* reader.c (lookup_): Enable.
* mlib.c (putc): New function.
* module/mes/libc.mes (putc): New function.

3 years agomescc: Support bitwise or.
Jan Nieuwenhuizen [Fri, 24 Mar 2017 22:15:01 +0000 (23:15 +0100)]
mescc: Support bitwise or.

* module/mes/as-i386.mes (i386:accu-or-base): New function.
* module/mes/as-i386.scm: Export it.
* module/language/c99/compiler.mes (expr->accu): Use it; support bitwise or.
* scaffold/t.c (math_test): Test it.
* scaffold/mini-mes.c (logior): Use it.

3 years agomescc: Lshift support non-fixed shift value.
Jan Nieuwenhuizen [Fri, 24 Mar 2017 21:32:02 +0000 (22:32 +0100)]
mescc: Lshift support non-fixed shift value.

* module/mes/as-i386.mes (i386:accu<<base): New function.
* module/mes/as-i386.scm: Export it.
* module/language/c99/compiler.mes (expr->accu): Use it.
* scaffold/t.c (math_test): Test it.

3 years agomescc: Use signed integer comparison.
Jan Nieuwenhuizen [Fri, 24 Mar 2017 20:45:19 +0000 (21:45 +0100)]
mescc: Use signed integer comparison.

* module/language/c99/compiler.mes (test->jump->info):
* module/mes/as-i386.mes (i386:Xjump-le, i386:Xjump-g, i386:Xjump-l,
  i386:Xjump-ge): New functions.
* module/mes/as-i386.scm: Export them.
* scaffold/t.c (math_test): Test them.
* tests/scm.test ("iota -1"): Enable for mesc.

3 years agomescc: Run module/base-0.mes.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 19:13:01 +0000 (21:13 +0200)]
mescc: Run module/base-0.mes.

* gc.c: New file.
* vector.c: New file.
* mes.c: Remove vector and gc functions, include vector.c, gc.c.
* GNUmakefile (mes.o): Add gc, vector dependencies.
* scaffold/mini-mes.c (eval_apply): Support primitive-load through
  read_input_file.
  (getenv_, open_input_file, current_input_port,
  set_current_input_port force_output, exit_, values, arity_, xassq,
  is_p, minus, plus, divide, modulo multiply, logior, ash): New function.
  (mes_symbols): Add symbols %gnuc, %mesc.
* scaffold/mini-mes.c (): New functions.
* scaffold/b-0.mes: New file.
* scaffold/t-0.mes: New file.

3 years agotest: Allow running with any mes.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 19:06:19 +0000 (21:06 +0200)]
test: Allow running with any mes.

* test/base.test: Run $MES if set, default to ../scripts/mes.
* tests/base.test: Likewise.
* tests/catch.test: Likewise.
* tests/closure.test: Likewise.
* tests/cwv.test: Likewise.
* tests/display.test: Likewise.
* tests/fluids.test: Likewise.
* tests/gc-0.test: Likewise.
* tests/gc-1.test: Likewise.
* tests/gc-2.test: Likewise.
* tests/gc-2a.test: Likewise.
* tests/gc-3.test: Likewise.
* tests/gc-4.test: Likewise.
* tests/gc-5.test: Likewise.
* tests/gc-6.test: Likewise.
* tests/gc.test: Likewise.
* tests/let-syntax.test: Likewise.
* tests/let.test: Likewise.
* tests/match.test: Likewise.
* tests/math.test: Likewise.
* tests/module.test: Likewise.
* tests/optargs.test: Likewise.
* tests/peg.test: Likewise.
* tests/psyntax.test: Likewise.
* tests/quasiquote.test: Likewise.
* tests/read.test: Likewise.
* tests/record.test: Likewise.
* tests/scm.test: Likewise.
* tests/srfi-1.test: Likewise.
* tests/srfi-13.test: Likewise.
* tests/srfi-14.test: Likewise.
* tests/vector.test: Likewise.

3 years agoscm+test: Factor-out math and vector.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 09:34:40 +0000 (11:34 +0200)]
scm+test: Factor-out math and vector.

* module/mes/base-0.mes (quotient): Remove.
* module/mes/scm.mes (quotient): Add.
* tests/scm.test: Remove arithmetic/math tests.
* tests/math.test: New file.
* GNUmakefile (TESTS): Add it

3 years agomescc: Have ungetc remember 2 positions.
Jan Nieuwenhuizen [Thu, 23 Mar 2017 17:57:06 +0000 (18:57 +0100)]
mescc: Have ungetc remember 2 positions.

* doc/examples/t.c (read_test): Test it.
* doc/examples/mini-mes.c:
* mlibc.c (getchar, ungetc): Support 2 ungetc positions.
* module/mes/libc.mes (getchar, ungetc): Likewise.

3 years agomescc: Add brk, naive malloc.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 10:31:15 +0000 (12:31 +0200)]
mescc: Add brk, naive malloc.

* scaffold/mini-mes.c (gc_init_cells): Use malloc to init g_cells.
* scaffold/malloc.c: New file.
* GNUmakefile (malloc, guile-malloc): New targets.
* module/mes/libc-i386.mes (i386:brk): New function.
  (i386:libc): Add it.
* mlibc.c (brk): New function.
  (malloc): Use it.
  (realloc): New function.
* module/mes/libc.mes (malloc, realloc): New functions.