Commit graph

206 commits

Author SHA1 Message Date
Jan Nieuwenhuizen 23c1e33a6d 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.
2017-01-04 09:05:56 +01:00
Jan Nieuwenhuizen a80ced8f84 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.
2017-01-04 08:52:04 +01:00
Jan Nieuwenhuizen 5f8eedacec Display: If possible, show name of closure.
* module/mes/display.mes (display): Lookup closure's name and display it.
2017-01-04 08:49:45 +01:00
Jan Nieuwenhuizen 41207c663e 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.
2016-12-25 15:38:26 +01:00
Jan Nieuwenhuizen 95a7782089 Revert "core: Display me debuggor."
This reverts commit 53ec23a0edcfdcb7dd4e32277e5a24e0a8fab5dd.
2016-12-25 11:54:14 +01:00
Jan Nieuwenhuizen 6014e56f68 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.
2016-12-25 11:53:55 +01:00
Jan Nieuwenhuizen 9dcbdf2135 Revert "core: FAT_C_READER: Show your speed."
This reverts commit 5a9b9ac36bd33e497272b287ab1f0db715e01d38.
2016-12-25 09:57:19 +01:00
Jan Nieuwenhuizen d8ea0d593b 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.
2016-12-25 08:41:27 +01:00
Jan Nieuwenhuizen 49f1c4e5f3 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.
2016-12-24 22:16:53 +01:00
Jan Nieuwenhuizen 7cb8aea66f 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.
2016-12-24 14:21:36 +01:00
Jan Nieuwenhuizen f1e0165faf core: Move dump, load, bload to lib.c.
* lib.c (dump, load, bload): Move from mes.c
* mes.c (dump, load, bload): Remove.
2016-12-24 14:05:33 +01:00
Jan Nieuwenhuizen 15163e9dc1 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.
2016-12-24 14:09:48 +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 bdeb41e0ae 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.
2016-12-24 11:28:25 +01:00
Jan Nieuwenhuizen 1f1f1454d8 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.
2016-12-24 11:21:30 +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 16e3caafcd core: Remove display.
* posix.c (stderr_): New function.
* display.c: Remove.
* mes.c: Remove includes.  Use stderr_ instead of display_.
 (gc_loop): Preserve function's name.
 (arity_): New function.
* GNUmakefile (mes.o): Remove dependency on display.
* module/mes/read-0.mes: Use core:stderr instead of display, newline.
  (newline): New function.
* module/mes/base-0.mes: Use core:stderr instead of display.
  Include (mes display).
* module/mes/display.mes: New file.
* lib.c (assert_defined): Move from mes.c.
  (string_to_cstring): Move from posix.c
* build-aux/mes-snarf.scm (function-environment): Initialize function
  name with scheme string.
2016-12-24 01:23:50 +01:00
Jan Nieuwenhuizen 73fc7707a5 core: Remove symbol_to_list, char_to_integer, integer_to_char.
* mes.c (symbol_to_list, char_to_integer, integer_to_char): Remove
* module/mes/read-0.mes (symbol->list, integer->char,
  symbol->keyword): New function.
  (read-word): Use symbol->keyword.
* module/mes/type-0.mes (char->integer): New function.
* module/mes/scm.mes (keyword->symbol): New function.
2016-12-23 23:25:49 +01:00
Jan Nieuwenhuizen 95fd6646dc core: Remove string.c.
* string.c: Remove.
* mes.c (eval_apply): Remove caller.
* GNUmakefile (mes.o): Remove dependency on string.
* module/mes/psyntax-0.mes (eval): Handle "noexpand".
* module/mes/type-0.mes (string->symbol, symbol->list, symbol->string):
  New function.
2016-12-23 22:48:27 +01:00
Jan Nieuwenhuizen e13587f57f core: Remove last_pair, list_ref, string_ref.
* lib.c (last_pair, list_ref): Remove.
* string.c (string_ref): Remove.
* module/mes/type-0.mes (string->list): New function.
* module/mes/scm.mes (string-ref): New function.
2016-12-23 20:09:57 +01:00
Jan Nieuwenhuizen 20b7a7851a core: Make closure real type.
* display.c (display_helper):
* mes.c (type_t): Add CLOSURE.
  (scm_t): Add closure.
  (CLOSURE): New macro.
  (eval_apply:apply): Update.
  (eval_apply:eval): Remove closure special-casing.
  (gc_loop): Handle CLOSURE.
