mes.git
5 years agomescc: Enhance enum support.
Jan Nieuwenhuizen [Sat, 6 May 2017 17:31:00 +0000 (19:31 +0200)]
mescc: Enhance enum support.

* module/language/c99/compiler.mes (ast->info): Support enum variable
  declaration.  Respect field value overrides.

5 years agomescc: Support binary constants.
Jan Nieuwenhuizen [Sat, 6 May 2017 16:16:24 +0000 (18:16 +0200)]
mescc: Support binary constants.

* module/language/c99/compiler.mes (cstring->number): Support binary 0bxxx values.
* scaffold/t.c (math_test): Test it.

5 years agomescc: Support ==, != as expression value.
Jan Nieuwenhuizen [Sat, 6 May 2017 15:30:14 +0000 (17:30 +0200)]
mescc: Support ==, != as expression value.

* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (expr->accu): Set accu to 0/1 for eq, ne.
* module/mes/as-i386.mes (i386:nz->accu, i386:z->accu,
  i386:accu<->stack): New functions.
* scaffold/t.c (math_test): Test it.

5 years agomescc: Support &, ^.
Jan Nieuwenhuizen [Sat, 6 May 2017 12:57:39 +0000 (14:57 +0200)]
mescc: Support &, ^.

* module/mes/as-i386.mes (i386:accu-and-base, i386:accu-xor-base): New functions.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (expr->accu): Support bitwise-and, bitwise-xor.

5 years agomescc: Support struct pointers.
Jan Nieuwenhuizen [Sat, 6 May 2017 09:01:58 +0000 (11:01 +0200)]
mescc: Support struct pointers.

* module/language/c99/compiler.mes (expr->accu): Support
  &struct.field, struct->field.
  (ast->info): Support struct *foo = &bar;
* scaffold/t.c (struct_test): Test it.

5 years agomescc: Support struct definition with variable declaration.
Jan Nieuwenhuizen [Sat, 6 May 2017 07:27:28 +0000 (09:27 +0200)]
mescc: Support struct definition with variable declaration.

* module/language/c99/compiler.mes (ast->info): Support `struct foo {} bar;'.

5 years agomescc: Support void functions.
Jan Nieuwenhuizen [Sat, 6 May 2017 07:11:42 +0000 (09:11 +0200)]
mescc: Support void functions.

* module/language/c99/compiler.mes (function->info): Add return if
  missing.  Fixes calling void functions (and functions where return
  is missing).
* scaffold/t.c (void_func): Test it.

5 years agomescc: Bugfix for break in switch not in compound.
Jan Nieuwenhuizen [Sat, 6 May 2017 06:39:04 +0000 (08:39 +0200)]
mescc: Bugfix for break in switch not in compound.

* module/language/c99/compiler.mes (clause->jump-info): Rename from
  case->jump-info.
  (statements->clauses): New function.
  (ast->info): Use it.  Fixes switch statement with break in a case
  outside of a compound.
* scaffold/t.c (swits): Test it.

5 years agomescc: Enhance [int/pointer] array support.
Jan Nieuwenhuizen [Fri, 5 May 2017 07:24:19 +0000 (09:24 +0200)]
mescc: Enhance [int/pointer] array support.

* module/language/c99/compiler.mes (p-expr->type): Handle array-ref
  with any index.
  (ast->info): Support plain array declerations.
  (expr->accu): For size == 4, assume value in accu.  Fixes int/pointer arrays.
* scaffold/t.c: Test it.

5 years agomescc: Enhance struct support.
Jan Nieuwenhuizen [Thu, 4 May 2017 17:39:23 +0000 (19:39 +0200)]
mescc: Enhance struct support.

* module/language/c99/compiler.mes (expr->accu): Remove struct scm
  hardcoding.
  (p-expr->type): New function.
  (ast->info): Support struct variable declaration without
  initializer.  Set struct type for all struct declarations.

5 years agomescc: Fix itoa for negative numbers, using workaround.
Jan Nieuwenhuizen [Wed, 3 May 2017 21:01:49 +0000 (23:01 +0200)]
mescc: Fix itoa for negative numbers, using workaround.

* module/mes/libc.mes (itoa): Avoid `sign = x < 0;' FIXME, todo.
* scaffold/t.c (test): Test it.

5 years agomescc: Support regular C99 compile, headers + mlibc.
Jan Nieuwenhuizen [Tue, 2 May 2017 21:30:46 +0000 (23:30 +0200)]
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.

