Commit graph

257 commits

Author SHA1 Message Date
Jan Nieuwenhuizen 79d989268f Mescc: avoid `if'.
* module/language/c/lexer.mes (keywords): Produce `If'.
* module/language/c/parser.mes (c-parser): Use `If.'
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen d34dba24f2 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.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen ad717d4bba More error handling on apply_env.
* mes.c (apply_env): Assert if applying *unspecified*.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen 332d2655cf Bugfix assq_ref_cache for running without environment cache.
* mes.c (assq_ref_cache) [!ENV_CACHE]: Return *undefined* if nothing
  found.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen 2cad00527e Error handling on failing set!.
* mes.c (set_env_x): Produce error message [WAS: dump core].
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen 3b4e9f36c8 Simplify toplevel read.
* mes.c (read_file_env): Rename from read_file.
 (load_file_env): New function.
 (main): Use it.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen 97212b5765 boot: fix ignored.
* module/mes/loop-0.mes: Wrap read-file in begin.
* module/mes/mes-0.mes: Remove ignored.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen 781957cbe9 Implement apply with multiple arguments.
* module/mes/base-0.mes (apply): Handle multiple arguments.
* tests/base.test: (apply, apply 1, apply 2): New test.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen 1f511481a3 Fix values.
* mes.c (call): Respect any other non-value arguments.
* tests/scm.test (values, values 2, values 3, call-with-values): New test.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen f593a5c9d7 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.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen 16f678a158 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.
2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen 266c66e40c 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.
2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen d209a18121 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.
2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen 3249db47b0 Guile gc experiment: remove global scan variable. 2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen 8fbe7f1b32 Guile gc experiment: add garbage collection. 2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen e1d5135af6 Guile gc experiment: add lists and display.
* guile/gc.scm (gc-nil, gc-null?, gc-list, gc-display, make-symbol):
  New function.
2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen 088d939945 Guile gc experiment: add pairs.
* guile/gc.scm (cell-type, cell-index, gc-cons, gc-car, gc-cdr): New
  function.
2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen c5e20f196c Guile gc experiment.
guile/gc.scm: New file.
2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen a00e69863e Revert "Speedup boot eval/apply."
This reverts commit 6326b3103156fd79cd7bebbb351194626cc8a64b.
2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen 0bd0cb2e3e 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%.
2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen 2262e4e409 guix hash: 115jycdz8i1r5sj2fsjqcrh456mayxzaykb8cxxxc3wxfkj8nagf 2016-12-12 20:33:43 +01:00
Jan Nieuwenhuizen 3849c48f79 Release 0.1.
* configure (VERSION): Bump to 0.1.
* mes.c (main): Likewise.
* module/mes/repl.mes: Likewise.
2016-11-20 21:47:47 +01:00
Jan Nieuwenhuizen 09a21626a8 Documentation update.
* HACKING: Target is R6RS-like, at least having syntax-case.
* README: Likewise.
* guix.scm: Likewise.
2016-11-20 21:45:12 +01:00
Jan Nieuwenhuizen 2823fca025 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.
2016-10-23 10:08:04 +02:00
Jan Nieuwenhuizen 011102bc12 Remove dead code.
* mes.c (mes_environment): Remove dead code.
2016-10-22 20:58:33 +02:00
Jan Nieuwenhuizen 6a4395869b 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.
2016-10-22 20:51:32 +02:00
Jan Nieuwenhuizen e282117de9 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.
2016-10-22 20:18:03 +02:00
Jan Nieuwenhuizen be2f3bc274 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.
2016-10-22 20:07:12 +02:00
Jan Nieuwenhuizen 27247383d7 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.
2016-10-22 19:36:54 +02:00
Jan Nieuwenhuizen bd7beddcda 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.
2016-10-22 19:26:12 +02:00
Jan Nieuwenhuizen 2586f0bb2c 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.
2016-10-22 12:16:19 +02:00
Jan Nieuwenhuizen c8fdae40d9 Update NEWS.
* NEWS: Note specials fix and booting with smaller core.
2016-12-12 20:31:41 +01:00
Jan Nieuwenhuizen 3e03a12a4d 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.
2016-10-21 22:44:50 +02:00
Jan Nieuwenhuizen 18aa0beaa9 Revert "Flip sign of cached symbols: only search cache if symbol is cached."
This reverts commit cef058be0d6ef5322f74e644bbcd96f1725c6327.
2016-10-22 18:13:37 +02:00
Jan Nieuwenhuizen 1684564ea1 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.
2016-10-21 20:44:18 +02:00
Jan Nieuwenhuizen bca8061232 named let-fu FIXME 2016-10-21 00:00:05 +02:00
Jan Nieuwenhuizen 497bbdc76f boot: fix builtin? tests.
* tests/scm.test: Test primitives, not eval.
2016-10-21 11:14:33 +02:00
Jan Nieuwenhuizen 2545605a69 Environment cache heuristicts.
* mes.c (ENV_HEAD): New define.
  (assq_ref_cache): Use it.
2016-10-21 10:43:32 +02:00
Jan Nieuwenhuizen 28b695510b boot: support apply.
* module/mes/loop-0.mes (eval-env): Add clause for apply-env.
2016-10-21 10:41:29 +02:00
Jan Nieuwenhuizen 2938f5155d boot: Remove label support from Scheme.
* module/mes/loop-0.scm (apply-env): Remove label clause.
2016-10-21 10:39:13 +02:00
Jan Nieuwenhuizen 46eca44fb4 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.
2016-10-21 10:51:09 +02:00
Jan Nieuwenhuizen 2926190567 Avoid let* in scm.mes.
* module/mes/scm.mes (case, max, min): Avoid let*.
2016-10-21 10:52:59 +02:00
Jan Nieuwenhuizen 37d27f66e3 loop-0: define and, let and cache-invalidate-range. 2016-10-21 00:02:24 +02:00
Jan Nieuwenhuizen 430455e886 boot: support quasiquote in eval.
* module/mes/loop-0.mes (eval-env): Add quasiquote support.
2016-10-20 23:33:35 +02:00
Jan Nieuwenhuizen 97f1d71de6 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.
2016-10-18 19:50:07 +02:00
Jan Nieuwenhuizen c8e87f3021 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.
2016-10-20 22:03:17 +02:00
Jan Nieuwenhuizen 596fa86cc4 Implement eval/apply in Scheme.
* module/mes/loop-0.mes: New file.
* module/mes/mes.mes: Remove
2016-10-16 18:53:31 +02:00
Jan Nieuwenhuizen 1d0cbcd59c 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.
2016-10-20 18:43:33 +02:00
Jan Nieuwenhuizen 1e62bbf8c9 Avoid adding top of environment to cache.
* mes.c (assq_ref_cache): Only consider caching symbols deeper than
  4*CACHE_SIZE depth.  50% speedup.
2016-10-20 00:21:06 +02:00
Jan Nieuwenhuizen 7885096526 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.
2016-10-20 00:11:48 +02:00