* module/mes/read-0.mes: Update types.
* module/mes/type-0.mes: Update types.
* display.c (display): Update.
* module/mes/fluids.mes (env:escape-closure): Check for '*closure.
2016-12-23 18:48:36 +01:00
Jan Nieuwenhuizen 20eecdc638 core: Remove quote, quasiquote, quasisyntax.
* mes.c (quote, quasiquote, quasisyntax): Remove.
2016-12-23 18:11:46 +01:00
Jan Nieuwenhuizen 8a4a3a4537 core: Remove make_lambda.
* mes.c (make_lambda): Remove.
2016-12-23 18:10:31 +01:00
Jan Nieuwenhuizen 10235efe7e core: Remove type.c.
* module/mes/type-0.mes: Resurrect.
* module/mes/base-0.mes: Include it.
* module/mes/read-0.mes (not, pair?, atom?): New functions.
* type.c: Remove.
* mes.c: Remove callers.
* GNUmakefile (mes.o): Remove dependency on type.
2016-12-23 18:05:45 +01:00
Jan Nieuwenhuizen 13dd5a1013 core: Remove gc_show.
* mes.c (gc_show): Remove.
2016-12-23 17:05:04 +01:00
Jan Nieuwenhuizen 97dfc3c981 core: Remove add_environment.
* mes.c (add_environment): Remove.  Update callers.
  (scm_symbol_dot): New global.
2016-12-23 17:02:23 +01:00
Jan Nieuwenhuizen 26e3e41357 core: Remove make_string.
* mes.c (MAKE_STRING): New macro.
  (make_string): Remove.  Update callers.
* string.c: Update callers.
2016-12-23 16:38:07 +01:00
Jan Nieuwenhuizen faed68ed57 core: Remove make_ref.
* mes.c (MAKE_REF): New macro.
  (make_ref): Remove.  Update callers.
2016-12-23 16:31:56 +01:00
Jan Nieuwenhuizen c4fe110d1e core: Remove make_char.
* mes.c (MAKE_CHAR): New macro.
  (make_char): Remove.  Update callers.
* reader.c (peek_char, read_char, unread_char): Remove.
* module/mes/scm.mes (peek-char, read-char, unread-char): New function.
2016-12-23 16:26:00 +01:00
Jan Nieuwenhuizen c2bfeffe96 core: Remove make_number.
* mes.c (MAKE_NUMBER): New macro.
  (tmp_num_, tmp_num_2): New function.
  (make_number): Remove.  Update callers.
2016-12-23 16:22:19 +01:00
Jan Nieuwenhuizen c2a12c4f34 Remove make_function.
* mes.c (make_function): Remove.
2016-12-23 16:02:36 +01:00
Jan Nieuwenhuizen 89e78bec77 core: Remove make_keyword.
* mes.c (make_keyword): Remove.
* module/mes/read-0.mes (<cell:keyword>): New global.
  (read-word): Use it with make_cell instead fo make-keyword.
* strting.c (symbol_to_keyword): Use make_cell instead of make_keyword.
2016-12-23 15:53:57 +01:00
Jan Nieuwenhuizen 976c86318e core: Remove make_macro.
* module/mes/read-0.mes (<macro>): New global.
  (env:macro): Use it with make_cell instead of make_macro.
* mes.c (make_macro): Remove.
* type.c (car_): Rename from mes_car.
  (cdr_): Rename from mes_cdr.
2016-12-23 15:47:52 +01:00
Jan Nieuwenhuizen 18ba10e2ae core: Simplify lookup.
* reader.c (lookup_): Rename from lookup.  Remove all lookups except
  for numbers and symbols.  Update callers.
* mes.c (make_symbol_): Rename from internal_make_symbol.  Update
  callers.
