mes.git
2 years agoRelease 0.8. v0.8
Jan Nieuwenhuizen [Sun, 25 Jun 2017 16:36:25 +0000 (18:36 +0200)]
Release 0.8.

* configure (VERSION): Bump.

2 years agobuild: Release update.
Jan Nieuwenhuizen [Sun, 25 Jun 2017 15:40:38 +0000 (17:40 +0200)]
build: Release update.

* configure (main): Make hex2 required.
* guix.scm (mes): Add mescc-tools to propagated-inputs.  Update commit, hash.

2 years agodoc: Release update.
Jan Nieuwenhuizen [Thu, 8 Jun 2017 18:39:24 +0000 (20:39 +0200)]
doc: Release update.

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

2 years agomescc: Remove ELF creation, handled by hex2 now.
Jan Nieuwenhuizen [Sun, 25 Jun 2017 07:26:25 +0000 (09:26 +0200)]
mescc: Remove ELF creation, handled by hex2 now.

* module/language/c99/compiler.scm (make-global, global:type,
  global:pointer, global:value): Move from elf-util.mes
* module/mes/as.mes: New file.
* module/mes/as-i386.mes: Use it.
* module/mes/as-i386.scm: Use it.
* module/mes/elf-util.mes: Remove.
* module/mes/elf.mes (elf32-addr, elf32-half, elf32-off, elf32-word,
  make-elf, write-any, object->elf): Remove
  (hex2->elf): New function with dummy implementation.
* module/mes/elf.scm: Update exports.
* module/mes/hex2.mes (object->elf): New function.
* module/mes/hex2.scm: Export it.

2 years agomescc: Produce object files in hex2 format, remove hex3.
Jan Nieuwenhuizen [Sun, 25 Jun 2017 07:33:55 +0000 (09:33 +0200)]
mescc: Produce object files in hex2 format, remove hex3.

* GNUmakefile (HEX2_FLAGS): New variable.
* make/mescc-guile.make ($(OUT)/$(TARGET)): Use HEX2 for linking.
* make/mescc-mes.make ($(OUT)/$(TARGET)): Likewise.
* guile/mescc.scm (main): Remove hex3 support.
* scripts/mescc.mes (main): Likewise.
* stage0/elf32-0header.hex2: New file, merging of elf32.hex and elf32-header.hex2.
* stage0/elf-0footer.hex2: New file.
* stage0/elf32-header.hex2: Rename from elf32-header-exit-42.hex2,
  repurpose as generic debug heder.
* stage0/elf32-footer-single-main.hex2: Rename from elf32-footer-exit-42.hex2,
  repurpose as generic debug footer for single-main source.
* stage0/exit-42.c: New file.
* stage0/stage0.make ($(OUT)/0exit-42): Test 0header, 0footer.
  ($(OUT)/exit-42.guile): Test generic debug header, footer.
* stage0/elf32.hex2: Remove.

2 years agobuild: Add stage0 hex2 test.
Jan Nieuwenhuizen [Fri, 23 Jun 2017 18:18:09 +0000 (20:18 +0200)]
build: Add stage0 hex2 test.

* configure (HEX2): Check for hex2 from MESCC_tools.
* INSTALL: Mention it.
* GNUmakefile (SUBDIRS): Add stage0.
* make/check-cc.make: New file.
* make/check.make: Remove CC-not-empty guard.
* scaffold/scaffold.make: Update CC check targets.

2 years agostage0: Move to-be-generated part of body to footer.
Jan Nieuwenhuizen [Wed, 21 Jun 2017 05:05:26 +0000 (07:05 +0200)]
stage0: Move to-be-generated part of body to footer.

* stage0/elf32-footer-exit-42.hex2: Add ELF_str, ELF_sym from body.
* stage0/elf32-body-exit-42.hex2: Remove ELF_str, ELF_sym.

2 years agostage0: Leverage label>base in stage0 gdb header.
Jan Nieuwenhuizen [Mon, 19 Jun 2017 20:45:51 +0000 (22:45 +0200)]
stage0: Leverage label>base in stage0 gdb header.

* stage0/elf32-header-exit-42.hex2: Replace calculated addresses with label>base.
* stage0/elf32-body-exit-42.hex2: Likewise.

2 years agostage0: Move stage0's section-headers before text.
Jan Nieuwenhuizen [Mon, 19 Jun 2017 07:52:27 +0000 (09:52 +0200)]
stage0: Move stage0's section-headers before text.

* stage0/elf32-header-exit-42.hex2: Add section-headers.
* stage0/elf32-body-exit-42.hex2: Update.
* stage0/elf32-footer-exit-42.hex2: Remove section-headers.

