Jan Nieuwenhuizen
e460771988
test: Allow running with any mes.
...
* test/base.test: Run $MES if set, default to ../scripts/mes.
* tests/base.test: Likewise.
* tests/catch.test: Likewise.
* tests/closure.test: Likewise.
* tests/cwv.test: Likewise.
* tests/display.test: Likewise.
* tests/fluids.test: Likewise.
* tests/gc-0.test: Likewise.
* tests/gc-1.test: Likewise.
* tests/gc-2.test: Likewise.
* tests/gc-2a.test: Likewise.
* tests/gc-3.test: Likewise.
* tests/gc-4.test: Likewise.
* tests/gc-5.test: Likewise.
* tests/gc-6.test: Likewise.
* tests/gc.test: Likewise.
* tests/let-syntax.test: Likewise.
* tests/let.test: Likewise.
* tests/match.test: Likewise.
* tests/math.test: Likewise.
* tests/module.test: Likewise.
* tests/optargs.test: Likewise.
* tests/peg.test: Likewise.
* tests/psyntax.test: Likewise.
* tests/quasiquote.test: Likewise.
* tests/read.test: Likewise.
* tests/record.test: Likewise.
* tests/scm.test: Likewise.
* tests/srfi-1.test: Likewise.
* tests/srfi-13.test: Likewise.
* tests/srfi-14.test: Likewise.
* tests/vector.test: Likewise.
2017-03-26 21:06:19 +02:00
Jan Nieuwenhuizen
9896f9eb92
scm+test: Factor-out math and vector.
...
* module/mes/base-0.mes (quotient): Remove.
* module/mes/scm.mes (quotient): Add.
* tests/scm.test: Remove arithmetic/math tests.
* tests/math.test: New file.
* GNUmakefile (TESTS): Add it
2017-04-02 11:34:40 +02:00
Jan Nieuwenhuizen
c83ef66265
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.
2017-04-02 12:23:00 +02:00
Jan Nieuwenhuizen
21a6f2ca52
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.
2017-01-07 01:08:29 +01:00
Jan Nieuwenhuizen
15518f92af
tests: Move (ice-9 syncase) into cond-expand.
...
* tests/psyntax.mes: Move (ice-9 syncase) into cond-expand. Fixes
guile-2 deprecation messages.
2016-12-25 22:48:06 +01:00
Jan Nieuwenhuizen
2675f711a3
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.
2016-12-28 22:26:07 +01:00
Jan Nieuwenhuizen
d0f7db73f9
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.
2016-12-28 22:04:57 +01:00
Jan Nieuwenhuizen
3dd219b891
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.
2017-01-04 09:12:16 +01:00
Jan Nieuwenhuizen
e8d8d5c3be
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.
2016-12-24 12:10:05 +01:00
Jan Nieuwenhuizen
d81ce91ff7
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.
2016-12-24 11:10:11 +01:00
Jan Nieuwenhuizen
ddfaa05149
core: Remove most of reader.
...
* reader.c (append_char, read_block_comment, read_character, read_hex,
read_string): Remove.
(eat_whitespace, read_word)[READER]: Remove.
* mes.c (list_to_symbol): New function.
* module/mes/read-0.mes (list->symbol, read-character, read-hex,
read-string): New functions.
2016-12-22 23:42:28 +01:00
Jan Nieuwenhuizen
a0caca6409
Refactor reader.
...
* module/mes/read-0.mes (eat-whitespace): More efficient ordering/peeking.
* module/mes/read-0.mes (read-word): Handle tab.
2016-12-25 12:37:35 +01:00
Jan Nieuwenhuizen
33ac19d7df
Support PEG from Guile.
...
* module/mes/peg.mes: New file.
* module/mes/peg/cache.scm: New file.
* module/mes/peg/codegen.scm: New file.
* module/mes/peg/simplify-tree.scm: New file.
* module/mes/peg/string-peg.scm: New file.
* module/mes/peg/using-parsers.scm: New file.
* tests/peg.test: New file.
* GNUmakefile (TESTS): Add it.
2016-12-22 20:16:44 +01:00
Jan Nieuwenhuizen
51cd4885fc
Add string-copy, string=, string=?, char<?, char>?, char<=?, char>=?.
...
* module/srfi/srfi-13.mes: New file.
* module/mes/scm.mes (char<?, char>?, char<=?, char>=?): New function.
* module/srfi/srfi-13.mes: New file.
* tests/srfi-13.test: New file.
* string.c (string_to_symbol): Handle "".
2016-12-11 21:26:27 +01:00
Jan Nieuwenhuizen
527fd253eb
core: Disable quasiquote.
...
* mes.c (QUASIQUOTE): Switch off.
* tests/read.test: Remove quasiquote tests.
2016-12-22 15:36:29 +01:00
Jan Nieuwenhuizen
ea7c0aac86
Refactor quasiquote.
...
* module/mes/quasiquote.mes (quasiquote): Refactor.
* tests/quasiquote.test: Add tests.
2016-12-22 12:11:55 +01:00
Jan Nieuwenhuizen
6854627391
core: Bugfix append with one argument.
...
* mes.c (append): Handle one argument.
* tests/base.test ("append", "append 0" ... "append 5"): New tests.
2016-12-22 14:22:40 +01:00
Jan Nieuwenhuizen
f8bc344dfc
Import psyntax from Guile-1.8: R7RS with-ellipsis.
...
* GNUmakefile (psyntax-import): New target.
* module/mes/psyntax.ss: Import.
* module/mes/psyntax-pp.mes: Import.
* NEWS: Mention it.
2016-12-19 19:41:43 +01:00
Jan Nieuwenhuizen
e97d99c03a
Add ash.
...
* math.c (ash): New function.
* tests/scm.test (ash, ash -1): New tests.
2016-12-20 20:10:43 +01:00
Jan Nieuwenhuizen
8e1b25368b
Add iota.
...
* module/mes/scm.mes: (iota): New function.
* tests/scm.test (iota, iota 0, iota -1): New tests.
2016-12-20 19:25:26 +01:00
Jan Nieuwenhuizen
f8bb463da6
Partial srfi-14 support for Nyacc.
...
* module/srfi/srfi-14.mes: New file.
* tests/srfi-14.test: New file.
* GNUmakefile (TESTS): Add it.
2016-12-20 12:26:20 +01:00
Jan Nieuwenhuizen
376435e974
Add missing srfi-1 functions for Nyacc.
...
* module/srfi/srfi-1.scm (fold, fold-right, remove, append-reverse,
remove!): New functions.
* tests/srfi-1.test: New file.
* GNUmakefile (TESTS): Add it.
* module/srfi/srfi-1.upstream.mes: Import bits from Guile-1.8.
* AUTHORS: Mention it.
2016-12-20 10:44:43 +01:00
Jan Nieuwenhuizen
2390d46a63
Closure is not a pair.
...
* module/mes/base.mes (closure_p, mes_car, mes_cdr): New function.
(pair_p): Closure is not a pair.
* NEWS: Mention it.
* psyntax-0.mes (self-evaluating?): Add closure?.
2016-12-19 19:35:38 +01:00
Jan Nieuwenhuizen
6b4bf34ff2
Support backslash in string.
...
* reader.c (read_string): Handle '\\'.
* tests/read.test: Add it.
2016-12-18 15:39:12 +01:00
Jan Nieuwenhuizen
95d913097d
Support non-nested #| |# comment.
...
* module/mes/read-0.mes (read-word, read-block-comment): Implement #|.
* reader.c (read_word, read_block_comment)[READER]: Likewise.
* tests/read.test: Test it.
* NEWS: Mention it.
2016-12-18 10:11:22 +01:00
Jan Nieuwenhuizen
9dcff14bba
Support #; comment.
...
* module/mes/read-0.mes (read-word): Implement #;.
* reader.c (read_word)[READER]: Likewise.
* tests/read.test: Test it.
* NEWS: Mention it.
2016-12-18 10:02:49 +01:00
Jan Nieuwenhuizen
a8b16ba013
Minimal syntactic exception support.
...
* module/mes/catch.mes: New file.
* tests/catch.test: New file.
* GNUmakefile (TEST): Add it.
2016-12-17 22:21:46 +01:00
Jan Nieuwenhuizen
4744b315c9
Minimal syntactic fluids support.
...
* module/mes/fluids.mes: New file.
* tests/fluids.test: New file.
* GNUmakefile (TESTS): Add it.
2016-12-17 14:51:45 +01:00
Jan Nieuwenhuizen
f3c464d07b
Make guile switchable in GNUmakefile.
...
* GNUmakefile (GUILE): New variable. Update users.
* guile/mes-0.scm (mes?, guile-1.8?, guile-2?): New variables.
* module/mes/base.mes (guile?): Remove.
* module/mes/base-0.mes (effective-version, mes?, guile?, guile-1.8?,
guile-2?): New variables.
* tests/cwv.test: Support Guile 1.8.
2016-12-21 17:08:36 +01:00
Jan Nieuwenhuizen
a36896662e
optargs guile
2016-12-25 11:13:51 +01:00
Jan Nieuwenhuizen
8531e9d898
Support Guile optargs.
...
* module/mes/optargs.upstream.mes: Import latest non-syntax-case
version from Guile.
* AUTHORS: Add it.
* module/mes/optargs.scm: New file.
* tests/optargs.test: New file.
* GNUmakefile (TESTS): Add it.
* NEWS: Update.
2016-12-16 23:34:08 +01:00
Jan Nieuwenhuizen
bbeb4708e5
Support => in cond.
...
* module/mes/base-0.mes (cond): Support =>.
* module/mes/rea-0.mes (cond): Update.
* NEWS: Update.
2016-12-16 20:18:38 +01:00
Jan Nieuwenhuizen
2b577eaee0
Add loadable modules.
...
* module/mes/base-0.mes (mes-use-module): Implement.
* module/mes: Update users.
* HACKING: Update.
* NEWS: Update.
* configure (main): Use shell expansion for prefix.
* make/install.make (install): Substitute prefix.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
b74d048b95
Use syntax rather than psyntax.
...
* module/language/c/parser.mes: Switch to syntax.
* module/language/paren.mes: Likewise
* scripts/mescc.mes: Likewise
* scripts/paren.mes: Likewise
* scripts/repl.mes: Likewise
* tests/let-syntax.test: Likewise
* tests/match.test: Likewise
* tests/record.test: Likewise
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
f26c7222b2
core: Split-off cache, display, reader.
...
* mes.c: Remove cache, display, reader functions.
* cache.c: New file.
* display.c: New file.
* reader.c: New file.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
1614d13439
Add reader in Scheme.
...
* module/mes/read-0.mes: New file.
* mes.c (char_to_integer, integer_to_char, null_p): Move to core.
(peek_byte, read_byte, unread_byte): New function.
(main): --dump, --load: New option.
* lib.c (char_to_integer, integer_to_char): Remove.
* NEWS: Update.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
e6a0257a79
core: Cleanup cells.
...
* mes.c: Use accessors rather than g_cell[] access throughout.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
61e42e8527
core: Number based cells.
...
* mes.c (scm_t): Change car, string, ref, cdr, macro, vector into g_cell index
[WAS]: scm_t pointer.
* define.c: Update.
* lib.c: Update.
* math.c: Update.
* posix.c: Update.
* quasiquote.c: Update.
* string.c: Update.
* type.c: Update.
* build-aux/mes-snarf.mes Update.
* tests/gc-4.test: New test.
* tests/gc-5.test: New test.
* tests/gc-6.test: New test.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen
25c29ecb6d
core: Integrate garbage collector/jam scraper.
...
* mes.c (r0, r1, r2, r3, stack): New globals.
(gc_loop): Handle MACRO and SCM.
(gc_copy): Handle FUNCTION, allow for pre-allocated SCM and SYMBOL.
(assq): Flag any BROKEN_HEARTs.
(vm_call): New function. Enables moving C stack to GC stack.
(evlis_env, apply_env, eval_env, expand_macro_env, begin_env,
if_env): Use vm_call-indirection.
(call_lambda): New function.
(vm_apply_env): Rename from apply_env. Remove parameters, instead
use r1, r2 and r0.
(vm_evlis_env, vm_eval_env, vm_expand_macro_env, vm_begin_env,
vm_if_env): Likewise.
(acons): New function.
(mes_environment) [!MES_FULL, MES_MINI]: Add cpp switches to create minimally
filled environment, for debugging.
(main): Print free value at exit.
* define.c (define_env): Use vm_call-indirection.
(vm_define_env): Rename from define_env.
* quasiquote.c (eval_quasiquote): Use vm_call-indirection.
(vm_eval_quasiquote): Rename from eval_quasiquote.
* tests/gc-2.test: New test.
tests/gc-2a.test: New test.
tests/gc-3.test: New test.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen
c035a59094
Add sicp garbage example: tests/gc-1.test.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen
99cedbfbde
core: Add garbage collector/jam collector experiment.
...
* mes.c (gc, gc_loop, gc_copy, gc_move, gc_relocate_car,
gc_relocate_cdr, gc_flip): New function.
* tests/gc-0.test: New file.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen
2866c75907
Add mes gc test setup.
...
* tests/gc.test: New file.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen
adbf1bb296
test: Add psyntax closure tests.
...
* tests/closure.test (closure 7, closure 8, closure 9): New test.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
c121fe3d72
test: Add toplevel begin define test.
...
* tests/base.test (top begin define): New test.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
97300ef6ae
Implement load.
...
* mes.c (symbol_primitive_load): New symbol.
(builtin_eval): Use it to implement primitive-load.
* module/mes/base-0.mes (push!, pop!): New macro.
(load): New macro.
* tests/data/load.scm: New file.
* tests/base.test (load): New test.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
2b373ff40f
Finalize psyntax integration.
...
* mes.c (sc_expand_env): Exclude primitives, expand native macros.
(symbol_expand_macro): New symbol.
* module/mes/psyntax-0.mes (properties-alist): New function.
* module/mes/psyntax-1.mes: Set expand-macro.
(define-syntax, syntax-rules, let-syntax): Remove macro.
* module/language/c/parser.mes: Use psyntax modules, remove syntax module.
* module/language/paren.mes: Likewise.
* scripts/repl.mes: Likewise.
* tests/match.test: Likewise.
* tests/record.test: Likewise.
* tests/psyntax.test (define-syntax swap!): Add test.
* module/mes/let-syntax.mes: Remove.
* module/mes/syntax.mes: Remove.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
c851935d4d
core: Quoted internals are symbols.
...
* mes.c (begin_env): Rename from begin. Update callers.
(scm_begin, scm_if, scm_define, scm_set_x): Rename from symbol_*.
(symbol_begin, symbol_define, symbol_if, scm_lambda, scm_set_x): New symbols.
(mes_environment): Add them to environment, SYMBOL->SCM.
* define.c (define_env): Rename from define. Update callers.
* build-aux/mes-snarf.scm: Shadow internals (SCM) by their symbol.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
8a13b472e3
test: More values, call-with-values tests.
...
* tests/cwv.test: New file.
* GNUmakefile (TESTS): Add it.
* tests/scm.test: Remove value and call-with-values tests.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
019ca90109
psyntax: More tests.
...
* tests/psyntax.test: Add tests.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
32214ff608
Add syntax-case based syntax-rules.
...
* module/mes/psyntax-1.mes (syntax-rules): New syntax transformer,
based on syntax-case.
(define-syntax-rule): New macro.
(let-syntax): New macro, for syntax-case.
* tests/let-syntax.test: Switch to syntax-case.
* tests/psyntax.test: Add syntax-rules and syntax-rule test.
2016-12-12 20:33:49 +01:00