mes.git
2 years agoRelease 0.12. v0.12
Jan Nieuwenhuizen [Fri, 6 Apr 2018 05:24:05 +0000 (07:24 +0200)]
Release 0.12.

* configure (VERSION): Bump to 0.12.

2 years agodoc: Release udpate.
Jan Nieuwenhuizen [Tue, 21 Nov 2017 18:22:26 +0000 (19:22 +0100)]
doc: Release udpate.

* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.12: New file.
* throughout: (janneke) coming out.

2 years agoguix.scm: Update mescc-tools to 0.4.
Jan Nieuwenhuizen [Sun, 8 Apr 2018 05:51:14 +0000 (07:51 +0200)]
guix.scm: Update mescc-tools to 0.4.

* guix.scm (mescc-tools): Update to 0.4.

2 years agocore: Workaround for mescc.
Jan Nieuwenhuizen [Sun, 8 Apr 2018 05:50:12 +0000 (07:50 +0200)]
core: Workaround for mescc.

* src/mes.c (eval_apply)[__MESC__]: Add reminder for macro_p, global_p.

2 years agobuild: Remove scripts/mes symlink.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 16:27:26 +0000 (18:27 +0200)]
build: Remove scripts/mes symlink.

2 years agomes: Add string-fold, string-fold-right.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 11:37:07 +0000 (13:37 +0200)]
mes: Add string-fold, string-fold-right.

* module/srfi/srfi-13.mes (string-fold, string-fold-right): New
  function.
* tests/srfi-13.test ("string-fold"): Test it.
  ("string-fold-right"): Test it.

2 years agomes: Allow tick as part of identifier.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 11:36:23 +0000 (13:36 +0200)]
mes: Allow tick as part of identifier.

* src/reader.c (reader_read_sexp_): Do not treat tick as special.

2 years agomescc: Remove debugging.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 11:14:58 +0000 (13:14 +0200)]
mescc: Remove debugging.

* module/language/c99/compiler.mes: Remove debugging.

2 years agomescc: No comments in M1 when running on Mes.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 11:13:26 +0000 (13:13 +0200)]
mescc: No comments in M1 when running on Mes.

* module/language/c99/compiler.mes (ast-comment): If mes?, return nil.

2 years agomescc: Trace globals.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 10:56:17 +0000 (12:56 +0200)]
mescc: Trace globals.

* module/language/c99/compiler.mes (mescc:trace): New function.  Use
  throughout.

2 years agoRevert "core: Add member."
Jan Nieuwenhuizen [Sat, 7 Apr 2018 11:15:26 +0000 (13:15 +0200)]
Revert "core: Add member."

This reverts commit 921686a0a3b06281f1804d04e6d4a0344dda507a.

2 years agocore: Add member.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 10:18:50 +0000 (12:18 +0200)]
core: Add member.

* src/lib.c (member): New function.
* module/mes/scm.mes (member): Remove.

2 years agomescc: trace M1 dumping.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 08:24:57 +0000 (10:24 +0200)]
mescc: trace M1 dumping.

* module/language/c99/compiler.mes (info->object): Add tracing.
* module/mes/M1.mes (object->M1): Add tracing.

2 years agoRevert "guix: Update nyacc to 0.83.31."
Jan Nieuwenhuizen [Sat, 7 Apr 2018 11:41:32 +0000 (13:41 +0200)]
Revert "guix: Update nyacc to 0.83.31."

This reverts commit 624b85d6b1dd876542f7ad342d6beb8a92408397.

2 years agoguix: Update nyacc to 0.83.31.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 07:48:47 +0000 (09:48 +0200)]
guix: Update nyacc to 0.83.31.

* guix.scm (nyacc): Update to 0.83.31.

2 years agomescc: Have Nyacc trace functions while parsing.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 07:35:08 +0000 (09:35 +0200)]
mescc: Have Nyacc trace functions while parsing.

* guile/mescc.scm (main): Set NYACC_TRACE.
* scripts/mescc.mes (main): Set NYACC_TRACE.

2 years agomes: Add setenv.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 07:34:02 +0000 (09:34 +0200)]
mes: Add setenv.

* src/posix.c (setenv_): New function.
* tests/base.test ("setenv, getenv"): Test it.

2 years agocore: Add setenv.
Jan Nieuwenhuizen [Sat, 7 Apr 2018 07:21:51 +0000 (09:21 +0200)]
core: Add setenv.

* lib/libc.c (setenv): New function.
* include/stdlib.h (setenv): Declare it.
* scaffold/tests/61-array.c (test): Test it.

2 years agoguix: Add manifest.
Jan Nieuwenhuizen [Thu, 5 Apr 2018 21:13:23 +0000 (23:13 +0200)]
guix: Add manifest.

* build-aux/manifest.scm: New file.

2 years agoguix: Update Nyacc to 0.80.42.
Jan Nieuwenhuizen [Thu, 5 Apr 2018 19:24:11 +0000 (21:24 +0200)]
guix: Update Nyacc to 0.80.42.