2 years agostage0: Add stage0 hex2 gdb header and footer example.
Jan Nieuwenhuizen [Sun, 18 Jun 2017 19:06:27 +0000 (21:06 +0200)]
stage0: Add stage0 hex2 gdb header and footer example.

* stage0/elf32-header-exit-42.hex2: New file.
* stage0/elf32-footer-exit-42.hex2: New file.

2 years agomescc: Remove jump calculation, use labels: rename jumps.
Jan Nieuwenhuizen [Tue, 13 Jun 2017 18:31:03 +0000 (20:31 +0200)]
mescc: Remove jump calculation, use labels: rename jumps.

* module/mes/as-i386.mes (i386:jump, i386:jump-byte-z, i386:jump-g,
  i386:jump-ge, i386:jump-nc, i386:jump-ncz, i386:jump-nz,
  i386:jump-z): Rename from i386:jump-label*.
* module/mes/as-i386.scm (mes): Update exports.
* module/language/c99/compiler.mes (ast->info): Update callers.

2 years agomescc: Remove jump calculation, use labels: remove offset-jumps.
Jan Nieuwenhuizen [Tue, 13 Jun 2017 18:27:40 +0000 (20:27 +0200)]
mescc: Remove jump calculation, use labels: remove offset-jumps.

* module/mes/as-i386.mes (i386:XXjump, i386:Xjump, i386:Xjump-c,
  i386:Xjump-cz, i386:Xjump-g, i386:Xjump-ge, i386:Xjump-l,
  i386:Xjump-le, i386:Xjump-nc, i386:Xjump-ncz, i386:Xjump-ncz",
  i386:Xjump-nz, i386:Xjump-z, i386:jump, i386:jump-byte-nz,
  i386:jump-byte-z, i386:jump-c, i386:jump-cz, i386:jump-le,
  i386:jump-nc, i386:jump-ncz, i386:jump-nz, i386:jump-z,
  i386:test-jump-z): Remove.
* module/mes/as-i386.scm: Remove export.

2 years agomescc: Remove jump calculation, use labels: cleanup.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 18:58:49 +0000 (20:58 +0200)]
mescc: Remove jump calculation, use labels: cleanup.

* module/language/c99/compiler.mes (test->jump->info): Remove.

2 years agomescc: Remove jump calculation, use labels: switch.
Jan Nieuwenhuizen [Tue, 13 Jun 2017 18:20:38 +0000 (20:20 +0200)]
mescc: Remove jump calculation, use labels: switch.

* module/language/c99/compiler.mes (expr->accu): Refactor (switch ...).
  (clause->info): Refactor.

2 years agomescc: Remove jump calculation, use labels: and, or.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 20:11:19 +0000 (22:11 +0200)]
mescc: Remove jump calculation, use labels: and, or.

* module/language/c99/compiler.mes (expr->accu): Refactor (and
  ...), (or ...).

2 years agomescc: Remove jump calculation, use labels: if.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 18:11:37 +0000 (20:11 +0200)]
mescc: Remove jump calculation, use labels: if.

* module/language/c99/compiler.mes (ast->info): Refactor (if ...)
  using test-jump-label->info.

2 years agomescc: Remove jump calculation, use labels: for.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 17:46:35 +0000 (19:46 +0200)]
mescc: Remove jump calculation, use labels: for.

* module/language/c99/compiler.mes (ast->info): Refactor (for ...)
  using test-jump-label->info.

2 years agomescc: Remove jump calculation, use labels: do while.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 17:00:24 +0000 (19:00 +0200)]
mescc: Remove jump calculation, use labels: do while.

* module/language/c99/compiler.mes (ast->info): Refactor (do-while
  ...)  using test-jump-label->info.

2 years agomescc: Remove jump calculation, use labels: ?.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 16:43:25 +0000 (18:43 +0200)]
mescc: Remove jump calculation, use labels: ?.

* module/language/c99/compiler.mes (ast->info): Refactor (cond-expr
  ...)  using test-jump-label->info.

2 years agomescc: Support continue in while.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 15:10:29 +0000 (17:10 +0200)]
mescc: Support continue in while.

* module/language/c99/compiler.mes (make): Add continue field.
  (.continue): New function.
  (clone): Support continue field.
  (ast->info): Support continue.
* scaffold/t.c (test): Test it.

2 years agomescc: Remove jump calculation, use labels: while.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 19:06:12 +0000 (21:06 +0200)]
mescc: Remove jump calculation, use labels: while.

* module/language/c99/compiler.mes (ast->info): Refactor (while ...)
  using test-jump-label->info.

