mes.git
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.

2 years agobootstrap: Add bootstrap build scripts.
Jan Nieuwenhuizen [Fri, 24 Nov 2017 18:02:58 +0000 (19:02 +0100)]
bootstrap: Add bootstrap build scripts.

* build.sh: New file.
* check-mescc.sh: New file.
* check.sh: New file.
* install.sh: New File.

2 years agoremove obsolete Nyacc link.
Jan Nieuwenhuizen [Thu, 23 Nov 2017 18:49:12 +0000 (19:49 +0100)]
remove obsolete Nyacc link.

* guile/nyacc: Remove.

2 years agobuild: mlib/include to include, move mlib to lib.
Jan Nieuwenhuizen [Wed, 22 Nov 2017 15:23:48 +0000 (16:23 +0100)]
build: mlib/include to include, move mlib to lib.

* include: Move from mlib/include.
* lib: Move from mlib.
* BOOTSTRAP: Update.
* HACKING: Update.
* guile/guix/make.scm: Update.
* make.scm: Update.
* module/language/c99/compiler.mes: Update.

2 years agomes: Resurrect running mes tests tests/*.test with Guile.
Jan Nieuwenhuizen [Tue, 21 Nov 2017 18:13:14 +0000 (19:13 +0100)]
mes: Resurrect running mes tests tests/*.test with Guile.

* tests/tests/base.test-guile: New file to resurrect running Mes test with Guile.
* tests/catch.test-guile: Symlink for same purpose.
* tests/closure.test-guile: Likewise.
* tests/cwv.test-guile: Likewise.
* tests/display.test-guile: Likewise.
* tests/fluids.test-guile: Likewise.
* tests/guile.test-guile: Likewise.
* tests/let-syntax.test-guile: Likewise.
* tests/let.test-guile: Likewise.
* tests/match.test-guile: Likewise.
* tests/math.test-guile: Likewise.
* tests/module.test-guile: Likewise.
* tests/optargs.test-guile: Likewise.
* tests/peg.test-guile: Likewise.
* tests/pmatch.test-guile: Likewise.
* tests/psyntax.test-guile: Likewise.
* tests/quasiquote.test-guile: Likewise.
* tests/read.test-guile: Likewise.
* tests/record.test-guile: Likewise.
* tests/scm.test-guile: Likewise.
* tests/srfi-1.test-guile: Likewise.
* tests/srfi-13.test-guile: Likewise.
* tests/srfi-14.test-guile: Likewise.
* tests/vector.test-guile: Likewise.
* make.scm (add-guile-test): New function.  Use it to run running tests/*.test-guile.

2 years agomes: resurrect running MesCC: handle \t in strings.
Jan Nieuwenhuizen [Mon, 20 Nov 2017 22:22:53 +0000 (23:22 +0100)]
mes: resurrect running MesCC: handle \t in strings.

* module/mes/read-0.mes (reader:read-string): Handle \t.  Fixex M1 output.

2 years agomes: Nyacc support: with-fluids.
Jan Nieuwenhuizen [Mon, 20 Nov 2017 22:21:25 +0000 (23:21 +0100)]
mes: Nyacc support: with-fluids.

* module/mes/fluids.mes (with-fluids): New macro.
* tests/fluids.test ("with-fluids"): Test it.

2 years agomes: resurrect running MesCC: update info interface.
Jan Nieuwenhuizen [Mon, 20 Nov 2017 22:17:50 +0000 (23:17 +0100)]
mes: resurrect running MesCC: update info interface.

* module/language/c99/info.mes (type?, global?, local?): New function.
  (make-global): Remove name parameter.
* module/nyacc/lang/c99/pprint.mes: New file.

2 years agomes: Add last.
Jan Nieuwenhuizen [Sun, 17 Dec 2017 12:32:17 +0000 (13:32 +0100)]
mes: Add last.

* module/srfi/srfi-1.mes (last): New funcion.

2 years agomes: Add reverse-list->string.
Jan Nieuwenhuizen [Mon, 20 Nov 2017 05:49:27 +0000 (06:49 +0100)]
mes: Add reverse-list->string.

* module/srfi/srfi-13.mes (reverse-list->string): New function.

2 years agobootstrap: Unbundle necessary M1 sources.
Jan Nieuwenhuizen [Mon, 20 Nov 2017 05:47:46 +0000 (06:47 +0100)]
bootstrap: Unbundle necessary M1 sources.

* mlibc/crt1.M1: Remove.
* mlibc/libc-mes.M1: Remove.
* src/mes.M1: Remove.

2 years agomlibc: Mescc-tools support: fix fgetc.
Jan Nieuwenhuizen [Sun, 19 Nov 2017 15:54:59 +0000 (16:54 +0100)]
mlibc: Mescc-tools support: fix fgetc.

* mlibc/libc-mes.c (fgetc): Fix from completely fubar.

2 years agomlibc: Mescc-tools support: strtol: partly implement stub.
Jan Nieuwenhuizen [Sun, 19 Nov 2017 15:54:13 +0000 (16:54 +0100)]
mlibc: Mescc-tools support: strtol: partly implement stub.

* mlibc/libc-mes+tcc.c (strtol): Partly implement stub.

2 years agomlibc: Mescc-tools support: getopt, getopt_long.
Jan Nieuwenhuizen [Sun, 19 Nov 2017 15:48:37 +0000 (16:48 +0100)]
mlibc: Mescc-tools support: getopt, getopt_long.

* mlibc/getopt.c: Move to ANSI C.  Remove GETOPT_COMPAT and
  non-POSIXLY_CORRECT options.
* mlibc/include/getopt.h: New file.
* mlibc/libc-gcc+tcc.c: Include getopt.c.
* mlibc/libc-mes+tcc.c: Likewise.

2 years agomlibc: Mescc-tools support: import getopt_long.
Jan Nieuwenhuizen [Sun, 19 Nov 2017 13:09:21 +0000 (14:09 +0100)]
mlibc: Mescc-tools support: import getopt_long.

* mlibc/getopt.c: Import from gcc-2.0.

2 years agoRevert "mescc: Grok char foo[] parameter."
Jan Nieuwenhuizen [Sun, 19 Nov 2017 19:50:06 +0000 (20:50 +0100)]
Revert "mescc: Grok char foo[] parameter."

This reverts commit c4cc75105db48b550cd515751b766b2e7a88ddc3.

2 years agomescc: Grok char foo[] parameter.
Jan Nieuwenhuizen [Sun, 19 Nov 2017 18:59:18 +0000 (19:59 +0100)]
mescc: Grok char foo[] parameter.

* module/language/c99/compiler.mes (function->text+data): Grok char
  foo[] parameter.

2 years agomescc: Grok char *const foo[];
Jan Nieuwenhuizen [Sun, 19 Nov 2017 15:46:43 +0000 (16:46 +0100)]
mescc: Grok char *const foo[];

* module/language/c99/compiler.mes (ast-strip-const): Grok char *const argv[];

2 years agomlibc: Mescc-tools support: endianness.
Jan Nieuwenhuizen [Sun, 19 Nov 2017 13:06:32 +0000 (14:06 +0100)]
mlibc: Mescc-tools support: endianness.

* mlibc/include/endian.h: New file.
* mlibc/include/ctype.h[!(__GNUC__ && POSIX)]: Include it.
* mlibc/include/stdlib.h: Likewise.
* mlibc/include/sys/types.h: Likewise.

2 years agomlibc: Mescc-tools support: exit stati.
Jan Nieuwenhuizen [Sun, 19 Nov 2017 13:05:33 +0000 (14:05 +0100)]
mlibc: Mescc-tools support: exit stati.

* mlibc/include/stdlib.h (EXIT_FAILURE, EXIT_SUCCESS): New define.

2 years agomescc: cleanup obsolete Nyacc 0.7x compatibility.
Jan Nieuwenhuizen [Sat, 18 Nov 2017 20:05:43 +0000 (21:05 +0100)]
mescc: cleanup obsolete Nyacc 0.7x compatibility.

* module/language/c99/compiler.mes (ast-type->type, ast->type
  expr->accu, struct-field, decl->info,): Remove obsolete Nyacc 0.7x
  patterns.

2 years agoguix: Release update.
Jan Nieuwenhuizen [Sat, 18 Nov 2017 12:53:50 +0000 (13:53 +0100)]
guix: Release update.

* guix.scm (mes): Update commit, hash and version.  Add
  'make-git-source-writable stage.

2 years agoRelease 0.11. v0.11
Jan Nieuwenhuizen [Sat, 18 Nov 2017 12:14:20 +0000 (13:14 +0100)]
Release 0.11.

* configure (VERSION): Bump to 0.11.

2 years agodoc: Release udpate.
Jan Nieuwenhuizen [Sat, 11 Nov 2017 12:09:26 +0000 (13:09 +0100)]
doc: Release udpate.

* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.11: New file.

2 years agobuild: fix for 07-include, thanks rain1!
Jan Nieuwenhuizen [Sat, 18 Nov 2017 14:02:21 +0000 (15:02 +0100)]
build: fix for 07-include, thanks rain1!

* make.scm (add-scaffold-test): New keyword parameter: includes.
  ("07-include"): Use it.

2 years agobuild: support gcc -m32, thanks rain1!
Jan Nieuwenhuizen [Sat, 18 Nov 2017 13:50:56 +0000 (14:50 +0100)]
build: support gcc -m32, thanks rain1!

* guile/guix/make.scm (%CC32): fallback to %CC.
  (%C32-FLAGS): Add -m32, to suppor gcc -m32.
  (LINK.gcc): Use it.

2 years agobootstrap: Update necessary M1 sources.
Jan Nieuwenhuizen [Sat, 18 Nov 2017 11:14:07 +0000 (12:14 +0100)]
bootstrap: Update necessary M1 sources.

   M1 -f stage0/x86.M1 -f mlibc/crt1.M1 --LittleEndian --Architecture=1 > mlibc/crt1.hex2
   M1 -f stage0/x86.M1 -f mlibc/mini-libc-mes.M1 --LittleEndian --Architecture=1  > mlibc/libc-mes.hex2
   M1 -f stage0/x86.M1 -f src/mes.M1 --LittleEndian --Architecture=1 > src/mes.hex2
   hex2 --LittleEndian --Architecture=1 --BaseAddress=0x1000000 -f stage0/elf32-header.hex2 -f mlibc/crt1.hex2 -f mlibc/libc-mes.hex2 -f src/mes.hex2 -f stage0/elf32-footer-single-main.hex2 > src/mes-mes
   exec_enable src/mes-mes

* mlibc/libc-mes.M1: Update.
* src/mes.M1: Udate.

2 years agomescc: Tinycc support: test #include.
Jan Nieuwenhuizen [Sat, 18 Nov 2017 10:55:47 +0000 (11:55 +0100)]
mescc: Tinycc support: test #include.

* scaffold/tests/exit-42.i: New file.
* scaffold/tests/07-include.c: New file.
* make.scm ("07-include"): Build it.

2 years agomescc: Tinycc support: struct struct array.
Jan Nieuwenhuizen [Fri, 17 Nov 2017 14:24:45 +0000 (15:24 +0100)]
mescc: Tinycc support: struct struct array.

Support

  struct foo
  {
    struct bar baz[N];
    struct bar bla*[M];
  };

* module/language/c99/compiler.mes (expr->accu):
* scaffold/tests/7n-struct-struct-array.c: Test it.
* make.scm (add-scaffold-test): Build it.

2 years agomlibc: Tinycc support: support, most syscalls stubbed.
Jan Nieuwenhuizen [Thu, 16 Nov 2017 21:11:07 +0000 (22:11 +0100)]
mlibc: Tinycc support: support, most syscalls stubbed.

* mlibc/libc-gcc.c (exit, write)[__TINYC__]: tcc-compatible gcc-style
  asm implementation.
  (read,open,access,brk,fsync)[__TINYC__]: Stub body.
* mlibc/libc-gcc+tcc.c (close,unlink, lseek, getcwd)[__TINYC__]: Stub
  body.
* mlibc/libc-mes+tcc.c: Support tinycc.
* mlibc/include/00-test.i (main) [__TINYC__]: Support tcc.

2 years agomescc: Tinycc support: empty for.
Jan Nieuwenhuizen [Thu, 16 Nov 2017 04:52:47 +0000 (05:52 +0100)]
mescc: Tinycc support: empty for.

* module/language/c99/compiler.mes (test-jump-label->info): Handle
  empty expression.
* make.scm (add-tcc-test "45_empty_for"): Test it.

2 years agotinycc: scaffold/main.c: running mes-tcc compiled binary #6.
Jan Nieuwenhuizen [Thu, 16 Nov 2017 04:33:11 +0000 (05:33 +0100)]
tinycc: scaffold/main.c: running mes-tcc compiled binary #6.

* scaffold/main.c (main): Use variable, if, argc, ++, +=, function call to return 42.

2 years agotinycc: scaffold/main.c: running mes-tcc compiled binary #5.
Jan Nieuwenhuizen [Wed, 15 Nov 2017 22:06:23 +0000 (23:06 +0100)]
tinycc: scaffold/main.c: running mes-tcc compiled binary #5.

* scaffold/main.c (main): Use function call and variable to return 42.

2 years agotinycc: scaffold/main.c: running mes-tcc compiled binary #4.
Jan Nieuwenhuizen [Tue, 14 Nov 2017 18:42:08 +0000 (19:42 +0100)]
tinycc: scaffold/main.c: running mes-tcc compiled binary #4.

* scaffold/main.c (main): Use variables to return 42.

2 years agomescc: Tinycc support: workaround lack of long long support.
Jan Nieuwenhuizen [Tue, 14 Nov 2017 18:39:46 +0000 (19:39 +0100)]
mescc: Tinycc support: workaround lack of long long support.

* module/language/c99/compiler.mes (i386:type-alist): Use size=4 for
  long long as a workaround.

2 years agomescc: refactor expr->accu, expr->accu*, fixes nontrivial struct by value assign.
Jan Nieuwenhuizen [Sat, 11 Nov 2017 12:45:53 +0000 (13:45 +0100)]
mescc: refactor expr->accu, expr->accu*, fixes nontrivial struct by value assign.

* module/language/c99/compiler.mes: (pke): New function.
  (expr->number): Rename from p-expr->number.  Update callers.
  (decl->info, init-declr->pointer, struct-field): Several pointeryness fixes.
  (expr->accu*, expr->accu): Remove special-casing for foo.bar,
  foo->bar, foo[bar].  Fixes struct by value assign for non-trival
  expressions.
  (accu->ident, ident-address->accu, ident->accu):
  (base->ident-address, ident->base): Remove.
* scaffold/tests/7k-for-each-elem.c (test): Test it.
* scaffold/tests/7c-dynarray.c (test): Test it.
* scaffold/tests/7m-struct-char-array-assign.c: Test it.
* make.scm (add-scaffold-test): Build it.

2 years agomlibc: errno.h: declare errno without extern.
Jan Nieuwenhuizen [Sat, 11 Nov 2017 12:42:42 +0000 (13:42 +0100)]
mlibc: errno.h: declare errno without extern.

* mlibc/include/errno.h: drop extern.  Fixes tcc compile.

2 years agoguix: nyacc: Update to 0.82.4.
Jan Nieuwenhuizen [Sat, 11 Nov 2017 12:20:25 +0000 (13:20 +0100)]
guix: nyacc: Update to 0.82.4.

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

3 years agoguix: Release update.
Jan Nieuwenhuizen [Sun, 10 Sep 2017 19:59:16 +0000 (21:59 +0200)]
guix: Release update.

* guix.scm (mes): Update commit, hash and version.

3 years agoRelease 0.10. v0.10
Jan Nieuwenhuizen [Sun, 10 Sep 2017 19:55:05 +0000 (21:55 +0200)]
Release 0.10.

* configure (VERSION): Bump to 0.10.

3 years agodoc: Release udpate.
Jan Nieuwenhuizen [Sat, 26 Aug 2017 11:29:07 +0000 (13:29 +0200)]
doc: Release udpate.

* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* doc/ANNOUNCE-0.10: New file.
* BOOTSTRAP: New file.
* make.scm: Install them.

3 years agobootstrap: Include necessary M1 sources.
Jan Nieuwenhuizen [Sun, 10 Sep 2017 19:17:17 +0000 (21:17 +0200)]
bootstrap: Include necessary M1 sources.

   M1 -f stage0/x86.M1 -f mlibc/crt1.M1 --LittleEndian --Architecture=1 > mlibc/crt1.hex2
   M1 -f stage0/x86.M1 -f mlibc/mini-libc-mes.M1 --LittleEndian --Architecture=1  > mlibc/libc-mes.hex2
   M1 -f stage0/x86.M1 -f src/mes.M1 --LittleEndian --Architecture=1 > src/mes.hex2
   hex2 --LittleEndian --Architecture=1 --BaseAddress=0x1000000 -f stage0/elf32-header.hex2 -f mlibc/crt1.hex2 -f mlibc/libc-mes.hex2 -f src/mes.hex2 -f stage0/elf32-footer-single-main.hex2 > src/mes-mes
   exec_enable src/mes-mes

* mlibc/crt1.M1: New File.
* mlibc/libc-mes.M1: New File.
* src/mes.M1: New File.

3 years agoguix: Bump Nyacc to 0.82.0.
Jan Nieuwenhuizen [Sun, 10 Sep 2017 19:10:08 +0000 (21:10 +0200)]
guix: Bump Nyacc to 0.82.0.

* guix.scm (nyacc): Bump to 0.82.0.

3 years agomescc: Support Nyacc-0.81.0.
Jan Nieuwenhuizen [Sun, 10 Sep 2017 19:09:23 +0000 (21:09 +0200)]
mescc: Support Nyacc-0.81.0.

* module/language/c99/compiler.mes (ast->info): Handle asm-expr from
  Nyacc 0.81.0.

3 years agotinycc: scaffold/main.c: running tcc-compiled binary #3.
Jan Nieuwenhuizen [Sun, 3 Sep 2017 08:43:02 +0000 (10:43 +0200)]
tinycc: scaffold/main.c: running tcc-compiled binary #3.

* scaffold/main.c (main): Remove asm.

3 years agomescc: Tinycc support: struct by value assign.
Jan Nieuwenhuizen [Sun, 10 Sep 2017 14:59:53 +0000 (16:59 +0200)]
mescc: Tinycc support: struct by value assign.

* module/language/c99/compiler.mes (expr->accu): warn for unsupported
  sizes.
* scaffold/tests/7h-struct-assign.c (test): Test it.

3 years agotinycc: scaffold/main.c: running tcc-compiled binary #2.
Jan Nieuwenhuizen [Sat, 2 Sep 2017 22:37:39 +0000 (00:37 +0200)]
tinycc: scaffold/main.c: running tcc-compiled binary #2.

* scaffold/main.c (main)[__i386__]: Rename from _start.

3 years agobuild: compile crt1.c, libc-mesc.c and <input>.c separately.
Jan Nieuwenhuizen [Sun, 10 Sep 2017 14:59:43 +0000 (16:59 +0200)]
build: compile crt1.c, libc-mesc.c and <input>.c separately.

* mlibc/crt1.c: New file.
* mlibc/libc-mes.c (_start): Remove.
* mlibc/libc-gcc.c (_start): Remove.
* make.scm (LINK.hex2, bin.mescc): Move from guile/guix/make.scm.
* guile/guix/make.scm (LINK.hex2, bin.mescc): Remove.

3 years agomescc: Tinycc support: refactor _start.
Jan Nieuwenhuizen [Sun, 3 Sep 2017 06:18:18 +0000 (08:18 +0200)]
mescc: Tinycc support: refactor _start.

* mlibc/libc-mes.c (_start): Refactor.
  (_env): Remove.
* stage0/x86.M1:

3 years agotinycc: scaffold/main.c: first running tcc-compiled binary.
Jan Nieuwenhuizen [Sat, 19 Aug 2017 09:35:58 +0000 (11:35 +0200)]
tinycc: scaffold/main.c: first running tcc-compiled binary.

* scaffold/main.c (_start): Exit 42 using asm.