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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
Jan Nieuwenhuizen [Tue, 3 Jan 2017 17:34:49 +0000 (18:34 +0100)]
mescc: Rename symbols to globals.
* module/language/c99/compiler.mes:
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.
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].
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.
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 ().
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.
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.
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.
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.
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.
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.
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.
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.
Matt Wette [Mon, 9 Jan 2017 00:59:20 +0000 (16:59 -0800)]
nyacc: fixes didn't get in in 0.74.0
Matt Wette [Mon, 9 Jan 2017 00:56:24 +0000 (16:56 -0800)]
nyacc: ugh. fixes did not take, why?
Matt Wette [Sun, 8 Jan 2017 21:06:33 +0000 (13:06 -0800)]
nyacc: new release 0.74.0
Matt Wette [Sun, 8 Jan 2017 21:00:57 +0000 (13:00 -0800)]
nyacc: minor fixes
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
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
Matt Wette [Fri, 6 Jan 2017 16:03:41 +0000 (08:03 -0800)]
nyacc: updates for cpp-ok/not-ok
Matt Wette [Mon, 2 Jan 2017 15:42:23 +0000 (07:42 -0800)]
nyacc: fixed c99/CPP bug: need to skip space before lparen
Matt Wette [Mon, 2 Jan 2017 03:40:27 +0000 (19:40 -0800)]
nyacc: have something working for in-place include
Matt Wette [Sun, 1 Jan 2017 15:54:21 +0000 (07:54 -0800)]
nyacc: working on cpp-include fix
Matt Wette [Sat, 31 Dec 2016 16:33:07 +0000 (08:33 -0800)]
nyacc: creating fixes for 0.73.0
Matt Wette [Mon, 26 Dec 2016 03:34:40 +0000 (19:34 -0800)]
nyacc: new release 0.73.0
Matt Wette [Mon, 26 Dec 2016 03:31:09 +0000 (19:31 -0800)]
nyacc: misc updates; see ChangeLog
Matt Wette [Sat, 3 Dec 2016 15:19:35 +0000 (07:19 -0800)]
nyacc: multiple fixes
Matt Wette [Tue, 9 Aug 2016 12:45:52 +0000 (05:45 -0700)]
nyacc: starting devel on 0.72.0
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.
Jan Nieuwenhuizen [Mon, 26 Dec 2016 07:05:00 +0000 (08:05 +0100)]
nyacc: Add README.nyacc.
* README.nyacc: New file.
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.
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.
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.
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.
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.
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.
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.
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.
Jan Nieuwenhuizen [Wed, 28 Dec 2016 15:37:06 +0000 (16:37 +0100)]
Revert "core: Display me debuggor CPS+CC."
This reverts commit
6c327b5bdceae6fc59ac8cce4aed99ea0a491846.
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.
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.
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.
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.
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.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 19:22:31 +0000 (20:22 +0100)]
core: Stderr_ also print numbers.
* posix.c (stderr_): Handle numbers.
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.
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.
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.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 22:46:44 +0000 (23:46 +0100)]
Add drain-input.
* module/mes/guile.mes (drain-input): New function.
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*.
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.
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.
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.
Jan Nieuwenhuizen [Mon, 2 Jan 2017 17:18:06 +0000 (18:18 +0100)]
Add srfi-1:iota.
* module/srfi/srfi-1.mes (iota,srf-1:iota): New function.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 23:18:22 +0000 (00:18 +0100)]
Add pretty-print from Guile.
* module/mes/pretty-print.scm: Import.
* module/mes/pretty-print.mes: Include it.
* AUTHORS: Mention it.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 23:17:21 +0000 (00:17 +0100)]
Add make-string, object->string.
* module/mes/guile.mes (make-string, object->string): New functions.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 23:16:37 +0000 (00:16 +0100)]
Add list-set!, string-set!
* module/mes/scm.mes (list-set!, string-set!): New functions.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 23:14:28 +0000 (00:14 +0100)]
Fix core:car, core:cdr for specials.
* mes.c (car_, cdr_): Return special. Fixes string->list, returning nil.
* tests/scm.test ("string-length", "string->list"): New tests.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 08:07:11 +0000 (09:07 +0100)]
core: Add continuation on stack.
* mes.c (r3): New stack variable.
(mes_g_stack): Initialize it.
(gc_push_frame): Add it.
(gc_peek_frame): Set it.
Jan Nieuwenhuizen [Mon, 26 Dec 2016 08:04:40 +0000 (09:04 +0100)]
core: Uniformize calling of apply.
* mes.c (eval_apply): Have apply take one argument, like all other vm
functions: r1; cons of function f and argument list x. Sorry John.
(r2): Repurpose as save/load register. Update users.
(r3): Remove.
(vm_call): Remove p2. Update callers.
Jan Nieuwenhuizen [Mon, 26 Dec 2016 08:00:43 +0000 (09:00 +0100)]
core: Refactor stack handling.
* mes.c (gc_pop_frame, gc_push_frame): New Functions.
(gc_frame, gc_stack): Remove.
(vm_call): Update callers.
* lib.c (dump, bload_env): Update callers.
Jan Nieuwenhuizen [Wed, 28 Dec 2016 07:55:34 +0000 (08:55 +0100)]
Add simple-format.
* module/mes/display.mes (simple-format, format): New functions.
Jan Nieuwenhuizen [Mon, 26 Dec 2016 09:00:17 +0000 (10:00 +0100)]
Display: If possible, show name of closure.
* module/mes/display.mes (display): Lookup closure's name and display it.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 15:43:28 +0000 (16:43 +0100)]
Update documentation.
* doc/ANNOUNCE-0.4: New file.
* NEWS: Typo.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 15:30:53 +0000 (16:30 +0100)]
guix hash: 1jpm8m8y2dqsl3sc6flf8da4rpdrqh6zgr2mghzjw0lg34v1r21j
Jan Nieuwenhuizen [Sun, 25 Dec 2016 14:51:53 +0000 (15:51 +0100)]
Release 0.4.
* configure (VERSION): Bump.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 14:38:26 +0000 (15:38 +0100)]
Remove hardcoded duplication of version.
* GNUmakefile (CPPFLAGS): Include VERSION.
* mes.c (main): Use it. Add --dump and --load to --help.
(scm_symbol_mes_prefix, scm_symbol_mes_version): New sybols.
(mes_symbols): Use them to set prefix and version.
* module/mes/base-0.mes (effective-version): Use %version.
* module/mes/repl.mes (welcome): Likewise.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 16:22:34 +0000 (17:22 +0100)]
Update documentation.
* HACKING: Update status, some ideas where to go next.
* NEWS: Update status.
* README: Update.
* doc/ANNOUNCE: Move from top.
* doc/ANNOUNCE-2: Likewise.
* doc/ANNOUNCE-0.3: New file.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 23:49:00 +0000 (00:49 +0100)]
make: Install nyacc scripts too.
* make/install.make (install): Add scripts/nyacc.mes, scripts/nyacc-calc.mes.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 10:54:14 +0000 (11:54 +0100)]
Revert "core: Display me debuggor."
This reverts commit
53ec23a0edcfdcb7dd4e32277e5a24e0a8fab5dd.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 10:53:55 +0000 (11:53 +0100)]
core: Display me debuggor.
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.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 08:57:19 +0000 (09:57 +0100)]
Revert "core: FAT_C_READER: Show your speed."
This reverts commit
5a9b9ac36bd33e497272b287ab1f0db715e01d38.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 07:41:27 +0000 (08:41 +0100)]
core: FAT_C_READER: Show your speed.
scripts/nyacc.mes runs in 4s rather than 18s with fat C reader.
This is a courtesy commit intended to prevent bitrot.
* mes.c (quasiquote, unquote, unquote_splicing, syntax, quasisyntax,
unsyntax, unsyntax_splicing): Add symbols.
* reader.c (char_eof, char_nul, char_alarm, char_backspace, char_tab,
char_newline, char_vtab, char_page, char_return,
char_space)[FAT_C_READER]: New global variables.
(make_keyword, read_block_comment, read_character, read_hex,
append_char, read_string, fat_c_lookup_, fat_c_eat_whitespace,
fat_c_read_word): New functions.
(eat_whitespace_, read_word_, lookup_)[FAT_C_READER]: Add hook.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 21:16:53 +0000 (22:16 +0100)]
Refactor reader.
* module/mes/read-0.mes (read-hash): New function.
(read-word): Use it.
(eat-whitespace): Rewrite.
(display): Minimal implementation through core.
* lib.c (stderr_): Support printing of strings while booting.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 13:21:36 +0000 (14:21 +0100)]
core: Remove c3+r abbreviatons.
* lib.c (caaar, caadr, caddr, cdadr, cadar, cddar, cdddr, cadddr):
Remove.
* mes.c: Rewrite callers
* module/mes/read-0.mes: Rewrite callers.
* module/mes/base.mes (caaar, caadr, caddr, cdadr, cadar, cddar, cdddr,
cadddr): New function.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 13:05:33 +0000 (14:05 +0100)]
core: Move dump, load, bload to lib.c.
* lib.c (dump, load, bload): Move from mes.c
* mes.c (dump, load, bload): Remove.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 13:09:48 +0000 (14:09 +0100)]
core: Add getenv, verbose module loading on MES_DEBUG.
* mes.c (MAKE_REF, MAKE_STRING): Oops, remove stray semicolon.
* posix.c (getenv_): New function.
* module/mes/base-0.mes (load): Use it to switch on MES_DEBUG=1.
(mes-use-module): Remove commented-out code.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 11:10:05 +0000 (12:10 +0100)]
core: Add some error checking.
* lib.c (length): Return -1 for non-proper lists.
(error): New function.
(assert_defined): Use it.
(check_formals, check_apply): New functions.
* mes.c (car, cdr, set_cdr_x, set_env_x, eval_apply): Add error check.
* srfi/srfi-1.mes (member): New function.
* tests/srfi-1.tests ("member"): New test.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 10:28:25 +0000 (11:28 +0100)]
core: Move reader and posix functions from mes.c
* mes.c (getchar, ungetchar, peekchar, peek_byte, read_byte,
unread_byte, write_byte, read_input_file_env_, read_input_file_env):
Remove.
* posix.c (getchar, ungetchar, peekchar, peek_byte, read_byte,
unread_byte, write_byte): Move from mes.c.
* reader (read_input_file_env_, read_input_file_env): Move from mes.c.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 10:21:30 +0000 (11:21 +0100)]
core: Remove unused symbols.
* mes.c (scm_symbol_noexpand, scm_symbol_syntax,
scm_symbol_quasisyntax, scm_symbol_unsyntax,
scm_symbol_unsyntax_splicing, scm_symbol_quasiquote,
scm_symbol_unquote, scm_symbol_unquote_splicing, scm_symbol_define,
scm_symbol_define_macro): Remove.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 10:10:11 +0000 (11:10 +0100)]
Add write, add display test, some fixes.
* mes.c (write_byte): Rename from write_char.
* module/mes/display.mes (display): Fixes for write: char, closure, procedure.
(write-char, write, with-output-to-string): New functions.
* tests/read.test: Include base-0 to see some output.
* tests/display.test: New file.
* GNUmakefile (TESTS): Add it.