2 years agomescc: Remove jump calculation, use labels: prepare.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 19:00:50 +0000 (21:00 +0200)]
mescc: Remove jump calculation, use labels: prepare.

* module/language/c99/compiler.mes (test-jump-label->info): New
  function.
* module/mes/as-i386.mes (i386:jump-label-z,i386:jump-label-byte-z,
  i386:jump-label-g, i386:jump-label-ge,i386:jump-label-nz): New
  functions.
* module/mes/as-i386.scm: Export them.

2 years agomescc: Remove duplication of string globals.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 08:49:31 +0000 (10:49 +0200)]
mescc: Remove duplication of string globals.

* module/language/c99/compiler.mes (expr->global): Curry-in globals.
  Update callers.
  (initzer->global): Likewise.

2 years agomescc: Unify labels.
Jan Nieuwenhuizen [Sun, 11 Jun 2017 16:05:56 +0000 (18:05 +0200)]
mescc: Unify labels.

* module/language/c99/compiler.mes: Use (#:address label) (#local
  label) (#:relative label) thoughout.
* module/mes/elf-util.mes (add-s:-prefix, drop-s:-prefix): Remove.
  (function->text): Update.
* module/mes/hex2.mes (write-hex2): Update.

2 years agomescc: Write object files in hex2 or hex3 format.
Jan Nieuwenhuizen [Sun, 11 Jun 2017 11:11:40 +0000 (13:11 +0200)]
mescc: Write object files in hex2 or hex3 format.

* stage0/elf32.hex2: New file.
* module/mes/hex2.mes: New file.
* module/mes/hex2.scm: New file.
* module/language/c99/compiler.mes: Eradicate object lamdas.
  (current-eval, dec-xhex, function:-object->text, object->elf,
  object->objects, merge-objects, alist-add): Remove.
* module/mes/elf.mes (object->elf): New function, move from compiler.mes.
* module/mes/elf.scm: Export it.
* guile/mescc.scm (parse-opts): Add -g.
  (main): Use it.
* scripts/mescc.mes: Likewise.
* scripts/mescc-guile.make (MESCC.scm, MESLD.scm): Add -g flag.
* scripts/mescc-mes.make (MESCC.mes, MESLD.mes): Likewise.
* scaffold/m.c: Add proper includes.
* scaffold/argv.c: New file.
* scaffold/hello.c: Simplify.
* scaffold/micro-mes.c: Add proper includes.
* scaffold/t.c: Add proper includes.

2 years agocore: %moduledir ends with /.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 15:18:31 +0000 (17:18 +0200)]
core: %moduledir ends with /.

* make/install.make (MODULEDIR): Append /.
  (install): Remove /.
* src/mes.c (load_env, bload_env): Update.

2 years agomescc: Put _start at top of mlibc.
Jan Nieuwenhuizen [Sun, 11 Jun 2017 11:01:46 +0000 (13:01 +0200)]
mescc: Put _start at top of mlibc.

* mlibc/libc-mes.c (_start): Move to top.
* mlibc/mini-libc-mes.c (_start): Likewise.
* module/mes/elf-util.mes (function-prefix): Update for _start == 0.
  (function-offset): Likewise.

2 years agomes: Add list-index.
Jan Nieuwenhuizen [Sun, 11 Jun 2017 12:45:01 +0000 (14:45 +0200)]
mes: Add list-index.

* module/srfi/srfi-1.scm (list-index): New function.

2 years agobuild: Bugfix add prepocess dependency on snarfing mes.
Jan Nieuwenhuizen [Thu, 8 Jun 2017 04:57:24 +0000 (06:57 +0200)]
build: Bugfix add prepocess dependency on snarfing mes.

* src/src.make ($(OUT)/$(DIR)/mes.guile-E, $(OUT)/$(DIR)/mes.mes-E):
  Depend on mes snarfing.

2 years agotest: Support for non-Guix[SD]: cater for missing CC/CC32 compilers.
Jan Nieuwenhuizen [Tue, 20 Jun 2017 17:07:31 +0000 (19:07 +0200)]
test: Support for non-Guix[SD]: cater for missing CC/CC32 compilers.

* make/check.make: Skip if CC is not set.
* make/check-mlibc.make: New file.
* scaffold/scaffold.make: Use it for mlibc targets.
* tinycc/tinycc.make: Skip mlibc targets if CC32 not set.

2 years agomescc: Support for non-Guix[SD] builds.
Jan Nieuwenhuizen [Tue, 20 Jun 2017 17:06:19 +0000 (19:06 +0200)]
mescc: Support for non-Guix[SD] builds.

