Jan Nieuwenhuizen [Wed, 7 Dec 2016 22:27:44 +0000 (23:27 +0100)]
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
Jan Nieuwenhuizen [Wed, 7 Dec 2016 22:51:07 +0000 (23:51 +0100)]
Resurrect syntax.mes.
* module/mes/syntax.mes: New file.
* AUTHORS: List it.
Jan Nieuwenhuizen [Mon, 21 Nov 2016 20:43:06 +0000 (21:43 +0100)]
core: use FIXED_PRIMITIVES rather than environment cache.
* cache.c: Remove.
* define.c: Remove callers.
* mes.c: Likewise.
(vm_eval_env) [FIXED_PRIMITIVES]: Hardcode car, cdr, cons, null_p.
* GNUmakefile: Update.
Jan Nieuwenhuizen [Sun, 11 Dec 2016 17:41:08 +0000 (18:41 +0100)]
core: Set max arena size.
* mes.c (MAX_ARENA_SIZE): New global.
(gc): Use it.
Jan Nieuwenhuizen [Sun, 11 Dec 2016 07:50:51 +0000 (08:50 +0100)]
core: Make arena size configurable.
* mes.c (main): Read MES_ARENA.
* scripts/repl.mes: Set MES_ARENA to
5000000 if not already set.
Fixes repl startup.
Jan Nieuwenhuizen [Sun, 11 Dec 2016 07:23:15 +0000 (08:23 +0100)]
core: Grow gc arena gradually.
* mes.c: (gc_up_arena): New function.
(gc): Use it when possible.
(gc_init_cells, gc_init_news): New function.
(mes_symbols): Use them.
Jan Nieuwenhuizen [Sat, 10 Dec 2016 11:07:04 +0000 (12:07 +0100)]
core: gc bugfixes.
* mes.c (make_tmps): New function.
(make_symbols, gc): Use it.
(vm_call_with_values_env): New vm function.
(call-with-values): Call it.
(eval_env): Do not call eval_env inline.
* define.c (vm_define_env): Use r2 rather than local name.
(g_symbols): Rename from symbols.
Jan Nieuwenhuizen [Mon, 21 Nov 2016 08:36:32 +0000 (09:36 +0100)]
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.
Jan Nieuwenhuizen [Sat, 19 Nov 2016 22:25:24 +0000 (23:25 +0100)]
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.
Jan Nieuwenhuizen [Mon, 21 Nov 2016 08:30:59 +0000 (09:30 +0100)]
core: Cleanup cells.
* mes.c: Use accessors rather than g_cell[] access throughout.
Jan Nieuwenhuizen [Sat, 19 Nov 2016 21:31:30 +0000 (22:31 +0100)]
core: Add function indirection.
* mes.c (functions): New array.
(scm_t): Change function pointer to index.
(make_cell): Handle function.
(call): Update for function change.
(display_): Likewise.
(make_function): New function.
* build-aux/mes-snarf.scm (function->source): Update declarations.
(function->environment): New function.
Jan Nieuwenhuizen [Mon, 21 Nov 2016 08:28:34 +0000 (09:28 +0100)]
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.
Jan Nieuwenhuizen [Fri, 28 Oct 2016 16:42:03 +0000 (18:42 +0200)]
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.
Jan Nieuwenhuizen [Thu, 27 Oct 2016 19:00:08 +0000 (21:00 +0200)]
Add sicp garbage example: tests/gc-1.test.
Jan Nieuwenhuizen [Thu, 27 Oct 2016 18:46:29 +0000 (20:46 +0200)]
core: Make using GC in switchable, set to off; on dumps core.
Jan Nieuwenhuizen [Thu, 27 Oct 2016 14:44:09 +0000 (16:44 +0200)]
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.
Jan Nieuwenhuizen [Wed, 26 Oct 2016 17:54:03 +0000 (19:54 +0200)]
Add mes gc test setup.
* tests/gc.test: New file.
Jan Nieuwenhuizen [Mon, 12 Dec 2016 19:35:07 +0000 (20:35 +0100)]
guix hash: 09axqivywpw0l9lm7pk1ncp6690vfv658z731z674ih73yqs5qma
Jan Nieuwenhuizen [Mon, 21 Nov 2016 13:18:01 +0000 (14:18 +0100)]
Release 0.2.
* configure (VERSION): Bump to 0.2.
* mes.c (main): Likewise.
* module/mes/repl.mes: Likewise.
Jan Nieuwenhuizen [Mon, 21 Nov 2016 13:16:52 +0000 (14:16 +0100)]
Update NEWS.
Jan Nieuwenhuizen [Thu, 10 Nov 2016 09:20:47 +0000 (10:20 +0100)]
test: Run psyntax before record.
* GNUmakefile (TESTS): Run psyntax before record.
Jan Nieuwenhuizen [Tue, 8 Nov 2016 20:05:01 +0000 (21:05 +0100)]
test: Add psyntax closure tests.
* tests/closure.test (closure 7, closure 8, closure 9): New test.
Jan Nieuwenhuizen [Sat, 5 Nov 2016 14:33:16 +0000 (15:33 +0100)]
core: Show more info on apply error.
* mes.c (apply_env): Be more specific about what cannot be applied.
Jan Nieuwenhuizen [Sat, 5 Nov 2016 12:46:22 +0000 (13:46 +0100)]
test: Add toplevel begin define test.
* tests/base.test (top begin define): New test.
Jan Nieuwenhuizen [Sat, 5 Nov 2016 10:08:10 +0000 (11:08 +0100)]
core: Bugfix: report name of undefined variable.
* mes.c (assert_defined): Add variable as parmeter, print it. Update
callers.
Jan Nieuwenhuizen [Thu, 3 Nov 2016 21:11:18 +0000 (22:11 +0100)]
core: Use switch in display_helper.
*mes (display_helper): Use switch.
Jan Nieuwenhuizen [Thu, 3 Nov 2016 20:43:01 +0000 (21:43 +0100)]
core: Refactor eval.
* mes.c (eval_env): Rename from builtin_eval, Update callers. Use switch.
Jan Nieuwenhuizen [Thu, 3 Nov 2016 20:28:05 +0000 (21:28 +0100)]
core: One SCM type for function.
* mes.c (function_t): New struct.
(type): One type for function.
(call): Refactor.
* build-aux/mes-snarf.mes: Use arity annotation. WAS: args. Update
annotations.
Jan Nieuwenhuizen [Thu, 3 Nov 2016 09:39:22 +0000 (10:39 +0100)]
core: Cleanup macro expansion.
* mes.c (builtin_eval): Call expand_macro_env after handling primitives.
(expand_macro_env): Include syntax-case expansion, remove skipping
of primitives.
(sc_expand_env): Remove.
Jan Nieuwenhuizen [Thu, 3 Nov 2016 09:37:08 +0000 (10:37 +0100)]
core: Factor-out assert_defined.
* mes.c (assert_defined): New function.
(set_env_x): Use it.
(builtin_eval): Use it.
Jan Nieuwenhuizen [Wed, 2 Nov 2016 19:25:08 +0000 (20:25 +0100)]
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.
Jan Nieuwenhuizen [Wed, 2 Nov 2016 19:22:02 +0000 (20:22 +0100)]
posix: Implement open-input-file.
* posix.c: New file.
* mes.c: Include posix.environment.h, posix.environment.i, posix.environment.c.
(read_input_file_env): Rename from read_file_env. Update
callers.
(load_env): Rename from load_file_env. Update callers.
* GNUmakefile (mes.o): Add posix.c, posix.environment.h,
posix.environment.i dependencies.
Jan Nieuwenhuizen [Wed, 2 Nov 2016 17:25:18 +0000 (18:25 +0100)]
core: Support switching of input stream.
* mes.c (g_stdin): New global.
(getchar): New function, use g_stdin.
(ungetchar): Use g_stdin.
(main): Initialize g_stdin to stdin.
Jan Nieuwenhuizen [Wed, 2 Nov 2016 14:35:32 +0000 (15:35 +0100)]
Update documentation wrt syntax-case.
* HACKING: Update wrt syntax-case.
* NEWS: Likewise.
* README: Likewise.
* guix.scm: Likewise.
Jan Nieuwenhuizen [Wed, 2 Nov 2016 14:39:27 +0000 (15:39 +0100)]
Update AUTHORS.
* AUTHORS: Include information on lalr, match and psyntax.
Jan Nieuwenhuizen [Wed, 2 Nov 2016 09:36:09 +0000 (10:36 +0100)]
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.
Jan Nieuwenhuizen [Wed, 2 Nov 2016 09:26:04 +0000 (10:26 +0100)]
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.
Jan Nieuwenhuizen [Wed, 2 Nov 2016 08:40:58 +0000 (09:40 +0100)]
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.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 22:32:33 +0000 (23:32 +0100)]
psyntax: More tests.
* tests/psyntax.test: Add tests.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 22:30:22 +0000 (23:30 +0100)]
core: Fix quasisyntax reading.
* mes.c (readword): Avoid unspecified behaviour in comma list.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 22:28:57 +0000 (23:28 +0100)]
test: Add new macros.
* module/mes/test.mes (pass-if-equal, expect-fail): New macros.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 15:18:59 +0000 (16:18 +0100)]
repl: Add sc-expand meta command, include syntax-case.
* module/mes/repl.mes (,sc-expand): New meta command.
* scripts/repl.mes: Include psyntax-0, psyntax-1, psyntax. Not used as
basis for match yet.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 19:41:49 +0000 (20:41 +0100)]
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.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 19:32:38 +0000 (20:32 +0100)]
Bugfix include.mes: skip commented modules.
* scripts/include.mes: Make regexp more strict.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 15:16:20 +0000 (16:16 +0100)]
Initial psyntax integration.
* mes.c (sc_expand_env): New function.
(builtin_eval): Use it.
* module/mes/psyntax-0.mes: New file.
* module/mes/psyntax-1.mes: New file.
* tests/psyntax.test: New file.
* GNUmakefile (TESTS): Add it.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 14:46:54 +0000 (15:46 +0100)]
psyntax: Add missing (interaction-environment) to eval.
* module/mes/psyntax.mes: Add (interaction-environment) to eval.
Jan Nieuwenhuizen [Sat, 29 Oct 2016 17:05:06 +0000 (19:05 +0200)]
Import psyntax from Guile-1.3a.
* module/mes/psyntax.mes: New file.
* module/mes/psyntax.ss: New file.
commit
230c435383087a1e6ad60d9c98d3ec75dd2c3e49
Author: Mikael Djurfeldt <djurfeldt@nada.kth.se>
Date: Tue Aug 19 01:28:50 1997 +0000
* syncase.scm: New file: Guile-adaption for syntax-case macros.
psyntax.pp, psyntax.ss: Syntax-case macros, portable version 2 by
R. Kent Dybvig, Oscar Waddell, Bob Hieb and Carl Bruggeman
Jan Nieuwenhuizen [Sun, 30 Oct 2016 19:33:59 +0000 (20:33 +0100)]
Exit upon error.
* module/mes/scm.mes (error): Add exit 1.
Jan Nieuwenhuizen [Sun, 20 Nov 2016 20:17:49 +0000 (21:17 +0100)]
Mescc: avoid `if'.
* module/language/c/lexer.mes (keywords): Produce `If'.
* module/language/c/parser.mes (c-parser): Use `If.'
Jan Nieuwenhuizen [Sun, 30 Oct 2016 15:01:34 +0000 (16:01 +0100)]
core: Add compile time switch for quasisyntax.
* mes.c [QUASISYNTAX]: New switch. Default off.
(builtin_eval) [QUASISYNTAX]: Handle syntax, unsyntax, quasisyntax.
* quasiquote.c (syntax, unsyntax, unsyntax_splicing, eval_quasisyntax,
add_unsyntaxers) [QUASISYNTAX]: Available only.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 14:42:50 +0000 (15:42 +0100)]
More error handling on apply_env.
* mes.c (apply_env): Assert if applying *unspecified*.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 14:39:36 +0000 (15:39 +0100)]
Bugfix assq_ref_cache for running without environment cache.
* mes.c (assq_ref_cache) [!ENV_CACHE]: Return *undefined* if nothing
found.
Jan Nieuwenhuizen [Sun, 30 Oct 2016 14:38:27 +0000 (15:38 +0100)]
Error handling on failing set!.
* mes.c (set_env_x): Produce error message [WAS: dump core].
Jan Nieuwenhuizen [Sat, 29 Oct 2016 16:43:03 +0000 (18:43 +0200)]
Simplify toplevel read.
* mes.c (read_file_env): Rename from read_file.
(load_file_env): New function.
(main): Use it.
Jan Nieuwenhuizen [Sat, 29 Oct 2016 16:35:06 +0000 (18:35 +0200)]
boot: fix ignored.
* module/mes/loop-0.mes: Wrap read-file in begin.
* module/mes/mes-0.mes: Remove ignored.
Jan Nieuwenhuizen [Sat, 29 Oct 2016 14:35:44 +0000 (16:35 +0200)]
Implement apply with multiple arguments.
* module/mes/base-0.mes (apply): Handle multiple arguments.
* tests/base.test: (apply, apply 1, apply 2): New test.
Jan Nieuwenhuizen [Sat, 29 Oct 2016 14:06:41 +0000 (16:06 +0200)]
Fix values.
* mes.c (call): Respect any other non-value arguments.
* tests/scm.test (values, values 2, values 3, call-with-values): New test.
Jan Nieuwenhuizen [Wed, 26 Oct 2016 17:44:36 +0000 (19:44 +0200)]
Define garbage collector/jam collector primitives.
* mes.c (make_cell): New primitive alongside make_vector for allocation.
(cons, make_char, make_macro, make_number, make_ref,
internal_make_symbol, make_vector): Use it.
Jan Nieuwenhuizen [Tue, 25 Oct 2016 14:50:19 +0000 (16:50 +0200)]
Implement strings and symbols as list of characters [WAS: c-string].
* mes.c (scm_t): Add string field.
(make_string, internal_lookup_symbol, internal_make_symbol,
make_symbol, lookup, readword): Take scm*. Update callers.
(display_helper): Support string field.
(append_char): New function.
(readstring): Use it. Produce scm*.
(cstring_to_list): New function.
(add_environment, internal_make_symbol): Use it.
(list_of_char_equal_p): New function.
(internal_lookup_symbol): Use it.
* lib.c (list_ref): New function.
* string.c (string_ref): Use it.
(string, string_append, string_length, substring, number_to_string,
string_to_symbol, symbol_to_string): Update to list-of-characters
implementation.
Jan Nieuwenhuizen [Tue, 25 Oct 2016 06:59:20 +0000 (08:59 +0200)]
Environment cache bugfix for define.
* define.c (define): Invalidate cache. Fixes vector test.
* GNUmakefile (mes-check, guile-check): Use set -e. Fixes skipping over errors.
Jan Nieuwenhuizen [Mon, 24 Oct 2016 22:21:28 +0000 (00:21 +0200)]
Introduce reference type, use vectors of SCM.
* mes.c (type): Add REF.
(scm_t): Add ref, change vector to *scm_t. Update users.
(alloc): New function.
(cons, make_char, make_macro, make_number, make_string,
internal_make_symbol, make_vector): Use it.
(make_ref): New function.
(vector_entry): New function.
(make_vector, list_to_vector, vector_set_x): Use it.
(vector_ref): Dereference REF entry.
(display_helper): Handle REF.
* lib.c (vector_to_list): Handle REF.
* type.c (ref_p): New function.
* tests/vector.test (vector list): New test.
Bugfix vector-ref.
* mes.c (vector-ref): Make copies of simple values. Fixes lalr.
* tests/vector.test (vector-set! 3): New test.
Jan Nieuwenhuizen [Mon, 24 Oct 2016 15:49:40 +0000 (17:49 +0200)]
Guile gc experiment: remove global scan variable.
Jan Nieuwenhuizen [Mon, 24 Oct 2016 09:52:01 +0000 (11:52 +0200)]
Guile gc experiment: add garbage collection.
Jan Nieuwenhuizen [Sun, 23 Oct 2016 15:21:56 +0000 (17:21 +0200)]
Guile gc experiment: add lists and display.
* guile/gc.scm (gc-nil, gc-null?, gc-list, gc-display, make-symbol):
New function.
Jan Nieuwenhuizen [Sun, 23 Oct 2016 12:22:53 +0000 (14:22 +0200)]
Guile gc experiment: add pairs.
* guile/gc.scm (cell-type, cell-index, gc-cons, gc-car, gc-cdr): New
function.
Jan Nieuwenhuizen [Sun, 23 Oct 2016 10:32:40 +0000 (12:32 +0200)]
Guile gc experiment.
guile/gc.scm: New file.
Jan Nieuwenhuizen [Sun, 23 Oct 2016 12:25:37 +0000 (14:25 +0200)]
Revert "Speedup boot eval/apply."
This reverts commit
6326b3103156fd79cd7bebbb351194626cc8a64b.
Jan Nieuwenhuizen [Sat, 22 Oct 2016 19:43:39 +0000 (21:43 +0200)]
Speedup boot eval/apply.
* module/mes/mes-0.scm (apply-env, evlis, eval-expand,
eval-quasiquote): use IF iso COND: factor 3.
(apply-env): Use lambda iso let: another 30%.
Jan Nieuwenhuizen [Mon, 12 Dec 2016 19:33:26 +0000 (20:33 +0100)]
guix hash: 115jycdz8i1r5sj2fsjqcrh456mayxzaykb8cxxxc3wxfkj8nagf
Jan Nieuwenhuizen [Sun, 20 Nov 2016 20:47:47 +0000 (21:47 +0100)]
Release 0.1.
* configure (VERSION): Bump to 0.1.
* mes.c (main): Likewise.
* module/mes/repl.mes: Likewise.
Jan Nieuwenhuizen [Sun, 20 Nov 2016 20:45:12 +0000 (21:45 +0100)]
Documentation update.
* HACKING: Target is R6RS-like, at least having syntax-case.
* README: Likewise.
* guix.scm: Likewise.
Jan Nieuwenhuizen [Sun, 23 Oct 2016 08:08:04 +0000 (10:08 +0200)]
Avoid gratuitous consing with begin and quasiquote.
* mes.c (apply_env, main): Call begin rather than eval with cons'ed
symbol begin.
* module/mes/mes-0.mes (apply-env): Likewise.
* quasiquote.c (add_unquoters): cons global unquoters rather than
creating it fresh.
* module/mes/mes-0.mes (add-unquoters): Likewise.
Jan Nieuwenhuizen [Sat, 22 Oct 2016 18:58:33 +0000 (20:58 +0200)]
Remove dead code.
* mes.c (mes_environment): Remove dead code.
Jan Nieuwenhuizen [Sat, 22 Oct 2016 18:51:32 +0000 (20:51 +0200)]
Move other post-boot and derived functions to lib.c.
* mes.c (c*r, length, last_pair, builtin_list, vector_to_list,
integer_to_char, char_to_integer, builtin_exit): Move to lib.c.
* lib.c: New file.
* GNUmakefile (mes.o): Depend on lib snarf output.
Jan Nieuwenhuizen [Sat, 22 Oct 2016 18:18:03 +0000 (20:18 +0200)]
Move strings to string.c.
* mes.c (string, string_append, list_to_string, string_length,
string_ref, substring, number_to_string, string_to_symbol,
symbol_to_string): Move to string.c
* string.c: New file.
* GNUmakefile (mes.o): Depend on string snarf output.
Jan Nieuwenhuizen [Sat, 22 Oct 2016 18:07:12 +0000 (20:07 +0200)]
Move arithmetic functions to math.c.
* mes.c (greater_p, less_p, is_p, minus, divide, modulo, multiply,
logior): Move to math.c.
* math.c: New file.
* GNUmakefile (mes.o): Depend on math snarf output.
Jan Nieuwenhuizen [Sat, 22 Oct 2016 17:36:54 +0000 (19:36 +0200)]
Move define, define-macro to define.c.
* mes.c (define, define-macro): Move to define.c
* define.c: New file.
* GNUmakefile (mes.o): Depend on define snarf output.
Jan Nieuwenhuizen [Sat, 22 Oct 2016 17:26:12 +0000 (19:26 +0200)]
Move quasiquote to quasiquote.c.
* mes.c (unquote, unquote_splicing, syntax, unsyntax,
unsyntax_splicing, eval_quasiquote, eval_quasisyntax, add_unquoters,
add_unsyntaxers): Move to quasiquote.c
* quasiquote.c: New file.
* GNUmakefile (mes.o): Depend on quasiquote snarf output.
Jan Nieuwenhuizen [Sat, 22 Oct 2016 10:16:19 +0000 (12:16 +0200)]
Move optional type predicates to type.c.
* mes.c (char_p, macro_p, number_p, pair_p, string_p, symbol_p,
vector_p, builtin_p, boolean_p): Move to type.c
* type.c: New file.
* GNUmakefile (mes.o): Depend on type snarf output.
* module/mes/loop-0.mes (cond, map, let, or, and not, evlis-env,
apply-env, eval-expand, uquote, add-unquoters, eval,
expand-macro-env, eval-begin-env, eval-if-env, sexp:define,
env:define, env:macro): Move to mes-0.mes.
* module/mes/mes-0.mes: New file.
* module/mes/type-0.mes: New file.
* scripts/include.mes: If BOOT, also include mes-0.mes. If TYPE0,
also include type-0.mes.
Jan Nieuwenhuizen [Mon, 12 Dec 2016 19:31:41 +0000 (20:31 +0100)]
Update NEWS.
* NEWS: Note specials fix and booting with smaller core.
Jan Nieuwenhuizen [Fri, 21 Oct 2016 20:44:50 +0000 (22:44 +0200)]
Generate C header and includes using snarfing.
* mes.c: Move specific renames and n-args to alist annotation.
* build-aux/mes-snarf.scm: New file.
* GNUmakefile (mes.environment.h): Use it.
(mes.h): Remove.
(clean): Update.
(mes.o): New dependency rule.
* .gitignore: Update.
Jan Nieuwenhuizen [Sat, 22 Oct 2016 16:13:37 +0000 (18:13 +0200)]
Revert "Flip sign of cached symbols: only search cache if symbol is cached."
This reverts commit
cef058be0d6ef5322f74e644bbcd96f1725c6327.
Jan Nieuwenhuizen [Fri, 21 Oct 2016 18:44:18 +0000 (20:44 +0200)]
Flip sign of cached symbols: only search cache if symbol is cached.
* mes.c (cache_save): Flip sign when caching and invalidating.
(cache_invalidate): Flip sign when invalidating.
Jan Nieuwenhuizen [Thu, 20 Oct 2016 22:00:05 +0000 (00:00 +0200)]
named let-fu FIXME
Jan Nieuwenhuizen [Fri, 21 Oct 2016 09:14:33 +0000 (11:14 +0200)]
boot: fix builtin? tests.
* tests/scm.test: Test primitives, not eval.
Jan Nieuwenhuizen [Fri, 21 Oct 2016 08:43:32 +0000 (10:43 +0200)]
Environment cache heuristicts.
* mes.c (ENV_HEAD): New define.
(assq_ref_cache): Use it.
Jan Nieuwenhuizen [Fri, 21 Oct 2016 08:41:29 +0000 (10:41 +0200)]
boot: support apply.
* module/mes/loop-0.mes (eval-env): Add clause for apply-env.
Jan Nieuwenhuizen [Fri, 21 Oct 2016 08:39:13 +0000 (10:39 +0200)]
boot: Remove label support from Scheme.
* module/mes/loop-0.scm (apply-env): Remove label clause.
Jan Nieuwenhuizen [Fri, 21 Oct 2016 08:51:09 +0000 (10:51 +0200)]
boot: vector support.
* mes.c (make_vector): Change to scm interface.
(temp_number): New global.
(list_to_vector): Use it.
* module/mes/scm.mes (c:make-vector): New function.
* tests/scm.test: Remove vector tests.
* tests/vector.test: New file.
* GNUmakefile (TESTS): Add it.
Jan Nieuwenhuizen [Fri, 21 Oct 2016 08:52:59 +0000 (10:52 +0200)]
Avoid let* in scm.mes.
* module/mes/scm.mes (case, max, min): Avoid let*.
Jan Nieuwenhuizen [Thu, 20 Oct 2016 22:02:24 +0000 (00:02 +0200)]
loop-0: define and, let and cache-invalidate-range.
Jan Nieuwenhuizen [Thu, 20 Oct 2016 21:33:35 +0000 (23:33 +0200)]
boot: support quasiquote in eval.
* module/mes/loop-0.mes (eval-env): Add quasiquote support.
Jan Nieuwenhuizen [Tue, 18 Oct 2016 17:50:07 +0000 (19:50 +0200)]
Remove evcon from loop-0.
* module/mes/loop-0.mes (loop-0): Handle define-macro.
(cond): New macro.
(eval-env-expand): Remove 'cond clause.
(evcon): Remove.
Jan Nieuwenhuizen [Thu, 20 Oct 2016 20:03:17 +0000 (22:03 +0200)]
Switch fat-c/boot using environment variable BOOT.
* GNUmakefile: check for BOOT, set CFLAGS.
* mes.c: Remove hardcoded BOOT define.
* scripts/include.mes: include loop-0 when BOOT is set.
Jan Nieuwenhuizen [Sun, 16 Oct 2016 16:53:31 +0000 (18:53 +0200)]
Implement eval/apply in Scheme.
* module/mes/loop-0.mes: New file.
* module/mes/mes.mes: Remove
Jan Nieuwenhuizen [Thu, 20 Oct 2016 16:43:33 +0000 (18:43 +0200)]
Reduce eval/apply in core, extend in Scheme.
* mes.c (eval_env_)[BOOT]: Rename from eval_env. Remove define, defin-macro.
(eval_env): New function.
(make_macro): Swap parameter ordering.
(apply_env)[BOOT]: Support label.
Jan Nieuwenhuizen [Wed, 19 Oct 2016 22:21:06 +0000 (00:21 +0200)]
Avoid adding top of environment to cache.
* mes.c (assq_ref_cache): Only consider caching symbols deeper than
4*CACHE_SIZE depth. 50% speedup.
Jan Nieuwenhuizen [Wed, 19 Oct 2016 22:11:48 +0000 (00:11 +0200)]
Implement environment cache.
* mes.c (cache_save, cache_lookup, cache_invalidate,
cache_invalidate_range): Implement cache for environment.
(assq_ref_cache): New function, perform cached lookups.
(builtin_eval,lookup_macro): Use it.
(set_cdr_x): Invalidate cache.
(set_x): Likewise.
(apply_env): Likewise.
Jan Nieuwenhuizen [Thu, 20 Oct 2016 17:19:32 +0000 (19:19 +0200)]
Introduce SCM type for special symbols.
* GNUmakefile (mes.h): Also export SCM to symbols.i
* mes.c: Introduce SCM type for special symbols.
(builtin_eval): Rename from eval_env. Update callers.
* module/mes/base-0.mes (eval): Remove.
* module/mes/repl.mes (repl): Use eval.
Jan Nieuwenhuizen [Thu, 20 Oct 2016 07:37:14 +0000 (09:37 +0200)]
Remove static primitives hack.
* mes.c (internal_primitive_p, internal_p, lookup_primitive,
mes_primitives): Remove.