mes.git
3 years agomescc: Support goto in while body.
Jan Nieuwenhuizen [Fri, 10 Mar 2017 06:01:51 +0000 (07:01 +0100)]
mescc: Support goto in while body.

* module/language/c99/compiler.mes (ast->info): Support goto in while
  body.
* doc/examples/t.c (test): Test it.

3 years agocore+mini-mes: Move function name to struct function.
Jan Nieuwenhuizen [Thu, 9 Mar 2017 22:27:12 +0000 (23:27 +0100)]
core+mini-mes: Move function name to struct function.

* module/language/c99/compiler.mes (expr->arg): Handle char arguments.
* doc/examples/cons-mes.c (struct function): Add name field.
* doc/examples/mini-mes.c: Likewise.
  (mes_builtins): Update.
* mes.c: Likewise.
* build-aux/mes-snarf.scm: Update.

3 years agomescc: Support strings in struct initialization.
Jan Nieuwenhuizen [Thu, 9 Mar 2017 07:14:27 +0000 (08:14 +0100)]
mescc: Support strings in struct initialization.

* module/mes/elf-util.mes (add-s:-prefix, drop-s:-prefix): New functions.
* module/mes/elf-util.scm: Export them.
* module/language/c99/compiler.mes (string->global): Add `s:' prefix
  to global strings.  Update users.
  (expr->arg): Update.
  (expr->accu): Handle string expressions.
  (initzer->global): New function.
  (struct-field): Handle string field.
* doc/examples/t.c: Test it.
* doc/examples/mini-mes.c: Use it.

dun!

3 years agomescc: Display sexps better.
Jan Nieuwenhuizen [Tue, 7 Mar 2017 21:33:59 +0000 (22:33 +0100)]
mescc: Display sexps better.

* module/mes/elf.mes (make-elf): Only display data sections smaller
  than 200 bytes.
* doc/examples/mini-mes.c (simple_bload_env): Read mini-0-32.mes.
* doc/examples/cons-mes.c (display_): Support symbols and specials.
* doc/examples/tiny-mes.c: Likewise.
* lib.c:
* mes.c:

3 years agomescc: Compile all of mini-mes.
Jan Nieuwenhuizen [Mon, 6 Mar 2017 06:14:15 +0000 (07:14 +0100)]
mescc: Compile all of mini-mes.

* module/language/c99/compiler.mes (case->jump-info): Support single statement.
* module/mes/elf-util.mes (function-prefix): Workaround for reversed
  functions.  FIXME!
* module/mes/elf.mes:
* scaffold/mini-mes.c (type_t): Rename FUNCTION to TFUNCTION for Nyacc.
  Add missing symbols.
  (eval_apply): Uncomment most.
* scaffold/tiny-mes.c:
* scaffold/cons-mes.c: Remove cruft.

3 years agomescc: Support struct assignment.
Jan Nieuwenhuizen [Thu, 2 Mar 2017 19:26:13 +0000 (20:26 +0100)]
mescc: Support struct assignment.

* module/mes/libc-i386.mes (i386:base-address->accu-address,
  i386:accu+n, i386:base+n): New functions.
* module/mes/libc-i386.scm: Export them.
* module/language/c99/compiler.mes (ast->info): Use them.
* doc/examples/t.c: Test them.
* doc/examples/cons-mes.c: Drop workarounds.
* doc/examples/mini-mes.c: Likewise.
* mes.c:

3 years agomescc: Fix add, sub, lshift.
Jan Nieuwenhuizen [Thu, 2 Mar 2017 19:19:53 +0000 (20:19 +0100)]
mescc: Fix add, sub, lshift.

* module/language/c99/compiler.mes (expr->accu): Fix add, sub, lshift.
* doc/examples/t.c: Test them.
* doc/examples/cons-mes.c:
* doc/examples/mini-mes.c:

3 years agomescc: Support any expression as arg.
Jan Nieuwenhuizen [Mon, 27 Feb 2017 06:50:33 +0000 (07:50 +0100)]
mescc: Support any expression as arg.

* module/language/c99/compiler.mes (expr->arg): Also push parameter,
  always return info.
  (ast->info): Loop over args.  Fixes using function calls in arguments.
* module/mes/libc-i386.mes (i386:push-arg): Remove.
  (i386:call, i386:call-accu): Remove arguments parameter.
* doc/examples/t.c: Test it.

3 years agomescc: Rename expr->accu*.
Jan Nieuwenhuizen [Thu, 2 Mar 2017 05:41:19 +0000 (06:41 +0100)]
mescc: Rename expr->accu*.

* module/language/c99/compiler.mes (expr->accu*): Rename from expr->accuX.

3 years agomescc: Fixes for goto.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 10:13:04 +0000 (12:13 +0200)]
mescc: Fixes for goto.

* module/mes/libc-i386.mes (XXjump): New function.
* module/mes/libc-i386.scm: Export it.
* module/language/c99/compiler.mes (case->jump-info, ast->info): Use it.
* scaffold/t.c: Test it.
* GNUmakefile (cons-mes): New target.
* scaffold/cons-mes.c: New file.
* scaffold/mini-mes.c:

3 years agomescc: Mini-mes runs (cons 0 1) dump.
Jan Nieuwenhuizen [Fri, 24 Feb 2017 12:27:39 +0000 (13:27 +0100)]
mescc: Mini-mes runs (cons 0 1) dump.

* module/mes/libc-i386.mes (i386:Xjump-z, i386:Xjump-c,
  i386:Xjump-nc): New functions.
* module/mes/libc-i386.scm: Export them.
* module/language/c99/compiler.mes (case->jump-info, test-jump->info,
  ast->info): Use them.
* doc/examples/t.c: Test it.
* doc/examples/mini-mes.c: Run it.

3 years agomescc: Run mini-mes.
Jan Nieuwenhuizen [Sun, 29 Jan 2017 14:22:39 +0000 (15:22 +0100)]
mescc: Run mini-mes.

* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
  (test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
  (lambda/label->list): Add text-address parameter.  Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
  (.init): New function.
  (ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
  i386:byte-accu->base-ref, i386:accu->base-ref+n,
  i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
  i386:global-add, i386:global->accu):, i386:local-ref->accu,
  i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.

3 years agodoc: Add gdb assembly debugging info.
Jan Nieuwenhuizen [Sun, 22 Jan 2017 13:16:22 +0000 (14:16 +0100)]
doc: Add gdb assembly debugging info.

* HACKING: Add gdb assembly debugging info.

3 years agodoc: Add fosdem talk.
Jan Nieuwenhuizen [Sat, 21 Jan 2017 15:15:34 +0000 (16:15 +0100)]
doc: Add fosdem talk.

* .gitignore: Ignore beamer/tex stuff.
* doc/fosdem/fosdem.org: New file.
* doc/fosdem/GuixSD.png: New file.
* doc/fosdem/LISP-1-5-page-13-bottom.png: New file.
* doc/fosdem/LISP-1.5-page-13-bottom.png: New file.
* doc/fosdem/LISP-1.5-page-13.pdf: New file.
* doc/fosdem/LISP-1.5-page-13.png: New file.
* doc/fosdem/beamercolorthemeX.sty: New file.
* doc/fosdem/beamerthemeX.sty: New file.
* doc/fosdem/bootstrap-graph.png: New file.
* doc/fosdem/egg.jpeg: New file.
* doc/fosdem/egg.png: New file.
* doc/fosdem/egg.xcf: New file.
* doc/fosdem/fosdem.pdf: New file.
* doc/fosdem/fsb-logo-guile-guix-gnu.png: New file.
* doc/fosdem/fsb-logo-guile-guix-gnu.xcf: New file.
* doc/fosdem/fsb-logo-guile-guix-mes.png: New file.
* doc/fosdem/fsb-logo-guile-guix-mes.xcf: New file.
* doc/fosdem/fsb-logo.png: New file.
* doc/fosdem/guix-build-bootstrap-tarballs.log: New file.
* doc/fosdem/html.sty: New file.
* doc/fosdem/mes.png: New file.
* doc/fosdem/mes.xcf: New file.

3 years agomescc: bugfix: arg as function call.
Jan Nieuwenhuizen [Sat, 21 Jan 2017 12:17:24 +0000 (13:17 +0100)]
mescc: bugfix: arg as function call.

* module/language/c99/compiler.mes (expr->arg):

3 years agomini-mes: gcc: run (cons 0 1).
Jan Nieuwenhuizen [Wed, 18 Jan 2017 06:38:45 +0000 (07:38 +0100)]
mini-mes: gcc: run (cons 0 1).

3 years agonyacc: new release 0.74.3
Matt Wette [Sun, 15 Jan 2017 16:51:21 +0000 (08:51 -0800)]
nyacc: new release 0.74.3

3 years agonyacc: CPP working better now
Matt Wette [Sun, 15 Jan 2017 16:47:49 +0000 (08:47 -0800)]
nyacc: CPP working better now

3 years agonyacc: something working
Matt Wette [Sat, 14 Jan 2017 23:16:28 +0000 (15:16 -0800)]
nyacc: something working

3 years agonyacc: still debugginug
Matt Wette [Sat, 14 Jan 2017 21:30:47 +0000 (13:30 -0800)]
nyacc: still debugginug

3 years agonyacc: working # and ## I think, but lots of debug output too
Matt Wette [Thu, 12 Jan 2017 00:37:58 +0000 (16:37 -0800)]
nyacc: working # and ## I think, but lots of debug output too

3 years agonyacc: exceptions worked on.. still need to fix #
Matt Wette [Wed, 11 Jan 2017 16:14:45 +0000 (08:14 -0800)]
nyacc: exceptions worked on.. still need to fix #

3 years agonyacc: new release 0.74.2
Matt Wette [Wed, 11 Jan 2017 04:10:32 +0000 (20:10 -0800)]
nyacc: new release 0.74.2

3 years agonyacc: fixed C99 use of 'defined XYZ' (no parens)
Matt Wette [Wed, 11 Jan 2017 04:06:28 +0000 (20:06 -0800)]
nyacc: fixed C99 use of 'defined XYZ' (no parens)

3 years agonyacc: merged master
Matt Wette [Wed, 11 Jan 2017 02:57:27 +0000 (18:57 -0800)]
nyacc: merged master

3 years agonyacc: working on fixes
Matt Wette [Wed, 11 Jan 2017 02:56:00 +0000 (18:56 -0800)]
nyacc: working on fixes

3 years agomescc: Read and display sexp dumped by mes.
Jan Nieuwenhuizen [Tue, 10 Jan 2017 19:05:47 +0000 (20:05 +0100)]
mescc: Read and display sexp dumped by mes.

* lib.c (dump)[MES_HACK]: Dump small hello-world sexp, to be handled by
* doc/examples/tiny-mes.c (display_): New function.
* module/mes/libc-i386.mes (i386:accu->base, i386:mem->accu,
  i386:mem+n->accu): New functions.
* module/mes/libc-i386.scm: Export them.
* GNUmakefile (mes-32): New target.

3 years agomescc: Support global pointer assignments.
Jan Nieuwenhuizen [Tue, 17 Jan 2017 17:57:41 +0000 (18:57 +0100)]
mescc: Support global pointer assignments.

* module/mes/libc-i386.mes (base->accu-ref, local-ref->base): New functions.
* module/mes/libc-i386.scm: Export them.
* module/language/c99/compiler.mes (base->ident-ref, ident-ref->base):
  New functions.

3 years agomescc: Add data as loadable ELF section.
Jan Nieuwenhuizen [Tue, 17 Jan 2017 17:48:54 +0000 (18:48 +0100)]
mescc: Add data as loadable ELF section.

* module/mes/elf.mes (make-elf): Add data as loadable section too.

3 years agomescc: Support switch.
Jan Nieuwenhuizen [Tue, 17 Jan 2017 18:03:08 +0000 (19:03 +0100)]
mescc: Support switch.

* module/language/c99/compiler.mes (case->jump-info): New function.
  (ast->info): Use it.
* doc/examples/t.c (swits): Test it.

3 years agomescc: Handle enums.
Jan Nieuwenhuizen [Tue, 10 Jan 2017 21:44:01 +0000 (22:44 +0100)]
mescc: Handle enums.

* module/language/c99/compiler.mes (<types>, <constants>): New slots for info.
 (make, clone): Add them.
 (.types, .constants): New accessors.

3 years agomescc: Update for.
Jan Nieuwenhuizen [Tue, 10 Jan 2017 19:51:29 +0000 (20:51 +0100)]
mescc: Update for.

* module/language/c99/compiler.mes (ast->info): Rewrite for to use
  test->jump->info.

3 years agoscm: Add string-delete.
Jan Nieuwenhuizen [Tue, 17 Jan 2017 17:48:28 +0000 (18:48 +0100)]
scm: Add string-delete.

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

3 years agomescc: Add open/read C-tests.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 10:10:38 +0000 (12:10 +0200)]
mescc: Add open/read C-tests.

* scaffold/m.c: New file.
* scaffold/tiny-mes.c: New file.
* GNUmakefile (m, tiny-mes): New targets.
* scaffold/micro-mes.c: Update gcc-libc bits.
* scaffold/mini-mes.c: Likewise.

3 years agomescc: Support ?.
Jan Nieuwenhuizen [Tue, 10 Jan 2017 19:27:44 +0000 (20:27 +0100)]
mescc: Support ?.

* module/language/c99/compiler.mes (ast->info): Support cond-expr.
* scaffold/t.c (test): Test it.

3 years agomescc: Support open, read.
Jan Nieuwenhuizen [Tue, 10 Jan 2017 19:35:52 +0000 (20:35 +0100)]
mescc: Support open, read.

* module/mes/libc-i386.mes (i386:write): Fix comment.
  (i386:open, i386:read): New functions.
* module/mes/libc-i386.scm: Export them.
* module/language/c99/compiler.mes (i386:libc): Add them.
  (getchar, putchar): New libc functions.
  (libc): Add them.

3 years agomescc: Support globals.
Jan Nieuwenhuizen [Tue, 10 Jan 2017 19:12:06 +0000 (20:12 +0100)]
mescc: Support globals.

* module/language/c99/compiler.mes (write-any): Catch writing of
  procedure and give more debug information.
  (ref-local, ref-global): Remove.
  (push-global-ref, push-global, push-ident-ref): New functions.
  (push-ident): New function.
  (expr->arg): Use them.
  (ident->accu, ident->accu, accu->ident, value->ident, ident->base):
  Take info parameter, also handle globals.
  (ident-address->accu, ident->global, cstring->number): New functions.
  (ast->info): Update.
* module/mes/libc-i386.mes (i386:ret-local): Remove.
  (i386:push-global-ref): Rename from i386:ref-global.
  (i386:push-local): Rename from i386:ref-local.
  (i386:value->local): Rename from i386:local-assign.
  (i386:push-global, i386:push-local-ref, i386:value->global,
  i386:local-address->accu): New functions.
* module/mes/libc-i386.scm: Export them.

3 years agomescc: Small ELF tweaks allowing debugging with gdb.
Jan Nieuwenhuizen [Mon, 9 Jan 2017 19:06:32 +0000 (20:06 +0100)]
mescc: Small ELF tweaks allowing debugging with gdb.

* module/mes/elf.mes (make-elf): Change note section to comment.  Fixes
  readelf.  Add SHF-ALLOC to .text and .data.

3 years agomescc: Handle && in if and while.
Jan Nieuwenhuizen [Sun, 8 Jan 2017 16:51:40 +0000 (17:51 +0100)]
mescc: Handle && in if and while.

* scaffold/t.c (test): Add strcmp tests.
* module/language/c99/compiler.mes (expr->arg):
  (test->jump->info): New function.
  (ast->info): Use it.
* module/mes/libc-i386.mes (i386:global->accu):
  (i386:base-mem->accu): Rename from i386:mem->accu.
  (i386:byte-base-mem->accu): Rename from i386:base-mem->accu.
  (i386:accu-not, i386:global->accu, i386:xor-accu): New functions.
* module/mes/libc-i386.scm: Export them.

3 years agomescc: Proper support for i++,++i,i--,--i.
Jan Nieuwenhuizen [Sat, 7 Jan 2017 20:53:12 +0000 (21:53 +0100)]
mescc: Proper support for i++,++i,i--,--i.

* module/language/c99/compiler.mes (ast->info): Bugfix: locals.
  Add i--, --i.  Properly support i++, ++i.
* module/mes/libc-i386.mes (i386:function-locals): Support 8 local vars.
* scaffold/t.c (test): Test it.

3 years agomescc: Beginning of expression and test template.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 10:23:00 +0000 (12:23 +0200)]
mescc: Beginning of expression and test template.

* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
  (make): Add <function> slot.
  (.function): New accessor.
  (clone): Handle it.
  (function->info): Set it.
  (ast->info): Make tests generic in if, for, while.  Add goto, label,
  !, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
  (text->list): Use it.
  (functions->text, function-prefix): New function.
  (function-offset): Use it.
  (label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
  (i386:byte-base-sub): Rename from sub-byte-base.
  (i386:byte-jump-z): Rename from i386:Xjump-byte-z.
  (i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
  (i386:byte-mem->base): Rename from i386:Xmem-byte->base.
  (i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
  i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
  i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
  i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
  i386:xor-zf): New functions.

3 years agomescc: Have micro-mes use strcmp to print help.
Jan Nieuwenhuizen [Thu, 5 Jan 2017 23:20:05 +0000 (00:20 +0100)]
mescc: Have micro-mes use strcmp to print help.

* doc/examples/micro-mes.c (main): Add --help.
* module/language/c99/compiler.mes (info?): New function.
  (expr->accu): Handle function call and sub.
  (ast->info): Handle if not, and, de-ref, eq, sub, return f ().
* module/mes/libc-i386.mes (i386:accu-zero?, i386:Xmem-byte->accu,
  i386:Xmem-byte->base, i386:jump-byte-nz, i386:jump-byte-z,
  i386:test-byte-base, i386:Xjump-byte-z, i386:sub-byte-base): New
  functions.
* module/mes/libc-i386.scm: Export them.

3 years agomescc: Compile specific for loop.
Jan Nieuwenhuizen [Thu, 5 Jan 2017 20:24:56 +0000 (21:24 +0100)]
mescc: Compile specific for loop.

* module/language/c99/compiler.mes (ast->info): Handle for, pre-inc.
* GNUmakefile (main): New target.
* doc/examples/main.c:
  (exit, write, strlen,puts)[__GNUC__]: New functions; import from micro-mes.c
  (_start): New function.

3 years agomescc: Refactor compiler.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 23:55:46 +0000 (00:55 +0100)]
mescc: Refactor compiler.

* module/language/c99/compiler.mes (make, clone): Lightweight functional
  GOOPS-like list-based info structure.
  (make-text+globals+locals): Remove.
  (ast->info): Rename from statement->text+globals+locals, refactor.
  Update callers.
  (function->info): Rename from function->globals, refactor.  Update
  callers.
  (ast-list->info): New function.

3 years agoscm: Fix psyntax/keyword/optargs interaction bug.
Jan Nieuwenhuizen [Sat, 7 Jan 2017 00:08:29 +0000 (01:08 +0100)]
scm: Fix psyntax/keyword/optargs interaction bug.

* module/mes/psyntax-0.mes (self-evaluating?): Add keyword?.
* module/mes/pmatch.mes (mes): Add missing psyntax dependency.
* module/mes/optargs.scm (rest-arg->keyword-binding-list): Make error
  messages non-constant.
* tests/optargs.test ("clone <info>"): New test.

3 years agomescc: Compile file supplied on command line.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 22:48:12 +0000 (23:48 +0100)]
mescc: Compile file supplied on command line.

* scripts/mecc.mes: Pass (command-line) to main.

3 years agonyacc: Add cpp to c99 mes module.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 21:12:12 +0000 (22:12 +0100)]
nyacc: Add cpp to c99 mes module.

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

3 years agomescc: Rename symbols to globals.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 17:34:49 +0000 (18:34 +0100)]
mescc: Rename symbols to globals.

* module/language/c99/compiler.mes:

3 years agomescc: Have micro-mes use if not to segfault.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 17:22:56 +0000 (18:22 +0100)]
mescc: Have micro-mes use if not to segfault.

* module/language/c99/compiler.mes (write-any): Check explicitly on
  number?, report error otherwise.
  (statement->text+symbols+locals): Remove statement-offset.
  Handle compounds.  Handle very specific if.
  (function->symbols): Remove unused text-offset.
* doc/examples/micro-mes.c (main): If argc > 1 print argv1.  Fixes
  segfault :-)
* module/mes/elf-util.mes (symbols->text): Loop rather than map,
  feed text-offset.
* module/mes/libc-i386.mes (i386:local-test, i386:jump-le): New
  functions.
* module/mes/libc-i386.scm: Export them.

3 years agomescc: Have micro-mes print argv.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 11:33:34 +0000 (12:33 +0100)]
mescc: Have micro-mes print argv.

* module/language/c99/compiler.mes (expr->arg): Bugfix argv: Use
  size=4 (int).
  (statement->text+symbols+locals): Bugfixes: array-ref, initialize with
  immediate, initialize with local.
  (formals->locals): Bugfix: formals counted down from -1 [WAS: down to
  -1].
* module/mes/libc-i386.mes (i386:call): Reverse args pushes to match
  formals index changes.
  (i386:write): Update for changed formals push order.
  (i386:mem->accu, i386:value->accu): New functions.
* module/mes/libc-i386.scm (mes): Export them.
* doc/examples/micro-mes.c (eputs, puts, fputs): Make identical with
  mescc's implementations.
  (main): Print argv[0] and (unconditionally; crash if not given) argv[1].

3 years agomescc: Have micro-mes print argc.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 11:52:59 +0000 (12:52 +0100)]
mescc: Have micro-mes print argc.

* module/language/c99/compiler.mes (accu->ident): New function.
  (statement->text+symbols+locals): Use it to implement initialization
  with immediate, local.
  (_start): Call main with argc,argv [WAS: 0,0].
* module/mes/libc-i386.mes (i386:push-accu, i386:accu->local): New
  functions.
* module/mes/libc-i386.scm: Export them.
* doc/examples/micro-mes.c (main): Return argc as exit status.

3 years agomescc: Support literal .byte in asm ().
Jan Nieuwenhuizen [Tue, 3 Jan 2017 11:45:47 +0000 (12:45 +0100)]
mescc: Support literal .byte in asm ().

* module/language/c99/compiler.mes (expr->arg): Handle array-ref (int
  only).
  (byte->hex, asm->hex): New functions.
  (statement->text+symbols+locals): Use it to implement asm ().

3 years agomescc: Remove data section from disassembly.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 11:43:00 +0000 (12:43 +0100)]
mescc: Remove data section from disassembly.

* module/mes/elf.mes (make-elf): Remove executable bit from data.

3 years agomescc: Formals, local variables.
Jan Nieuwenhuizen [Mon, 2 Jan 2017 22:21:33 +0000 (23:21 +0100)]
mescc: Formals, local variables.

* module/language/c99/compiler.mes (statement->text+symbols+locals):
  Rename from statement->text+symbols.  Handle locals.
  (formals->text): Add proper function preamble.
  (formals->locals): Add formals as locals.
  (expr->accu, ident->accu, ident->base, ident-ref, global-ref): New
  functions.
  (strlen, eputs, fputs, puts): New functions.
  (libc): New variable.
  (i386:libc): Rename from libc.  Remove eputs and puts.
* module/mes/libc-i386.mes (i386:eputs, i386:puts: Remove.
  (i386:call, i386:ret): Handle locals as argument.
  (i386:function-locals, i386:function-preamble, i386:jump,
  i386:local->accu, i386:local-add, i386:local-assign,
  i386:local->base, i386:ref-global, i386:ref-local, i386:ret-local,
  i386:mem-byte->accu, i386:test-jump, i386:write): New functions.
* module/mes/libc-i386.scm: Export them.

3 years agomescc: Nicer functions/parameters.
Jan Nieuwenhuizen [Mon, 2 Jan 2017 06:41:56 +0000 (07:41 +0100)]
mescc: Nicer functions/parameters.

* module/mes/libc-i386.mes (eputs, exit, puts): Save stack pointer,
  fill parameter registers from stack.
* module/language/c99/compiler.mes (formal->text): Fill parameter
  registers from stack memory.
  (formals->text): Save stack pointer.

3 years agomini-mes: Parse with Nyacc.
Jan Nieuwenhuizen [Mon, 2 Jan 2017 06:50:44 +0000 (07:50 +0100)]
mini-mes: Parse with Nyacc.

* doc/examples/mini-mes.c: Parse with Nyacc.

3 years agomescc: Scaffolding of Nyacc compile experiments.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 10:01:33 +0000 (12:01 +0200)]
mescc: Scaffolding of Nyacc compile experiments.

* scaffold/micro-mes.c: New file.
* scaffold/mini-mes.c: New file.
* GNUmakefile (mini-mes, micro-mes): New targets.
* .gitignore: Ignore them.

3 years agomescc: Nyacc updates, factor-out elf-util.
Jan Nieuwenhuizen [Sun, 2 Apr 2017 09:55:37 +0000 (11:55 +0200)]
mescc: Nyacc updates, factor-out elf-util.

* module/mes/bytevectors.mes
* module/mes/elf-util.mes: New file.
* module/mes/elf.mes: Use it.
  (make-elf): Generate symbol-table string-table.
* module/mes/elf-util.scm: New file.
* module/mes/elf.scm: Use it.
* module/language/c99/compiler.mes: Include it.
* module/language/c99/compiler.scm: Include it.
* module/mes/libc-i386.mes (call, eputs, exit, puts): New functions.
* module/mes/libc-i386.scm: Export them.

3 years agomescc: Use Nyacc frontend.
Jan Nieuwenhuizen [Sat, 31 Dec 2016 08:03:07 +0000 (09:03 +0100)]
mescc: Use Nyacc frontend.

* module/language/c99/compiler.mes: New file.
* module/language/c99/compiler.scm: Include it.
* module/mes/elf.mes: Move (mes-use-module) into cond-expand.
* module/mes/elf.scm: New file.
* module/mes/libc-i386.scm: New file.
* module/nyacc/lang/c99/parser.mes: Add missing module includes.
* module/nyacc/lang/util.mes: Add missing module include.
* scripts/mescc.mes: Use Nyacc.
* guile/mescc.scm: New file.
* GNUmakefile (guile-mescc): Run it.

3 years agoscm: Avoid xpath's shadowing of filter.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 21:18:22 +0000 (22:18 +0100)]
scm: Avoid xpath's shadowing of filter.

* module/sxml/xpath.scm (xpath:filter): Rename from filter.  Fixes
  shadowing of core filter.

3 years agonyacc: fixes didn't get in in 0.74.0
Matt Wette [Mon, 9 Jan 2017 00:59:20 +0000 (16:59 -0800)]
nyacc: fixes didn't get in in 0.74.0

3 years agonyacc: ugh. fixes did not take, why?
Matt Wette [Mon, 9 Jan 2017 00:56:24 +0000 (16:56 -0800)]
nyacc: ugh. fixes did not take, why?

3 years agonyacc: new release 0.74.0
Matt Wette [Sun, 8 Jan 2017 21:06:33 +0000 (13:06 -0800)]
nyacc: new release 0.74.0

3 years agonyacc: minor fixes
Matt Wette [Sun, 8 Jan 2017 21:00:57 +0000 (13:00 -0800)]
nyacc: minor fixes

3 years agonyacc: lots of C99/CPP fixes. now more robust for code mode
Matt Wette [Sun, 8 Jan 2017 20:16:28 +0000 (12:16 -0800)]
nyacc: lots of C99/CPP fixes. now more robust for code mode

3 years agonyacc: lots of fixes to make CPP more robust; now need to test
Matt Wette [Sun, 8 Jan 2017 00:06:09 +0000 (16:06 -0800)]
nyacc: lots of fixes to make CPP more robust; now need to test

3 years agonyacc: updates for cpp-ok/not-ok
Matt Wette [Fri, 6 Jan 2017 16:03:41 +0000 (08:03 -0800)]
nyacc: updates for cpp-ok/not-ok

3 years agonyacc: fixed c99/CPP bug: need to skip space before lparen
Matt Wette [Mon, 2 Jan 2017 15:42:23 +0000 (07:42 -0800)]
nyacc: fixed c99/CPP bug: need to skip space before lparen

3 years agonyacc: have something working for in-place include
Matt Wette [Mon, 2 Jan 2017 03:40:27 +0000 (19:40 -0800)]
nyacc: have something working for in-place include

3 years agonyacc: working on cpp-include fix
Matt Wette [Sun, 1 Jan 2017 15:54:21 +0000 (07:54 -0800)]
nyacc: working on cpp-include fix

3 years agonyacc: creating fixes for 0.73.0
Matt Wette [Sat, 31 Dec 2016 16:33:07 +0000 (08:33 -0800)]
nyacc: creating fixes for 0.73.0

3 years agonyacc: new release 0.73.0
Matt Wette [Mon, 26 Dec 2016 03:34:40 +0000 (19:34 -0800)]
nyacc: new release 0.73.0

3 years agonyacc: misc updates; see ChangeLog
Matt Wette [Mon, 26 Dec 2016 03:31:09 +0000 (19:31 -0800)]
nyacc: misc updates; see ChangeLog

3 years agonyacc: multiple fixes
Matt Wette [Sat, 3 Dec 2016 15:19:35 +0000 (07:19 -0800)]
nyacc: multiple fixes

3 years agonyacc: starting devel on 0.72.0
Matt Wette [Tue, 9 Aug 2016 12:45:52 +0000 (05:45 -0700)]
nyacc: starting devel on 0.72.0

3 years agonyacc: Move README.nyacc.
Jan Nieuwenhuizen [Mon, 26 Dec 2016 07:06:49 +0000 (08:06 +0100)]
nyacc: Move README.nyacc.

* module/nyacc/README.nyacc: Moved from README.nyacc.

3 years agonyacc: Add README.nyacc.
Jan Nieuwenhuizen [Mon, 26 Dec 2016 07:05:00 +0000 (08:05 +0100)]
nyacc: Add README.nyacc.

* README.nyacc: New file.

3 years agotests: Move (ice-9 syncase) into cond-expand.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 21:48:06 +0000 (22:48 +0100)]
tests: Move (ice-9 syncase) into cond-expand.

* tests/psyntax.mes: Move (ice-9 syncase) into cond-expand.  Fixes
  guile-2 deprecation messages.

3 years agonyacc: Move (ice-9 syncase) into cond-expand.
Jan Nieuwenhuizen [Sun, 26 Mar 2017 20:27:20 +0000 (22:27 +0200)]
nyacc: Move (ice-9 syncase) into cond-expand.

* module/nyacc/lalr.scm: Move (ice-9 syncase) into cond-expand.  Fixes
  guile-2 deprecation messages.
* module/nyacc/lang/c99/cpp.scm: Likewise.
* module/nyacc/lang/c99/parser.scm: Likewise.
* module/nyacc/lex.scm: Likewise.

3 years agocore: Move GNUisms inside #if.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 07:16:14 +0000 (08:16 +0100)]
core: Move GNUisms inside #if.

* mes.c: Move GNUisms inside #if, add Nyacc #ifs.
 (tmp_num2, tmp_num3): Remove.
 (make_tmps): Update.
 (g_free): Make simple int.  Update users.
* lib.c: Update users.
* build-aux/mes-snarf.scm (GCC?): New switch to enable GNU extensions.

3 years agorepl: Fix expand in repl.
Jan Nieuwenhuizen [Sun, 22 Jan 2017 00:35:33 +0000 (01:35 +0100)]
repl: Fix expand in repl.

* module/mes/repl.mes (repl): Fix expand.  Remove sc-expand.

3 years agoscm: Error throws rather than hard exit.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 23:11:47 +0000 (00:11 +0100)]
scm: Error throws rather than hard exit.

* module/mes/read-0.mes (read-character, read-string): Call error.
* module/mes/scm.mes (error): Call core:error instead of exit.
  (syntax-error): Likewise.
* module/mes/repl.mes (repl): Move read into catch.

3 years agorepl: Use exception handling.
Jan Nieuwenhuizen [Wed, 28 Dec 2016 19:49:19 +0000 (20:49 +0100)]
repl: Use exception handling.

* module/mes/repl.mes (repl): Use catch to prevent exit upon error.

3 years agocore: Throw exceptions rather than asserts.
Jan Nieuwenhuizen [Wed, 28 Dec 2016 21:26:33 +0000 (22:26 +0100)]
core: Throw exceptions rather than asserts.

* lib.c (error): Throw instead of assert.
  (check_formals, check_apply): Update.
* mes.c (scm_symbol_unbound_variable, scm_symbol_not_a_pair,
  scm_symbol_system_error, scm_symbol_wrong_number_of_args,
  scm_symbol_wrong_type_arg, scm_symbol_unbound_variable): New symbols.
  (car, cdr, set_cdr_x, set_env_x, eval_apply, gc_up_arena): Update.

3 years agocore+scm: Implement exception handling.
Jan Nieuwenhuizen [Wed, 28 Dec 2016 21:26:07 +0000 (22:26 +0100)]
core+scm: Implement exception handling.

* mes.c (scm_symbol_throw): New symbol.
* module/mes/catch.scm (catch, throw): Implement [WAS: syntactic sugar].
  (make-exception, exception?, exception-key, exception-args): Remove.
* tests/catch.test ("catch", "catch 22"): Add tests.
* module/mes/base-0.scm: Include it.

3 years agoRevert "core: Display me debuggor CPS+CC."
Jan Nieuwenhuizen [Wed, 28 Dec 2016 15:37:06 +0000 (16:37 +0100)]
Revert "core: Display me debuggor CPS+CC."

This reverts commit 6c327b5bdceae6fc59ac8cce4aed99ea0a491846.

3 years agocore: Display me debuggor CPS+CC.
Jan Nieuwenhuizen [Wed, 28 Dec 2016 15:35:12 +0000 (16:35 +0100)]
core: Display me debuggor CPS+CC.

Having display in the core is handy for debugging.
This is a courtesy commit intended to prevent bitrot.

* GNUmakefile (mes.o): Depend on display.
* mes.c: Include display.
* display.c: New file.

3 years agocore: Add continuations, call/cc.
Jan Nieuwenhuizen [Wed, 28 Dec 2016 21:04:57 +0000 (22:04 +0100)]
core: Add continuations, call/cc.

* mes.c (type_t): Add CONTINUATION.
  (scm_t): Add continuation;
  (scm_call_with_current_continuation): New symbol.
  (scm_symbol_call_with_current_continuation): New special.
  (g_continuations): New global
  (CONTINUATION): New field accessor.
  (MAKE_CONTINUATION): New make_cell helper.
  (car_): Update.
  (eval_apply): Implement call/cc.
* module/mes/display.mes (display): Handle continuations.
* module/mes/type-0.mes (<cell:continuation>): New type.
  (cell-type-alist): Add it.
  (continuation?): New function.
* tests/base.test ("call/cc"): New test.

3 years agocore: Rewrite eval_apply in continuation passing style.
Jan Nieuwenhuizen [Wed, 28 Dec 2016 20:55:42 +0000 (21:55 +0100)]
core: Rewrite eval_apply in continuation passing style.

* mes.c (scm_vm_evlis, scm_vm_evlis2, scm_vm_evlis3, scm_vm_apply,
  scm_vm_apply2, scm_vm_eval, scm_vm_eval_set_x, scm_vm_eval_macro,
  scm_vm_eval2, scm_vm_macro_expand, scm_vm_begin,
  scm_vm_begin_read_input_file, scm_vm_begin2, scm_vm_if,
  scm_vm_if_expr, scm_vm_call_with_values, scm_vm_call_with_values2,
  scm_vm_return): New specials.
  (scm_vm_eval_car, scm_vm_eval_cdr, scm_vm_eval_cons,
  scm_vm_eval_null_p)[PRIMITIVE-EVAL]: New specials.
  (eval_apply_t, g_target): Remove.
  (push_cc): New function.
  (eval_apply): Rewrite.
  (vm_call, eval_env, apply_env, eval_env, macro_expand_env, begin_env,
  call_with_values_env): Remove.
* posix.c (stderr_): Update.
* reader.c (read_input_file_env): Update.
* module/mes/base-0.mes: Update.

3 years agoSupport radix for string->number, number->string.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 20:11:52 +0000 (21:11 +0100)]
Support radix for string->number, number->string.

* module/mes/scm.mes (string->number, number->string): Support radix.

3 years agoAdd string-take, string-drop.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 19:56:47 +0000 (20:56 +0100)]
Add string-take, string-drop.

* module/srfi/srfi-13.mes (string-take, string-drop): New functions.

3 years agocore: Stderr_ also print numbers.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 19:22:31 +0000 (20:22 +0100)]
core: Stderr_ also print numbers.

* posix.c (stderr_): Handle numbers.

3 years agoBugfixes bytevectors.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 19:20:15 +0000 (20:20 +0100)]
Bugfixes bytevectors.

* math.c (modulo): Modulo of negative value correctly.
* module/mes/bytevectors.mes (bytevector-u32-native-set!):
  (bytevector-u16-native-set!): Use ash instead of quotient.

3 years agoAppend-map: handle multiple list.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 10:20:29 +0000 (11:20 +0100)]
Append-map: handle multiple list.

* module/srfi/srfi-1.mes (append-map): Add optional rest argument.

3 years agocore: Move GNUisms inside #if.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 07:16:14 +0000 (08:16 +0100)]
core: Move GNUisms inside #if.

* mes.c: Move GNUisms inside #if, add Nyacc #ifs.
 (tmp_num2, tmp_num3): Remove.
 (make_tmps): Update.
 (g_free): Make simple int.  Update users.
* lib.c: Update users.
* build-aux/mes-snarf.scm (GCC?): New switch to enable GNU extensions.

3 years agoAdd drain-input.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 22:46:44 +0000 (23:46 +0100)]
Add drain-input.

* module/mes/guile.mes (drain-input): New function.

3 years agoBugfix for reading #\*eof* character.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 22:46:03 +0000 (23:46 +0100)]
Bugfix for reading #\*eof* character.

* module/mes/read-0.mes (read-character): Bugfix for #\*eof*.

3 years agocore: Expose command line.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 22:41:11 +0000 (23:41 +0100)]
core: Expose command line.

* mes.c (scm_symbol_argv): New symbol
  (main): Use it to add argv to environment.
* module/mes/base.mes (command-line): New function.

3 years agoInclude srfi-13 in base.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 21:20:14 +0000 (22:20 +0100)]
Include srfi-13 in base.

* module/mes/base-0.mes: Include srfi-13.

3 years agoAdd filter-map.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 21:11:34 +0000 (22:11 +0100)]
Add filter-map.

* module/srfi/srfi-1.mes (filter-map): New function.