* module/language/c99/compiler.mes (c99-input->full-ast): Cater for
  C_INCLUDE_PATH not set.  Fixes non-Guix[SD] builds.

2 years agobuild: Support for non-Guix[SD]: make CC/CC32 optional in configure too.
Jan Nieuwenhuizen [Mon, 19 Jun 2017 10:01:19 +0000 (12:01 +0200)]
build: Support for non-Guix[SD]: make CC/CC32 optional in configure too.

* configure (optional): New global.
  (BUILD_TRIPLET): Use Guile value.
  (check-version): Add keyword argument #:optional.
  (main): Make CC optional (--with-courage).  Only check for stdio.h,
  limits.h if CC is found.
  Make CC32 check optional.
* scripts/scripts.make: Skip if CC is not set.

2 years agomescc: Bugfix for merging objects.
Jan Nieuwenhuizen [Sun, 4 Jun 2017 20:44:21 +0000 (22:44 +0200)]
mescc: Bugfix for merging objects.

* mlibc/libc-mes.c (main): Declare.
* mlibc/mini-libc-mes.c (g_stdin): Define.
  (main): Declare.
* module/language/c99/compiler.mes (alist-add): Thinko.  Fixes merging
  objects when first declares function of next.

2 years agoguix hash: 0fvzr1ai2rmi46zdi5b2bdjb6s8ip78mkmsk02yxl46rajmp2pb1
Jan Nieuwenhuizen [Sat, 3 Jun 2017 19:53:56 +0000 (21:53 +0200)]
guix hash: 0fvzr1ai2rmi46zdi5b2bdjb6s8ip78mkmsk02yxl46rajmp2pb1

2 years agoRelease 0.7. v0.7
Jan Nieuwenhuizen [Sat, 3 Jun 2017 10:00:08 +0000 (12:00 +0200)]
Release 0.7.

* configure (VERSION): Bump.

2 years agodoc: Release update.
Jan Nieuwenhuizen [Mon, 22 May 2017 21:35:39 +0000 (23:35 +0200)]
doc: Release update.

* AUTHORS: Remove module/nyacc.
* HACKING: Release uppdate.
* NEWS: Release uppdate.
* doc/ANNOUNCE-0.7: New file.

2 years agoguix: mes.git: Add git hash to version.
Jan Nieuwenhuizen [Sat, 3 Jun 2017 19:18:53 +0000 (21:18 +0200)]
guix: mes.git: Add git hash to version.

* guix.scm (mes.git): Add git hash to version.

2 years agomescc: move include into share/mlibc, allows installing alongside gcc.
Jan Nieuwenhuizen [Sat, 3 Jun 2017 10:11:57 +0000 (12:11 +0200)]
mescc: move include into share/mlibc, allows installing alongside gcc.

* mlibc: Rename from libc.
* HACKING: Update for name change.
* make/bin.make: Likewise.
* make/mescc-guile.make: Likewise.
* make/mescc-mes.make: Likewise.
* scaffold/scaffold.make: Likewise.
* make/install.make: Likewise.
  (install): Install mlibc into share/mlibc.

2 years agomescc: Handle any const, by ignoring.
Jan Nieuwenhuizen [Fri, 2 Jun 2017 11:12:56 +0000 (13:12 +0200)]
mescc: Handle any const, by ignoring.

* module/language/c99/compiler.mes (ast-strip-const): New function.
  (c99-input->ast): Use it.
  (type->size, type->description, ast->info): Remove const handling.

2 years agomescc: Support array in struct.
Jan Nieuwenhuizen [Wed, 31 May 2017 18:52:48 +0000 (20:52 +0200)]
mescc: Support array in struct.

* module/language/c99/compiler.mes: (field:size, field-offset): New
  functions.  Update callers, use them throughout.
  (ast->info): Support declaration of struct and typedef'ed struct
  variable with array fields.
  (expr->accu, expr->accu*): Support foo.bar[baz], foo->bar[baz].
* scaffold/t-tcc.c: Test it.

2 years agobuild: Skip gcc, mlibc, guile or mes builds using CC=, CC32=, GUILE= or MES=.
Jan Nieuwenhuizen [Sun, 28 May 2017 16:32:53 +0000 (18:32 +0200)]
build: Skip gcc, mlibc, guile or mes builds using CC=, CC32=, GUILE= or MES=.

* GNUmakefile (build-scripts): New target
  (HELP_TOP): Mention it.