* module/mes/read-0.mes (lookup): New function.
  (read-word): Remove all lookup calls, except for numbers and symbols.
2016-12-23 11:31:34 +01:00
Jan Nieuwenhuizen aa0aaa58ab core: Cleanup symbol initialization and lookup.
* build-aux/mes-snarf.scm (symbol->names): New function
  (function->environment): Initialize symbol.
  (generate-includes): Also write .symbol-names.i.
* mes.c (mes_symbols): Include it.  Remove internal_lookup_symbol.
* display.c (display): Handle display of nil in symbol list.
* reader.c (internal_lookup_symbol): Remove name-fu.
2016-12-23 10:38:41 +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 b45a3b6f33 core: Disable reader.
* mes.c (READER): Switch off.
* module/mes/read-0.mes (eat-whitespace): Handle #;.
2016-12-22 21:23:49 +01:00
Jan Nieuwenhuizen 570eec966e core: Do some tail call elimination.
* mes.c (eval_apply): Use goto instead of return.
2016-12-22 16:50:51 +01:00
Jan Nieuwenhuizen 471bdb0af4 core: One big eval_apply.
* mes.c (eval_apply): New function.
  (eval_apply_t): New type.
  (g_target): New global.
  (vm_evlis, vm_apply_env, vm_eval_env, vm_expand_macro_env,
  vm_begin_env, vm_if_env, vm_call_with_values_env): Remove.  Update callers.
  (macro_expand_env): Rename from expand_macro_env.
* guile/mes.mes: Update callers.
* module/mes/base-0.mes: Likewise.
* module/mes/mes-0.mes: Likewise.
* module/mes/psyntax-1.mes: Likewise.
* module/mes/repl.mes: Likewise.
2016-12-22 16:34:28 +01:00
Jan Nieuwenhuizen cc58cf2e04 core: Remove vm_call_lambda.
* mes.c (vm_call_lambda): Remove.
 (call_lambda): Use begin_env.
2016-12-22 16:16:09 +01:00
Jan Nieuwenhuizen 8256f2638e core: Remove quasiquote, quasisyntax.
* quasiquote.c: Remove.
* mes.c: Remove callers.
* GNUmakefile (mes.o): Remove dependency on quasiquote.
2016-12-22 15:41:43 +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 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 681a541774 core: Do macro expansion only once.
* mes.c (vm_eval_env): I will expand this macro only once.
2016-12-22 08:31:20 +01:00
Jan Nieuwenhuizen 7bf25a7e17 core: Remove define.
* base-0.mes (cons*): Refactor.
* module/mes/read-0.mes: Implement define, define-macro using macros.
* define.c: Remove.
* mes.c: Remove callers.
* GNUmakefile (mes.o): Remove dependency on define.
2016-12-21 22:22:34 +01:00
Jan Nieuwenhuizen 23754e6f75 core: Bugfix unread_byte.
* mes.c (unread_byte): Return SCM value instead of stray int.
2016-12-20 22:28:29 +01:00
Jan Nieuwenhuizen 15eabee623 Resurrect quasisyntax support.
* mes.c (the_unsyntaxers): New symbol.
  (mes_builtins)[QUASISYNTAX]: Initialize it, add to environment.
* quasiquote.c (add_unsyntaxers): Use it.
  (vm_eval_quasisyntax): New function.
  (eval_quasisyntax): Use it.
2016-12-16 15:10:03 +01:00
Jan Nieuwenhuizen 89f771f18a Support #\alarm, #\vtab.
* mes.c (char_alarm): New variable.
  (char_vtab): Rename from char_vt.
* reader.c (read_character): Add alarm, update vtab.
* display.c (display): Likewise.
* module/language/c/lexer.mes (read-string): Use vtab.
2016-12-18 15:21:05 +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 46a617f16e core: Support keywords.
* display.c (display): Handle keyword.
* mes.c (type_t): Add KEYWORD.
  (eq_p): Handle it.
  (make_keyword): New function.
* reader.c (lookup): Use it.
* type.c (keyword_p): New function.
* NEWS: Update.
2016-12-16 23:30:33 +01:00