* guix.scm (nyacc): Update to 0.80.42.

2 years agomescc: Also print `parsing: input' when using -E.
Jan Nieuwenhuizen [Fri, 6 Apr 2018 05:18:19 +0000 (07:18 +0200)]
mescc: Also print `parsing: input' when using -E.

* module/language/c99/compiler.mes (c99-input->ast): Print `parsing:
  input'.
  (c99-input->info): Remove that.

2 years agocore: Cleanup reader.
Jan Nieuwenhuizen [Thu, 5 Apr 2018 20:41:53 +0000 (22:41 +0200)]
core: Cleanup reader.

* src/reader.c (reader_read_sexp_): Rename from reader_read_word_.  Cleanup.
  (read_hash): Cleanup.

2 years agomes: Cleanup formatting.
Jan Nieuwenhuizen [Thu, 5 Apr 2018 19:35:31 +0000 (21:35 +0200)]
mes: Cleanup formatting.

2 years agocore: Add equal2?.
Jan Nieuwenhuizen [Thu, 5 Apr 2018 18:01:04 +0000 (20:01 +0200)]
core: Add equal2?.

* src/lib.c (equal2_p): New function.
* module/mes/base.mes (equal2?): Remove.

2 years agocore: Add memq.
Jan Nieuwenhuizen [Thu, 5 Apr 2018 09:03:09 +0000 (11:03 +0200)]
core: Add memq.

* lib/mes.c (memq): New function.
* module/mes/scm.mes (memq): Remove.

2 years agomes: Remove duplicate memq.
Jan Nieuwenhuizen [Thu, 5 Apr 2018 09:02:06 +0000 (11:02 +0200)]
mes: Remove duplicate memq.

* module/mes/base-0.mes (memq): Remove.

2 years agomes: Single environment lookup for variables, SICP chapter 3.
Jan Nieuwenhuizen [Sat, 9 Dec 2017 07:33:50 +0000 (08:33 +0100)]
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>.

2 years agocore: Remove override hook for read-input-file.
Jan Nieuwenhuizen [Tue, 3 Apr 2018 05:45:12 +0000 (07:45 +0200)]
core: Remove override hook for read-input-file.

* src/reader.c (read_input_file_env): Remove override hook for
read-input-file.

2 years agomes: Iterative recursive macro expand.
Jan Nieuwenhuizen [Sun, 4 Mar 2018 09:05:55 +0000 (10:05 +0100)]
mes: Iterative recursive macro expand.

* src/mes.c (eval_apply): Iterative recursive macro expand.
* src/posix.c (set_current_input_port): Return previous port.
* module/mes/catch.mes (%eh): Use core:display.
* module/mes/display.mes (display-cut, display-cut2): Move macro
  definitions to toplevel.

2 years agoguix: records.scm: update from upstream.
Jan Nieuwenhuizen [Wed, 4 Apr 2018 21:32:40 +0000 (23:32 +0200)]
guix: records.scm: update from upstream.

* guile/guix/records.scm: Update from upstream.

2 years agomes: Add incremental test suite.
Jan Nieuwenhuizen [Thu, 25 Jan 2018 05:58:44 +0000 (06:58 +0100)]
mes: Add incremental test suite.

* check-boot.sh: New file.
* check.sh: Invoke it.
* module/srfi/srfi-16.mes: New file.
* scaffold/boot/00-zero.scm: New file.
* scaffold/boot/01-true.scm: New file.
* scaffold/boot/02-symbol.scm: New file.
* scaffold/boot/03-string.scm: New file.
* scaffold/boot/04-cons.scm: New file.
* scaffold/boot/04-quote.scm: New file.
* scaffold/boot/05-list.scm: New file.
* scaffold/boot/06-tick.scm: New file.
* scaffold/boot/07-if.scm: New file.
* scaffold/boot/08-if-if.scm: New file.
* scaffold/boot/10-cons.scm: New file.
* scaffold/boot/11-list.scm: New file.
* scaffold/boot/12-car.scm: New file.
* scaffold/boot/13-cdr.scm: New file.
* scaffold/boot/14-exit.scm: New file.
* scaffold/boot/15-display.scm: New file.
* scaffold/boot/16-if-eq-quote.scm: New file.
* scaffold/boot/20-define-quote.scm: New file.
* scaffold/boot/20-define-quoted.scm: New file.
* scaffold/boot/20-define.scm: New file.
* scaffold/boot/21-define-procedure.scm: New file.
* scaffold/boot/22-define-procedure-2.scm: New file.
* scaffold/boot/23-begin.scm: New file.
* scaffold/boot/24-begin-define.scm: New file.
* scaffold/boot/25-begin-define-2.scm: New file.
* scaffold/boot/26-begin-define-later.scm: New file.
* scaffold/boot/26-define-define.scm: New file.
* scaffold/boot/27-lambda-define.scm: New file.
* scaffold/boot/28-define-define.scm: New file.
* scaffold/boot/29-lambda-define.scm: New file.
* scaffold/boot/2a-lambda-lambda.scm: New file.
* scaffold/boot/2b-define-lambda.scm: New file.
* scaffold/boot/2c-define-lambda-recurse.scm: New file.
* scaffold/boot/2d-define-lambda-set.scm: New file.
* scaffold/boot/2e-define-second.scm: New file.
* scaffold/boot/30-capture.scm: New file.
* scaffold/boot/31-capture-define.scm: New file.
* scaffold/boot/32-capture-modify-close.scm: New file.
* scaffold/boot/33-procedure-override-close.scm: New file.
* scaffold/boot/34-cdr-override-close.scm: New file.
* scaffold/boot/35-closure-modify.scm: New file.
* scaffold/boot/36-closure-override.scm: New file.
* scaffold/boot/37-closure-lambda.scm: New file.
* scaffold/boot/38-simple-format.scm: New file.
* scaffold/boot/40-define-macro.scm: New file.
* scaffold/boot/41-when.scm: New file.
* scaffold/boot/42-if-when.scm: New file.
* scaffold/boot/43-or.scm: New file.
* scaffold/boot/44-or-if.scm: New file.
* scaffold/boot/45-pass-if.scm: New file.
* scaffold/boot/46-report.scm: New file.
* scaffold/boot/47-pass-if-eq.scm: New file.
* scaffold/boot/48-let.scm: New file.
* scaffold/boot/49-macro-override.scm: New file.
* scaffold/boot/4a-define-macro-define-macro.scm: New file.
* scaffold/boot/4b-define-macro-define.scm: New file.
* scaffold/boot/4c-quasiquote.scm: New file.
* scaffold/boot/50-primitive-load.scm: New file.
* scaffold/boot/51-module.scm: New file.
* scaffold/boot/52-define-module.scm: New file.
* scaffold/boot/53-closure-display.scm: New file.
* scaffold/boot/60-let-syntax.scm: New file.
* scaffold/boot/closure.scm: New file.
* scaffold/boot/compose.scm: New file.
* scaffold/boot/data/bar.mes: New file.
* scaffold/boot/data/i.scm: New file.
* scaffold/boot/data/module.mes: New file.
* scaffold/boot/foo.scm: New file.
* scaffold/boot/lambda-star.scm: New file.
* scaffold/boot/vector.scm: New file.
* tests/boot.test: New file.
* tests/boot.test-guile: New file.
* tests/srfi-16.test: New file.
* tests/srfi-16.test-guile: New file.

2 years agomes: Boot from MES_BOOT, boot-0.scm.
Jan Nieuwenhuizen [Sat, 3 Feb 2018 20:43:52 +0000 (21:43 +0100)]
mes: Boot from MES_BOOT, boot-0.scm.

* src/mes.c (load_env): Softcode loading of boot-0.scm from
  environment variabl MES_BOOT.
* module/mes/boot-00.scm: New file.
* module/mes/boot-01.scm: New file.
* module/mes/boot-0.scm: Rename from read-0.mes.
* module/mes/module.mes: New file.

2 years agobuild: Add -fno-stack-protector for debian.
Jan Nieuwenhuizen [Sun, 4 Mar 2018 14:53:05 +0000 (15:53 +0100)]
build: Add -fno-stack-protector for debian.

* guile/guix/make.scm (%C32-FLAGS): Add -fno-stack-protector.

2 years agomes: reader: reader_ prefix; read/write char/string in core.
Jan Nieuwenhuizen [Sat, 6 Jan 2018 06:58:23 +0000 (07:58 +0100)]
mes: reader: reader_ prefix; read/write char/string in core.

* src/posix.c (peek_char, read_char, read_string, unread_char, write_char): New function.
* src/reader.c: Use reader_ prefix.

r# bootstrappable.org

2 years agomes: More informative error reporting for number asserts.
Jan Nieuwenhuizen [Thu, 25 Jan 2018 06:00:48 +0000 (07:00 +0100)]
mes: More informative error reporting for number asserts.

* src/math.c (assert_number): New function.  Update assert () users.

2 years agoguile: Resurrect eval/apply in scheme.
Jan Nieuwenhuizen [Sat, 27 Jan 2018 15:43:09 +0000 (16:43 +0100)]
guile: Resurrect eval/apply in scheme.

* guile/mes.mes (eval-expand): Short-circuit make-closure.
* guile/mes.scm (environment): Update.

2 years agomes: simple-format: support ~A, ~S.
Jan Nieuwenhuizen [Sat, 3 Feb 2018 19:06:38 +0000 (20:06 +0100)]
mes: simple-format: support ~A, ~S.

* module/mes/display.scm (simple-format): support ~A, ~S.

2 years agocore: Display and write string and char compliance.
Jan Nieuwenhuizen [Mon, 22 Jan 2018 22:45:46 +0000 (23:45 +0100)]
core: Display and write string and char compliance.

* src/lib.c (display_helper): Display and write char and string compliance.

2 years agomes: display: Support keyword.
Jan Nieuwenhuizen [Sat, 3 Feb 2018 20:57:30 +0000 (21:57 +0100)]
mes: display: Support keyword.

* src/lib.c (display_helper): Support keyword.

2 years agomes: display: vector.
Jan Nieuwenhuizen [Fri, 12 Jan 2018 17:24:42 +0000 (18:24 +0100)]
mes: display: vector.

* src/lib.c (display_helper): Display vector.

2 years agomes: display: closure names.
Jan Nieuwenhuizen [Sun, 14 Jan 2018 08:11:19 +0000 (09:11 +0100)]
mes: display: closure names.

* src/lib.c (display_helper): Display closure names.

2 years agomes: Rename make-vector to core:make-vector.
Jan Nieuwenhuizen [Sun, 7 Jan 2018 15:26:36 +0000 (16:26 +0100)]
mes: Rename make-vector to core:make-vector.

* src/vector.c (make_vector_): Rename from make_vector.  Update callers.

2 years agomes: Better error reporting.
Jan Nieuwenhuizen [Sun, 7 Jan 2018 15:08:11 +0000 (16:08 +0100)]
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).

2 years agoRevert "mes: un-defmacro optargs. WIP"
Jan Nieuwenhuizen [Sun, 7 Jan 2018 13:52:09 +0000 (14:52 +0100)]
Revert "mes: un-defmacro optargs.  WIP"

This reverts commit 5da527c540dc0e1481a010899233b4e806fe37da.

2 years agomes: un-defmacro optargs. WIP
Jan Nieuwenhuizen [Sat, 6 Jan 2018 08:29:11 +0000 (09:29 +0100)]
mes: un-defmacro optargs.  WIP

2 years agomes: Test optargs without pmatch.
Jan Nieuwenhuizen [Sat, 6 Jan 2018 10:18:38 +0000 (11:18 +0100)]
mes: Test optargs without pmatch.

* tests/optargs.test: Remove pmatch.

2 years agomes: Add define-macro*.
Jan Nieuwenhuizen [Sat, 6 Jan 2018 10:09:10 +0000 (11:09 +0100)]
mes: Add define-macro*.

* module/mes/optargs.mes (define-macro*): New macro.

2 years agomes: Evaluate test of COND only once.
Jan Nieuwenhuizen [Fri, 5 Jan 2018 09:01:50 +0000 (10:01 +0100)]
mes: Evaluate test of COND only once.

* module/mes/base-0.mes (cond): Evaluate test of COND only once.
  Fixes cond tests with side effects (Nyacc).
* tests/base.test ("cond side effect"): Test it.

2 years agomes: #\page is whitespace.
Jan Nieuwenhuizen [Thu, 4 Jan 2018 21:26:29 +0000 (22:26 +0100)]
mes: #\page is whitespace.

* module/srfi/srfi-14.mes (char-set:whitespace): Add #\page.

2 years agomes: #<eof> is not a character.
Jan Nieuwenhuizen [Thu, 4 Jan 2018 20:36:46 +0000 (21:36 +0100)]
mes: #<eof> is not a character.

* module/mes/display.mes (display):
* module/mes/type-0.mes (char?): -1 is not a character.
  (eof-object?): New function.
* tests/base.test ("#<eof>"): Test it.
* module/mes/scm.mes (eof-object?): Remove.
  (unread-char): Return character (WAS: integer).

2 years agomes: open-input-string: peek fix.
Jan Nieuwenhuizen [Thu, 4 Jan 2018 18:32:35 +0000 (19:32 +0100)]
mes: open-input-string: peek fix.

* module/mes/guile.mes (open-input-string): Return actual tell.
* tests/guile.test ("open-input-string peek"): Test it.

2 years agomes: with-input-from-string: peek fix.
Jan Nieuwenhuizen [Thu, 4 Jan 2018 17:35:26 +0000 (18:35 +0100)]
mes: with-input-from-string: peek fix.

* module/mes/guile.mes (with-input-from-string): Return actual tell.
* tests/guile.test ("with-input-from-string peek"): Test it.

2 years agomescc: Resurrect guile-1.8.
Jan Nieuwenhuizen [Wed, 3 Jan 2018 07:33:55 +0000 (08:33 +0100)]
mescc: Resurrect guile-1.8.

* guile/mescc.scm: Use GUILE_LOAD_COMPILED_PATH instead of -C.
  [guile]: Include syncase.
* module/language/c99/compiler.scm [guile]: Stub pretty-print-c99.
  Set stack to unlimited.
* module/language/c99/info.scm [guile]: Include (ice-9 syncase).
* module/mes/as-i386.scm [guile]: Likewise.
* module/mes/guile.scm [guile]: Add compose, export it.

2 years agomes: Add string-drop-right.
Jan Nieuwenhuizen [Wed, 3 Jan 2018 05:53:02 +0000 (06:53 +0100)]
mes: Add string-drop-right.

* module/srfi/srfi-13.mes (string-drop-right): New function.

2 years agomescc: cleanups.
Jan Nieuwenhuizen [Tue, 2 Jan 2018 20:35:55 +0000 (21:35 +0100)]
mescc: cleanups.

* guile/mescc.scm: Cleanups.
* module/language/c99/compiler.mes:
* module/language/c99/compiler.scm:
* module/language/c99/info.mes:
* module/language/c99/info.scm:
* module/mes/getopt-long.mes:
* module/mes/optargs.mes:
* module/mes/optargs.scm:
* module/mes/repl.mes:
* module/mes/scm.mes:
* scripts/mescc.mes:

2 years agonyacc cpp-debugging, tests
Jan Nieuwenhuizen [Tue, 2 Jan 2018 19:41:59 +0000 (20:41 +0100)]
nyacc cpp-debugging, tests

2 years agomes: getopt-long: fix multi-opt and unclumping.
Jan Nieuwenhuizen [Tue, 2 Jan 2018 06:05:41 +0000 (07:05 +0100)]
mes: getopt-long: fix multi-opt and unclumping.

* module/mes/getopt-long.scm (remove-if-not): Remove.
  (option-spec): Add value field.  Update users.
  (expand-clumped-singles): Simplify, fix.
  (process-options): To get an option's value, use value instead of
  value-policy.  Fixes multi-opt.
* tests/getopt-long.test: New file.
* make.scm (mes-tests): Add it.
* check.sh (tests): Add it.
* tests/getopt-long.test-guile: New symlink.

2 years agoguix: back to 0.80.41 for tinycc.
Jan Nieuwenhuizen [Tue, 2 Jan 2018 06:05:22 +0000 (07:05 +0100)]
guix: back to 0.80.41 for tinycc.

guix.scm (nyacc): New variable.

2 years agomes: Support equal? with arbitrary number of arguments.
Jan Nieuwenhuizen [Mon, 1 Jan 2018 22:00:01 +0000 (23:00 +0100)]
mes: Support equal? with arbitrary number of arguments.

* module/mes/base.mes (equal2?): Rename from equal?.
  (equal?): Implement.

2 years agomescc: Use records for mes too.
Jan Nieuwenhuizen [Mon, 1 Jan 2018 21:21:15 +0000 (22:21 +0100)]
mescc: Use records for mes too.

* module/language/c99/info.mes: Use info.scm records, remove
  simplistic list data structures.

2 years agomescc.mes: Use write for preprocessing output.
Jan Nieuwenhuizen [Mon, 1 Jan 2018 20:13:46 +0000 (21:13 +0100)]
mescc.mes: Use write for preprocessing output.

* scripts/mescc.mes (source->ast): Use core:write instead of pretty-print.

2 years agomes: Add write, core:write.
Jan Nieuwenhuizen [Mon, 1 Jan 2018 20:10:15 +0000 (21:10 +0100)]
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.

2 years agomes: gc_safety.
Jan Nieuwenhuizen [Mon, 1 Jan 2018 19:00:06 +0000 (20:00 +0100)]
mes: gc_safety.

2 years agocheck-mescc.sh: run with mes.
Jan Nieuwenhuizen [Mon, 1 Jan 2018 15:55:07 +0000 (16:55 +0100)]
check-mescc.sh: run with mes.

* src/build.sh:
* src/check-mescc.sh: Run with mes.

2 years agomes: Add string-null?.
Jan Nieuwenhuizen [Mon, 1 Jan 2018 15:41:15 +0000 (16:41 +0100)]
mes: Add string-null?.

* module/srfi/srfi-13.mes (string-null?): New function.

2 years agomes: Add dirname.
Jan Nieuwenhuizen [Mon, 1 Jan 2018 15:40:23 +0000 (16:40 +0100)]
mes: Add dirname.

* module/mes/guile.mes (dirname): New function.

2 years agotest: Add syntax tests.
Jan Nieuwenhuizen [Mon, 1 Jan 2018 14:53:13 +0000 (15:53 +0100)]
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 ()

2 years agoRevert "mes: use array-based stack. WIP: will not survice gc."
Jan Nieuwenhuizen [Sun, 17 Dec 2017 06:42:49 +0000 (07:42 +0100)]
Revert "mes: use array-based stack. WIP: will not survice gc."

This reverts commit 7fb653f68c2dbf8bc83cce4bd138439c600b538f.

2 years agomes: use array-based stack. WIP: will not survice gc.
Jan Nieuwenhuizen [Thu, 14 Dec 2017 06:05:53 +0000 (07:05 +0100)]
mes: use array-based stack. WIP: will not survice gc.

* src/mes.c (STACK_SIZE)[MES_ARRAY_STACK]: New variable.
  (g_stack_array): New variable.
  (g_stack): Change type to SCM*.
* (gc_push_frame)[MES_ARRAY_STACK]: Use g_stack_array, g_stack.
  (gc_peek_frame): Likewise.
  (gc_pop_frame): Likewise.
* src/gc.c (gc_check): Likewise.
  (gc): Likewise.

2 years agomes: Fix assq to improve performance.
Jan Nieuwenhuizen [Tue, 12 Dec 2017 19:25:48 +0000 (20:25 +0100)]
mes: Fix assq to improve performance.

* src/mes.c (assq): Special case eq_p to improve performance.

2 years agomes: Reimplement records.
Jan Nieuwenhuizen [Mon, 11 Dec 2017 23:12:42 +0000 (00:12 +0100)]
mes: Reimplement records.

* module/srfi/srfi-9.mes (define-record-type): New macro.
* AUTHORS: Update.
* module/mes/record-0.mes: Remove.
* module/mes/record.mes: Remove.
* module/srfi/srfi-9-psyntax.mes: Remove.
* module/srfi/srfi-9.scm: Remove.
* make.scm: Remove them.

2 years agomes: Fix display of closure.
Jan Nieuwenhuizen [Mon, 11 Dec 2017 06:06:21 +0000 (07:06 +0100)]
mes: Fix display of closure.

* module/mes/display.mes (display): Drop extra ( at start of *closure*, *circ*.
* src/lib.c (display_helper): Likewise.

2 years agomes: Resurrect define, define-macro in C core.
Jan Nieuwenhuizen [Sat, 9 Dec 2017 07:24:38 +0000 (08:24 +0100)]
mes: Resurrect define, define-macro in C core.

* make.scm (bin.gcc, bin.mescc): Use MES_C_READER=1.
* src/mes.c (scm_symbol_define, scm_symbol_define_macro): New symbol.
  (scm_vm_eval_define): New special.
  (scm_symbol_c_define): New symbol.
  (MAKE_MACRO): New define.
  (eval_apply)[MES_C_DEFINE]: Handle define, define-macro.
  (mes_symbols): Define %c-define for use in read-0.mes.
* module/mes/read-0.mes: Do not implement full scheme define if %c-define.
* module/mes/quasiquote.mes (sexp:define, env:define, env:macro): New function.
  (define-macro): New macro.  FIXME
* module/mes/psyntax.mes (define): New macro.  FIXME

2 years agomes: Fix initial display.
Jan Nieuwenhuizen [Sun, 10 Dec 2017 14:51:35 +0000 (15:51 +0100)]
mes: Fix initial display.

* module/mes/read-0.mes (display): Fix.

2 years agomes: Fix compile warning in reader.
Jan Nieuwenhuizen [Mon, 11 Dec 2017 03:52:00 +0000 (04:52 +0100)]
mes: Fix compile warning in reader.

* src/reader.c[MES_C_READER]: Declare read_block_comment, read_hash.
  Fixes compile warning.

2 years agomescc: Allow invoking git mescc.mes from elsewhere.
Jan Nieuwenhuizen [Sat, 9 Dec 2017 21:38:51 +0000 (22:38 +0100)]
mescc: Allow invoking git mescc.mes from elsewhere.

* src/mes.c (load_env): Look in MES_PREFIX too.  Add debug printing.
* scripts/mescc.mes: Consider MES_PREFIX.
* guile/mescc.scm (%prefix): Consider MES_PREFIX.
* module/mes/base-0.mes (string->list): New function, move from type-0.mes.
  (%moduledir): Consider MES_PREFIX.
* module/mes/type-0.mes (string->list): Remove.

2 years agomescc: Output performance hacks: use core:display.
Jan Nieuwenhuizen [Sat, 9 Dec 2017 19:10:57 +0000 (20:10 +0100)]
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.

2 years agomes: Nyacc support: substring/copy, substring/shared.
Jan Nieuwenhuizen [Sat, 9 Dec 2017 21:45:38 +0000 (22:45 +0100)]
mes: Nyacc support: substring/copy, substring/shared.

* module/srfi/srfi-13.mes (substring/copy, substring/shared): Define
  to substring.

2 years agomes: Nyacc support: Read old characters.
Jan Nieuwenhuizen [Sat, 9 Dec 2017 21:36:53 +0000 (22:36 +0100)]
mes: Nyacc support: Read old characters.

* src/reader.c (read_character)[MES_C_READER]: Support reading old
  characters: #\bel, #\bs, #\vt.

2 years agomes: resurrect running MesCC: handle \t in strings.
Jan Nieuwenhuizen [Sat, 9 Dec 2017 18:33:10 +0000 (19:33 +0100)]
mes: resurrect running MesCC: handle \t in strings.

* src/reader.c (read-string): Handle \t.  Fixex M1 output.

2 years agomescc: Use small, bootstrappable syntax rather than huge psyntax seed.
Jan Nieuwenhuizen [Sat, 9 Dec 2017 09:55:46 +0000 (10:55 +0100)]
mescc: Use small, bootstrappable syntax rather than huge psyntax seed.

* module/nyacc/lex.mes (mes): Use syntax (WAS: psyntax).
* module/mes/pmatch.mes (mes): Likewise.
* module/nyacc/lang/c99/parser.mes (srfi-9): Use syntax (WAS: srfi-9-psyntax).

2 years agomes: Fix for pmatch on bootstrappable syntax-rules.
Jan Nieuwenhuizen [Sat, 9 Dec 2017 14:04:32 +0000 (15:04 +0100)]
mes: Fix for pmatch on bootstrappable syntax-rules.

* module/mes/pmatch.scm (ppat): Do not use let.
* tests/pmatch.test ("pmatch nyacc minimal", "pmatch nyacc"): Test it.

2 years agomlibc: M4 support: robustify headers, add sys/signal.h.
Jan Nieuwenhuizen [Tue, 5 Dec 2017 18:49:37 +0000 (19:49 +0100)]
mlibc: M4 support: robustify headers, add sys/signal.h.

* include/errno.h (ERANGE): New define.
* include/stdarg.h (size_t): Undefine before typedef.
* include/stdint.h: Likewise.
* include/stdio.h: Likewise.
* include/stdlib.h: Likewise.
* include/sys/types.h: Likewise.
* include/string.h: Likewise.
  (ssize_t): Undefine before typedef.
* include/unistd.h: Likewise.
  (off_t): Undefine before typedef.
* include/sys/stat.h (struct stat): New stub.
* include/sys/signal.h: New file.

2 years agomescc: M4 support: scaffold/tests/82-define.c.
Jan Nieuwenhuizen [Mon, 4 Dec 2017 22:19:32 +0000 (23:19 +0100)]
mescc: M4 support: scaffold/tests/82-define.c.

* scaffold/tests/82-define.c: New file; inspired by M4.  Thanks, Ricardo!
* make.scm ("82-define"): Build it.
* check-mescc.sh: Add 82-define.

2 years agomlibc: Tinycc support: Avoid hex.
Jan Nieuwenhuizen [Mon, 4 Dec 2017 21:58:10 +0000 (22:58 +0100)]
mlibc: Tinycc support: Avoid hex.

* include/00-test.i (main)[__TINYC__]: Do not use $0x.

2 years agomlibc: Tinycc support: qsort.
Jan Nieuwenhuizen [Mon, 4 Dec 2017 18:01:39 +0000 (19:01 +0100)]
mlibc: Tinycc support: qsort.

* lib/libc+tcc.c (qswap, qpart): New function
  (qsort): Implement.
* scaffold/tests/81-qsort.c: Test it.
* make.scm ("81-qsort"): Build it.

2 years agomescc: scaffold: misc cleanups.
Jan Nieuwenhuizen [Sun, 3 Dec 2017 22:03:09 +0000 (23:03 +0100)]
mescc: scaffold: misc cleanups.

* scaffold/tests/44-switch.c (swits): More case labels.
* scaffold/tests/60-math.c: Discriminate return values.
* scaffold/tests/77-pointer-assign.c (memset)[__TINYC__]: Remove.
* scaffold/tests/79-int-array.c (test): Discriminate return values.

2 years agomlibc: Tinycc support: __udivdi3, __umoddi3.
Jan Nieuwenhuizen [Sun, 3 Dec 2017 19:40:49 +0000 (20:40 +0100)]
mlibc: Tinycc support: __udivdi3, __umoddi3.

* lib/libc+tcc-gcc.c (__udivdi3, __umoddi3): Fix signature, do not
  crash on simple integer devisions.

2 years agomescc: Tinycc support: Respect word size better.
Jan Nieuwenhuizen [Sun, 3 Dec 2017 15:33:35 +0000 (16:33 +0100)]
mescc: Tinycc support: Respect word size better.

* stage0/x86.M1 (movzwl_0x32(%ebp),%eax,movzwl_0x8(%ebp),%eax): New
  define.
* module/mes/as-i386.mes (i386:push-word-local-de-ref,
  i386:word-local->accu): New function.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (push-local-de-ref): Respect word size.
  (ident->accu): Likewise.

2 years agomlibc: New library layout; remove duplication.
Jan Nieuwenhuizen [Sun, 3 Dec 2017 12:56:21 +0000 (13:56 +0100)]
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.

2 years agomlibc: Tinycc support: itoab, for debugging.
Jan Nieuwenhuizen [Sun, 3 Dec 2017 09:33:05 +0000 (10:33 +0100)]
mlibc: Tinycc support: itoab, for debugging.

* lib/libc-gcc.c (itoab): New function.
* lib/libc-mes.c (itoab): New function.

2 years agomescc: prefix string labels with _.
Jan Nieuwenhuizen [Sat, 2 Dec 2017 13:04:41 +0000 (14:04 +0100)]
mescc: prefix string labels with _.

* module/mes/M1.mes (object->M1): Prefix string lables with _.

2 years agomescc: prefix local labels with _.
Jan Nieuwenhuizen [Sat, 2 Dec 2017 11:59:07 +0000 (12:59 +0100)]
mescc: prefix local labels with _.

* module/language/c99/compiler.mes (expr->accu): prefix local labels with _.

2 years agobootstrap: Update build script.
Jan Nieuwenhuizen [Sat, 2 Dec 2017 07:48:34 +0000 (08:48 +0100)]
bootstrap: Update build script.

* build.sh: Add blood-elf, use -o.

2 years agomlibc: Mescc-tools support: fix for [v]fprintf.
Jan Nieuwenhuizen [Sat, 2 Dec 2017 07:46:41 +0000 (08:46 +0100)]
mlibc: Mescc-tools support: fix for [v]fprintf.

* lib/libc-mes+tcc.c (vfprintf): Bugfix: print to fd.

2 years agomes: resurrect full reader in C core.
Jan Nieuwenhuizen [Wed, 29 Nov 2017 20:42:50 +0000 (21:42 +0100)]
mes: resurrect full reader in C core.

* module/mes/read-0.mes (defined?): New function.
  (eat-whitespace, read-env, read-word, read-block-comment,
  read-line-comment, read-list, read-character, read-hex, read-octal,
  reader:read-string, lookup, read-hash, read-word): Only define if
  not %c-reader.
* module/mes/base-0.mes (defined?): Remove.
* src/mes.c[MES_C_READER]: Set ARENA_SIZE=10000000.
  (scm_symbol_quasiquote scm_symbol_unquote,
  scm_symbol_unquote_splicing, scm_symbol_syntax,
  scm_symbol_quasisyntax, scm_symbol_unsyntax,
  scm_symbol_unsyntax_splicing): New symbol.
  (scm_symbol_c_reader): New symbol.
  (MAKE_KEYWORD)[MES_C_READER]: New define.
  (mes_symbols): Define %c_reader.
* src/reader.c (read_word_)[MES_C_READER]: Extend to full Scheme
  reader.
  (eat_whitespace)[MES_C_READER]: Likewise.
  (read_block_comment, read_hash, read_word, read_character,
  read_octal, read_hex, append_char, read_string)[MES_C_READER]:
  Likewise.
* make.scm (bin.gcc,bin.mescc): Define MES_C_READER=1.

2 years agomescc: Mescc-tools support: char foo[BAR] = {'a', 'b', 'c'}.
Jan Nieuwenhuizen [Mon, 27 Nov 2017 18:51:18 +0000 (19:51 +0100)]
mescc: Mescc-tools support: char foo[BAR] = {'a', 'b', 'c'}.

* stage0/x86.M1 (mov____%al,0x8(%ebp), mov____%al,0x32(%ebp),
  mov____%ax,0x8(%ebp), mov____%ax,0x32(%ebp)): New define.
* module/mes/as-i386.mes (i386:accu->local+n,i386:byte-accu->local+n,
  i386:word-accu->local+n): New function.
* module/language/c99/compiler.mes (accu->local+n): New function.
  (initzer->data): Return char as single byte.
  (decl->info): Support char foo[BAR] = {'a', 'b', 'c'}.
* scaffold/tests/66-local-char-array.c: Test it.
* make.scm (add-scaffold-test): Build it.

2 years agomlibc: Mescc-tools support: chmod.
Jan Nieuwenhuizen [Sun, 26 Nov 2017 17:45:10 +0000 (18:45 +0100)]
mlibc: Mescc-tools support: chmod.

* stage0/x86.M1 (SYS_chmod): New define.
* lib/libc-gcc.c (chmod): New function.
* lib/libc-mes.c (chmod): New function.

2 years agomlibc: GNU Gcc support: setjmp, longjmp.
Jan Nieuwenhuizen [Sun, 26 Nov 2017 12:10:46 +0000 (13:10 +0100)]
mlibc: GNU Gcc support: setjmp, longjmp.

* stage0/x86.M1 (jmp____*%ebx): New macro.
  (mov____0x8(%ebp),%ebp): New macro.
  (mov____0x8(%ebp),%esp): New macro.
* include/setjmp.h (jmp_buf): Redefine as struct.
* lib/libc-mes+tcc.c (longjmp, setjmp): Implement.
* scaffold/tests/80-setjmp.c: Test it.
* make.scm ("80-setjmp"): Build it.
* .gitignore: Ignore *.tcc-guile.

2 years agomlibc: GNU Gcc support: ferror.
Jan Nieuwenhuizen [Sat, 25 Nov 2017 21:57:18 +0000 (22:57 +0100)]
mlibc: GNU Gcc support: ferror.

* lib/libc-mes+tcc.c (ferror): New function.
* include/stdio.h (ferror): Declare it.