* configure (main): Write GUILE_FOR_BUILD.
* make/bin-mlibc.make: Skip if CC32 is not set.
* make/bin.make: Skip if CC is not set.
* make/install.make (install): Only install $(OUT)/mes.mes if
  MES_BOOTSTRAP is set.
* make/mescc-guile.make: Skip if GUILE is not set.
* make/mescc-mes.make: Skip if MES is not set.
* HACKING: write something about

2 years agocore: Always include reader.c, drop binary read-0-32.mo dependency.
Jan Nieuwenhuizen [Sun, 28 May 2017 14:03:45 +0000 (16:03 +0200)]
core: Always include reader.c, drop binary read-0-32.mo dependency.

* module/language/c99/compiler.mes (c99-input->full-ast): Remove
  obsolete __NYACC__ and MES_FULL defines.
* src/mes.c [!MES_FULL]: Include reader-mes.h.
  (mes_builtins) [!MES_FULL]: Include reader.mes.i, reader.me.environment.i.
  [!MES_FULL]: Include reader.c.
  (main) [!MES_FULL]: By default call load_env, only call bload_env
  when --load is supplied.  WAS: Always bload read-0-32.mo.
* src/reader.c (__end_of__mes_): Remove.
  (dump): Remove option of dumping tiny test program.
* make/mescc-mes.make ($(OUT)/$(TARGET), mescc.mes-ccompile,
  mescc.mes.c-compile-E): Depend on $(OUT)/mes, scripts/mes.
* src/src.make (mes.guile): Remove module/mes/read-32-0 dependency.
  Do not build $(OUT)/mes.mes.
* module/module.make (module/mes/read-0.mo, module/mes/read-0-32.mo,
  module/mes/tiny-0-32.mo): Remove targets.
  (CLEAN): Do not add them.  Neither install $(OUT)/mes.mes.
* .gitignore: Remove exceptions for them.
* make/install.make (install): Do not install them.
* HACKING: Update info about creating module/mes/read-32-0.mo.
* scaffold/mini-mes.c: Remove.
* scaffold/tiny-mes.c: Remove.
* scaffold/cons-mes.c: Remove.
* scaffold/scaffold.make (tiny-mes.libc, tiny-mes.guile, tiny-mes.mes,
  mini-mes.libc, mini-mes.guile, mini-mes.mes): Reemove targets.

2 years agomescc: Add missing builtins.
Jan Nieuwenhuizen [Sat, 27 May 2017 07:28:08 +0000 (09:28 +0200)]
mescc: Add missing builtins.

* module/language/c99/compiler.mes (i386:type-alist): Add missing
  builtins.  TODO: identify and handle unsigned.

2 years agomescc: Support typedef and many TCC declaration variants.
Jan Nieuwenhuizen [Thu, 25 May 2017 05:32:29 +0000 (07:32 +0200)]
mescc: Support typedef and many TCC declaration variants.

* module/language/c99/compiler.mes (ast->info): Register typedefs in types.
  (enum-def-list->constants): Support addition and substraction in
  enum field values.
  (get-type): New function.  Use throughout.

2 years agomescc: Handle comments anywhere.
Jan Nieuwenhuizen [Thu, 25 May 2017 17:48:26 +0000 (19:48 +0200)]
mescc: Handle comments anywhere.

* module/language/c99/compiler.mes (c99-input->full-ast): Rename from c99-input->full-ast.
  (ast-strip-comment, c99-input->ast): New functions.
  (ast->info): Remove comment exceptions.

2 years agomescc: Support anonymous enums.
Jan Nieuwenhuizen [Thu, 25 May 2017 05:57:26 +0000 (07:57 +0200)]
mescc: Support anonymous enums.

* module/language/c99/compiler.mes (enum-def-list->constants): New function.
  (ast->info): Support anonymous enum.

2 years agomescc: C99 header files and declaraions.
Jan Nieuwenhuizen [Tue, 23 May 2017 05:16:08 +0000 (07:16 +0200)]
mescc: C99 header files and declaraions.

* libc/include/assert.h (assert_fail):
* libc/include/stdio.h:
+int eputs (char const* s);
+int fputs (char const* s);
+int puts (char const* s);
+int putchar (int c);
+int fputc (int c, int fd);
+int getchar ();
* libc/include/stdlib.h:
+char* getenv (char const* s)
+int atoi (char const *s);
+int *malloc (size_t);
+int *realloc (int *p, int size);
* libc/include/unistd.h (access):
* src/lib.c (display_helper):
* src/mes.c (read_input_file_env):
* src/posix.c: Include unistd.h.

2 years agoguix: Update from Guix.
Jan Nieuwenhuizen [Tue, 23 May 2017 18:11:51 +0000 (20:11 +0200)]
guix: Update from Guix.