5 years agomescc: Support list of initializers.
Jan Nieuwenhuizen [Wed, 3 May 2017 06:09:19 +0000 (08:09 +0200)]
mescc: Support list of initializers.

* module/language/c99/compiler.mes (ast->info): Support list of initializers.

5 years agomescc: Basic printf support.
Jan Nieuwenhuizen [Tue, 2 May 2017 15:00:07 +0000 (17:00 +0200)]
mescc: Basic printf support.

* module/mes/libc-i386.mes (i386:va-arg): New function.
* module/mes/libc-i386.scm (mes): Export it.
* module/mes/libc.mes (printf): New function.
  (libc): Add it.
* libc/include/stdio.h: New file.
* module/language/c99/compiler.mes (c99-input->ast): Add libc/include
  to include path.
  (ast-info): Handle (skip) ellipsis in function declaration.

5 years agoguix: Update from Guix.
Jan Nieuwenhuizen [Tue, 2 May 2017 14:58:56 +0000 (16:58 +0200)]
guix: Update from Guix.

* guix.scm: Use version from Guix.
* make/install.make (update-hash): Update version for new Guix meme.

5 years agomake: Recompile .go too when included mes is touched.
Jan Nieuwenhuizen [Tue, 2 May 2017 14:56:14 +0000 (16:56 +0200)]
make: Recompile .go too when included mes is touched.

* build-aux/compile-all.scm (scm->mes): New function.
  (file-needs-compilation?): Use it to hackishly respect (include-[from-path] "<>.mes")

5 years agobuild: Resolve MODULEDIR confusion. Fixes mes installation.
Jan Nieuwenhuizen [Fri, 5 May 2017 20:13:01 +0000 (22:13 +0200)]
build: Resolve MODULEDIR confusion.  Fixes mes installation.

* make/install.make (GUILEDIR): New variable.  Was MODULEDIR.
  (MODULEDIR): Mes' module dir.
* guile/mescc.scm: Update.
* src/mes.c (load_env, bload_env): Update.

5 years agoguix hash: 01m8n7zk4f1ryd61dj589zarx09vbi7fc5f8m1x5zfk6r7l0zja2
Jan Nieuwenhuizen [Tue, 2 May 2017 12:08:59 +0000 (14:08 +0200)]
guix hash: 01m8n7zk4f1ryd61dj589zarx09vbi7fc5f8m1x5zfk6r7l0zja2

5 years agoguix.scm: Remove erroneous system restriction.
Jan Nieuwenhuizen [Thu, 27 Apr 2017 12:04:51 +0000 (14:04 +0200)]
guix.scm: Remove erroneous system restriction.

* guix.scm (mes): Remove second erroneous system restriction.

5 years agoRelease 0.5. v0.5
Jan Nieuwenhuizen [Sun, 25 Dec 2016 14:51:53 +0000 (15:51 +0100)]
Release 0.5.

* configure (VERSION): Bump.

5 years agobootstrap: Regenerate.
Jan Nieuwenhuizen [Thu, 27 Apr 2017 10:07:26 +0000 (12:07 +0200)]
bootstrap: Regenerate.

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

5 years agodoc: Release update.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 15:01:29 +0000 (17:01 +0200)]
doc: Release update.

* AUTHORS: Mention Nyacc and GuixSD.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.5 New file.
* HACKING: Add pointers, update TODO/DONE.

5 years agobootstrap: Regenerate.
Jan Nieuwenhuizen [Tue, 25 Apr 2017 18:20:10 +0000 (20:20 +0200)]
bootstrap: Regenerate.

* mes.mes: Regenerate.

5 years agomescc: Parse mlibc early, show progress.
Jan Nieuwenhuizen [Mon, 24 Apr 2017 17:09:54 +0000 (19:09 +0200)]
mescc: Parse mlibc early, show progress.

* module/mes/libc.mes (_start, strlen, getchar, assert_fail, ungetc,
  putchar, fputc, eputs, fputs, puts, strcmp, itoa, isdigit, atoi,
  malloc, realloc, strncmp, c:getenv): Change to function, add
  progress.  Update callers.
* module/language/c99/compiler.mes (c99-input->info): Compile libc separately.
* guile/mescc.scm: Update progress.
* scripts/mescc.mes: Update progress.

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

* mes.mes: Regenerate.

5 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.

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

* mes.mes: Regenerate.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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:

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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").

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.

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

* HACKING: Add roadmap.

5 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.

5 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.

5 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.

5 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.

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

5 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.

5 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).

5 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.

5 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.

5 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.

5 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.

5 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.

5 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.