* guix.scm (mes): Update from Guix.

2 years agobuild: Use separate preprocessing stage for mescc.
Jan Nieuwenhuizen [Mon, 22 May 2017 19:15:58 +0000 (21:15 +0200)]
build: Use separate preprocessing stage for mescc.

* make/mescc-guile.make (mescc.scm-c-preprocess, (mescc.scm-compile-E):
  New defines.
  [!MESC_DIRECT]Compile .o via separate preprocessed .E stage.

2 years agomescc: support -E.
Jan Nieuwenhuizen [Mon, 22 May 2017 17:22:18 +0000 (19:22 +0200)]
mescc: support -E.

* guile/mescc.scm (parse-opts): Add -E.
  (source->ast): New function.
  (main): Use it.
* scripts/mescc.mes (parse-opts): Add -E.
  (source->ast): New function.
  (main): Use it.

2 years agomescc: Refactor mlibc compilation.
Jan Nieuwenhuizen [Sun, 21 May 2017 20:25:02 +0000 (22:25 +0200)]
mescc: Refactor mlibc compilation.

* libc/libc-mes.c: New file.  Contents from module/mes/libc.mes, module/mes/libc-i386.mes.
* libc/libc-gcc.c: Rename from libc/mlibc.c, include libc/mstart.c
* libc/mstart.c: Remove.
* module/mes/libc-i386.mes: Remove.
* module/mes/libc-i386.scm: Remove.
* module/mes/libc.mes: Remove.
* module/mes/libc.scm: Remove.
* GNUmakefile (CFLAGS): Include libc-gcc.c (WAS: mlibc.c).
* make/bin-mlibc.make (C_FLAGS): Remove start.c include.
* make/mescc-guile.make: Rewrite using compile, link.
* make/mescc-mes.make: Likewise.
* scaffold/m.c: Update.

2 years agomescc: support -c, -o.
Jan Nieuwenhuizen [Wed, 17 May 2017 11:56:25 +0000 (13:56 +0200)]
mescc: support -c, -o.

* module/language/c99/compiler.mes: Throughout: quote lambda's.
  (current-eval): New function.
  Thanks Andy!
  (object->list): New function.  Update callers.
  (c99-input->info): Dump a.o.
  (initzer->non-const, function:object->list): New functions.
  (info:object->list): New function.
  (c99-input->elf): Call it.
* module/mes/as-i386: Throughout: quote lambda's.
* scripts/mescc.mes (main): Rewrite.
* guile/mescc.scm (main): Likewise.

2 years agomes: Bugifx for number->string radix > 10.
Jan Nieuwenhuizen [Tue, 23 May 2017 04:28:37 +0000 (06:28 +0200)]
mes: Bugifx for number->string radix > 10.

* module/mes/scm.mes (number->string): Bugfix for `10' -> hex/radix > 10.

2 years agomes: Simplify read-string.
Jan Nieuwenhuizen [Sun, 21 May 2017 10:21:07 +0000 (12:21 +0200)]
mes: Simplify read-string.

* module/mes/guile.mes (read-string): Simplify, probably fix even.

2 years agomescc: Remove LALR C frontend prototype.
Jan Nieuwenhuizen [Sun, 21 May 2017 10:38:29 +0000 (12:38 +0200)]
mescc: Remove LALR C frontend prototype.

* module/language/c/compiler.mes: Remove.
* module/language/c/lexer.mes: Remove.
* module/language/c/parser.mes: Remove.

2 years agomes: Add negate.
Jan Nieuwenhuizen [Sun, 21 May 2017 10:33:16 +0000 (12:33 +0200)]
mes: Add negate.

* module/mes/scm.mes (negate): New function.

2 years agocore: Add current-output-port, open-output-file, set-current-output-port.
Jan Nieuwenhuizen [Fri, 19 May 2017 04:56:47 +0000 (06:56 +0200)]
core: Add current-output-port, open-output-file, set-current-output-port.

* libc/include/fcntl.h: Declare it.  Add some fcntl defines.
* libc/include/stdio.h: Remove fcntl defines, Declare g_stdout.
* module/language/c99/compiler.mes (c99-input->ast): Define O_WRONLY, O_RDWR.
* module/mes/guile.mes (with-output-to-file, with-output-to-port): New functions.
* src/posix.c (current_output_port, open_output_file,
  set_current_output_port): New functions.
* libc/mlibc.c (open): Add optional mode parameter.
* module/mes/libc-i386.mes (i386:open): Forward third parameter.
* scaffold/mini-mes.c (main): Init g_stdout.
* src/mes.c (main): Likewise.

2 years agomes: Support octal numbers in reader.
Jan Nieuwenhuizen [Fri, 19 May 2017 19:10:08 +0000 (21:10 +0200)]
mes: Support octal numbers in reader.

* module/mes/read-0.mes (read-octal): New function.
  (read-word): Use it.
* tests/read.test: Test it.

2 years agomes: Add getopt-long.
Jan Nieuwenhuizen [Thu, 18 May 2017 20:03:02 +0000 (22:03 +0200)]
mes: Add getopt-long.

* module/mes/getopt-long.scm: New file, imported from Guile-1.8,
* module/mes/getopt-long.mes: Include it.
* AUTHORS: Mention it.

2 years agomes: Add string-rindex.
Jan Nieuwenhuizen [Thu, 18 May 2017 22:41:01 +0000 (00:41 +0200)]
mes: Add string-rindex.

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

2 years agomes: Support predicate with string-index.
Jan Nieuwenhuizen [Thu, 18 May 2017 22:51:23 +0000 (00:51 +0200)]
mes: Support predicate with string-index.

* module/srfi/srfi-13.mes (string-index): Support predicate.

2 years agomes: Add string-suffix?
Jan Nieuwenhuizen [Thu, 18 May 2017 22:23:13 +0000 (00:23 +0200)]
mes: Add string-suffix?

* module/mes/scm.mes (string-prefix?): Refactor.
  (string-suffix?): New function.

2 years agoPurging binary blobs
Jeremiah Orians [Sat, 27 May 2017 04:56:06 +0000 (00:56 -0400)]
Purging binary blobs

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

2 years agodoc: Update.
Jan Nieuwenhuizen [Mon, 15 May 2017 05:01:01 +0000 (07:01 +0200)]
doc: Update.

* AUTHORS: Remove module/nyacc.

2 years agodoc: typo
Jan Nieuwenhuizen [Sun, 14 May 2017 16:09:22 +0000 (18:09 +0200)]
doc: typo

2 years agoguix hash: 0qqywk3siyhf08v7xac08lqldklrqfndlp495wgy6ii9fn93197k
Jan Nieuwenhuizen [Sun, 14 May 2017 16:00:38 +0000 (18:00 +0200)]
guix hash: 0qqywk3siyhf08v7xac08lqldklrqfndlp495wgy6ii9fn93197k

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

* configure (VERSION): Bump.

2 years agodoc: Release update.
Jan Nieuwenhuizen [Sat, 6 May 2017 15:46:41 +0000 (17:46 +0200)]
doc: Release update.

* NEWS: Update.

2 years agotest: Run 33/55 tests of ../tinycc/tests/test2 if avaiable.
Jan Nieuwenhuizen [Thu, 4 May 2017 17:41:45 +0000 (19:41 +0200)]
test: Run 33/55 tests of ../tinycc/tests/test2 if avaiable.

* make/check-tinycc.make: New file.
* tinycc/tinycc.make: New file.
* GNUmakefile (SUBDIRS): Add tinycc.

2 years agobuild: Support i686, support development for arm.
Jan Nieuwenhuizen [Sun, 14 May 2017 07:03:06 +0000 (09:03 +0200)]
build: Support i686, support development for arm.

* configure (CC32): Accept arm-* as 32 bit compiler.
  (check-compile-header-c, check-header-c): New functions.
  (parse-opts): New option: --with-courage.
  (main): Check for platform, stdio.h, limits.h.

2 years agomescc: Minimal support for short.
Jan Nieuwenhuizen [Mon, 8 May 2017 19:34:08 +0000 (21:34 +0200)]
mescc: Minimal support for short.

* module/language/c99/compiler.mes (i386:type-alist): Add short.

2 years agomescc: Add strcpy.
Jan Nieuwenhuizen [Mon, 8 May 2017 19:15:53 +0000 (21:15 +0200)]
mescc: Add strcpy.

* libc/include/string.h (strcpy): Declare.
* libc/mlibc.c (strcpy): New function.
* module/mes/libc.mes (strcpy): New function.
  (libc): Add it.
* scaffold/t.c (string_test): Test it.

2 years agomescc: Enhance sizeof support.
Jan Nieuwenhuizen [Mon, 8 May 2017 19:32:32 +0000 (21:32 +0200)]
mescc: Enhance sizeof support.

* module/language/c99/compiler.mes (expr->accu): Support sizeof (simple-type),
  sizeof (var).

2 years agomescc: Support void return.
Jan Nieuwenhuizen [Mon, 8 May 2017 18:06:20 +0000 (20:06 +0200)]
mescc: Support void return.

* module/language/c99/compiler.mes (ast-info): Support `return'.

2 years agonyacc: Unbundle.
Jan Nieuwenhuizen [Sun, 7 May 2017 08:04:32 +0000 (10:04 +0200)]
nyacc: Unbundle.

* configure (check-version): Use keyword parameters, add #:command
  parameter.
  (main): Check for Nyacc.
* INSTALL: Mention Nyacc as dependency.
* make/guile.make (all-go): Compile in guile dir.
* module/module.make (SCM_FILES): Remove Nyacc filters.
* module/nyacc/BUGS: Remove.
* module/nyacc/ChangeLog: Remove.
* module/nyacc/README: Remove.
* module/nyacc/README.nyacc: Remove.
* module/nyacc/bison.scm: Remove.
* module/nyacc/export.scm: Remove.
* module/nyacc/import.scm: Remove.
* module/nyacc/lalr.scm: Remove.
* module/nyacc/lalr2.scm: Remove.
* module/nyacc/lang/c99/README: Remove.
* module/nyacc/lang/c99/body.scm: Remove.
* module/nyacc/lang/c99/cpp.scm: Remove.
* module/nyacc/lang/c99/cppmach.scm: Remove.
* module/nyacc/lang/c99/mach.d/c99act.scm: Remove.
* module/nyacc/lang/c99/mach.d/c99tab.scm: Remove.
* module/nyacc/lang/c99/mach.d/c99xact.scm: Remove.
* module/nyacc/lang/c99/mach.d/c99xtab.scm: Remove.
* module/nyacc/lang/c99/mach.d/cppact.scm: Remove.
* module/nyacc/lang/c99/mach.d/cpptab.scm: Remove.
* module/nyacc/lang/c99/mach.scm: Remove.
* module/nyacc/lang/c99/parser.scm: Remove.
* module/nyacc/lang/c99/pprint.scm: Remove.
* module/nyacc/lang/c99/util1.scm: Remove.
* module/nyacc/lang/c99/util2.scm: Remove.
* module/nyacc/lang/c99/xparser.scm: Remove.
* module/nyacc/lang/calc/parser.scm: Remove.
* module/nyacc/lang/util.scm: Remove.
* module/nyacc/lex.scm: Remove.
* module/nyacc/parse.scm: Remove.
* module/nyacc/util.scm: Remove.

2 years agomes: Consider GUILE_LOAD_PATH for include-from-path.
Jan Nieuwenhuizen [Sun, 7 May 2017 06:23:20 +0000 (08:23 +0200)]
mes: Consider GUILE_LOAD_PATH for include-from-path.

* module/mes/guile.scm (include-from-path): New macro.

2 years agomescc: Bugfixes for local char[].
Jan Nieuwenhuizen [Sun, 7 May 2017 05:36:44 +0000 (07:36 +0200)]
mescc: Bugfixes for local char[].

* module/language/c99/compiler.mes (push-ident): Cater for local arrays.
  (expr->accu): Avoid post-inc/post-dec twice on rhs of assignment.
  Fix size lookup for local char arrayns.

2 years agonyacc: Update to 0.78.
Jan Nieuwenhuizen [Sat, 6 May 2017 20:35:46 +0000 (22:35 +0200)]
nyacc: Update to 0.78.

2 years agomes: Add srfi-16 to Nyacc Guile support.
Jan Nieuwenhuizen [Sat, 6 May 2017 20:47:45 +0000 (22:47 +0200)]
mes: Add srfi-16 to Nyacc Guile support.

* module/mes/guile.mes: Include srfi-16 for Nyacc.

2 years agomes: Basic support for string-index.
Jan Nieuwenhuizen [Sat, 6 May 2017 21:00:27 +0000 (23:00 +0200)]
mes: Basic support for string-index.

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

2 years agomes: Support #\cr short form in reader.
Jan Nieuwenhuizen [Sat, 6 May 2017 20:49:08 +0000 (22:49 +0200)]
mes: Support #\cr short form in reader.

* module/mes/read-0.mes (read-character): Support #\cr short form for #\return.
* module/mes/read-0-32.mo: Regenerate.

2 years agomes: Support case-lambda.
Jan Nieuwenhuizen [Sat, 6 May 2017 20:42:21 +0000 (22:42 +0200)]
mes: Support case-lambda.

* module/srfi/srfi-16.scm: New file.
* AUTHORS: Mention it.
* module/srfi/srfi-16.mes: New file.

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

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

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

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

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

2 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;'.

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

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

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

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

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

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

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

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

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

2 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")

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

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