mes.git
4 years agomescc: Scaffolding of Nyacc compile experiments.
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.

4 years agomescc: Nyacc updates, factor-out elf-util.
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.

4 years agomescc: Use Nyacc frontend.
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.

4 years agoscm: Avoid xpath's shadowing of filter.
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.

4 years agonyacc: fixes didn't get in in 0.74.0
Matt Wette [Mon, 9 Jan 2017 00:59:20 +0000 (16:59 -0800)]
nyacc: fixes didn't get in in 0.74.0

4 years agonyacc: ugh. fixes did not take, why?
Matt Wette [Mon, 9 Jan 2017 00:56:24 +0000 (16:56 -0800)]
nyacc: ugh. fixes did not take, why?

4 years agonyacc: new release 0.74.0
Matt Wette [Sun, 8 Jan 2017 21:06:33 +0000 (13:06 -0800)]
nyacc: new release 0.74.0

4 years agonyacc: minor fixes
Matt Wette [Sun, 8 Jan 2017 21:00:57 +0000 (13:00 -0800)]
nyacc: minor fixes

4 years agonyacc: lots of C99/CPP fixes. now more robust for code mode
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

4 years agonyacc: lots of fixes to make CPP more robust; now need to test
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

4 years agonyacc: updates for cpp-ok/not-ok
Matt Wette [Fri, 6 Jan 2017 16:03:41 +0000 (08:03 -0800)]
nyacc: updates for cpp-ok/not-ok

4 years agonyacc: fixed c99/CPP bug: need to skip space before lparen
Matt Wette [Mon, 2 Jan 2017 15:42:23 +0000 (07:42 -0800)]
nyacc: fixed c99/CPP bug: need to skip space before lparen

4 years agonyacc: have something working for in-place include
Matt Wette [Mon, 2 Jan 2017 03:40:27 +0000 (19:40 -0800)]
nyacc: have something working for in-place include

4 years agonyacc: working on cpp-include fix
Matt Wette [Sun, 1 Jan 2017 15:54:21 +0000 (07:54 -0800)]
nyacc: working on cpp-include fix

4 years agonyacc: creating fixes for 0.73.0
Matt Wette [Sat, 31 Dec 2016 16:33:07 +0000 (08:33 -0800)]
nyacc: creating fixes for 0.73.0

4 years agonyacc: new release 0.73.0
Matt Wette [Mon, 26 Dec 2016 03:34:40 +0000 (19:34 -0800)]
nyacc: new release 0.73.0

4 years agonyacc: misc updates; see ChangeLog
Matt Wette [Mon, 26 Dec 2016 03:31:09 +0000 (19:31 -0800)]
nyacc: misc updates; see ChangeLog

4 years agonyacc: multiple fixes
Matt Wette [Sat, 3 Dec 2016 15:19:35 +0000 (07:19 -0800)]
nyacc: multiple fixes

5 years agonyacc: starting devel on 0.72.0
Matt Wette [Tue, 9 Aug 2016 12:45:52 +0000 (05:45 -0700)]
nyacc: starting devel on 0.72.0

4 years agonyacc: Move README.nyacc.
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.

4 years agonyacc: Add README.nyacc.
Jan Nieuwenhuizen [Mon, 26 Dec 2016 07:05:00 +0000 (08:05 +0100)]
nyacc: Add README.nyacc.

* README.nyacc: New file.

4 years agotests: Move (ice-9 syncase) into cond-expand.
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.

4 years agonyacc: Move (ice-9 syncase) into cond-expand.
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.

4 years agocore: Move GNUisms inside #if.
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.

4 years agorepl: Fix expand in repl.
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.

4 years agoscm: Error throws rather than hard exit.
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.

4 years agorepl: Use exception handling.
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.

4 years agocore: Throw exceptions rather than asserts.
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.

4 years agocore+scm: Implement exception handling.
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.

4 years agoRevert "core: Display me debuggor CPS+CC."
Jan Nieuwenhuizen [Wed, 28 Dec 2016 15:37:06 +0000 (16:37 +0100)]
Revert "core: Display me debuggor CPS+CC."

This reverts commit 6c327b5bdceae6fc59ac8cce4aed99ea0a491846.

4 years agocore: Display me debuggor CPS+CC.
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.

4 years agocore: Add continuations, call/cc.
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.

4 years agocore: Rewrite eval_apply in continuation passing style.
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.

4 years agoSupport radix for string->number, number->string.
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.

4 years agoAdd string-take, string-drop.
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.

4 years agocore: Stderr_ also print numbers.
Jan Nieuwenhuizen [Wed, 4 Jan 2017 19:22:31 +0000 (20:22 +0100)]
core: Stderr_ also print numbers.

* posix.c (stderr_): Handle numbers.

4 years agoBugfixes bytevectors.
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.

4 years agoAppend-map: handle multiple list.
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.

4 years agocore: Move GNUisms inside #if.
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.

4 years agoAdd drain-input.
Jan Nieuwenhuizen [Tue, 3 Jan 2017 22:46:44 +0000 (23:46 +0100)]
Add drain-input.

* module/mes/guile.mes (drain-input): New function.

4 years agoBugfix for reading #\*eof* character.
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*.

4 years agocore: Expose command line.
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.

4 years agoInclude srfi-13 in base.
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.

4 years agoAdd filter-map.
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.

4 years agoAdd srfi-1:iota.
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.

4 years agoAdd pretty-print from Guile.
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.

4 years agoAdd make-string, object->string.
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.

4 years agoAdd list-set!, string-set!
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.

4 years agoFix core:car, core:cdr for specials.
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.

4 years agocore: Add continuation on stack.
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.

4 years agocore: Uniformize calling of apply.
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.

4 years agocore: Refactor stack handling.
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.

4 years agoAdd simple-format.
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.

4 years agoDisplay: If possible, show name of closure.
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.

4 years agoUpdate documentation.
Jan Nieuwenhuizen [Sun, 25 Dec 2016 15:43:28 +0000 (16:43 +0100)]
Update documentation.

* doc/ANNOUNCE-0.4: New file.
* NEWS: Typo.

4 years agoguix hash: 1jpm8m8y2dqsl3sc6flf8da4rpdrqh6zgr2mghzjw0lg34v1r21j
Jan Nieuwenhuizen [Sun, 25 Dec 2016 15:30:53 +0000 (16:30 +0100)]
guix hash: 1jpm8m8y2dqsl3sc6flf8da4rpdrqh6zgr2mghzjw0lg34v1r21j

4 years agoRelease 0.4. v0.4
Jan Nieuwenhuizen [Sun, 25 Dec 2016 14:51:53 +0000 (15:51 +0100)]
Release 0.4.

* configure (VERSION): Bump.

4 years agoRemove hardcoded duplication of version.
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.

4 years agoUpdate documentation.
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.

4 years agomake: Install nyacc scripts too.
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.

4 years agoRevert "core: Display me debuggor."
Jan Nieuwenhuizen [Sun, 25 Dec 2016 10:54:14 +0000 (11:54 +0100)]
Revert "core: Display me debuggor."

This reverts commit 53ec23a0edcfdcb7dd4e32277e5a24e0a8fab5dd.

4 years agocore: Display me debuggor.
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.

4 years agoRevert "core: FAT_C_READER: Show your speed."
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.

4 years agocore: FAT_C_READER: Show your speed.
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.

4 years agoRefactor reader.
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.

4 years agocore: Remove c3+r abbreviatons.
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.

4 years agocore: Move dump, load, bload to lib.c.
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.

4 years agocore: Add getenv, verbose module loading on MES_DEBUG.
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.

4 years agocore: Add some error checking.
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.

4 years agocore: Move reader and posix functions from mes.c
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.

4 years agocore: Remove unused symbols.
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.

4 years agoAdd write, add display test, some fixes.
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.

4 years agocore: Remove display.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 00:23:50 +0000 (01:23 +0100)]
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.

4 years agoImport srfi-26 from Guile.
Jan Nieuwenhuizen [Sat, 24 Dec 2016 07:34:19 +0000 (08:34 +0100)]
Import srfi-26 from Guile.

* module/srfi/srfi-26.scm: Import.
* module/srfi/srfi-26.mes: Include it.
* AUTHORS: Mention it.

4 years agocore: Remove symbol_to_list, char_to_integer, integer_to_char.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 22:25:49 +0000 (23:25 +0100)]
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.

4 years agocore: Remove string.c.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 21:48:27 +0000 (22:48 +0100)]
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.

4 years agocore: Remove number_to_string.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 21:08:03 +0000 (22:08 +0100)]
core: Remove number_to_string.

* string.c (number_to_string): Remove.
* module/mes/scm.mes (number->string): New function.

4 years agocore: Remove substring.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 20:44:54 +0000 (21:44 +0100)]
core: Remove substring.

* string.c (substring): Remove.
* module/mes/scm.mes (substring): New function.

4 years agocore: Remove string_length.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 20:26:16 +0000 (21:26 +0100)]
core: Remove string_length.

* module/mes/scm.mes (string-length): New function.

4 years agocore: Remove list_to_string.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 20:21:54 +0000 (21:21 +0100)]
core: Remove list_to_string.

* string.c (list_to_string): Remove.
* module/mes/read-0.mes (list->string): New function.
* module/mes/scm.mes (list->string): Remove.

4 years agocore: Remove string-append.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 19:56:37 +0000 (20:56 +0100)]
core: Remove string-append.

* string.c (string_append): Remove.
* module/mes/type-0.mes (string-append): New function.
* module/mes/base-0.mes: Include type-0 without using string-append.

4 years agocore: Remove string.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 19:44:04 +0000 (20:44 +0100)]
core: Remove string.

* string.c (string): Remove.
* module/mes/type-0.mes (string): New function.

4 years agoAdd exit.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 19:31:45 +0000 (20:31 +0100)]
Add exit.

* lib.c (exit_): Rename from builtin_exit.
* module/mes/scm.mes (list): Remove.

4 years agocore: Remove last_pair, list_ref, string_ref.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 19:09:57 +0000 (20:09 +0100)]
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.

4 years agocore: Make closure real type.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 17:48:36 +0000 (18:48 +0100)]
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.

4 years agocore: Remove quote, quasiquote, quasisyntax.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 17:11:46 +0000 (18:11 +0100)]
core: Remove quote, quasiquote, quasisyntax.

* mes.c (quote, quasiquote, quasisyntax): Remove.

4 years agocore: Remove make_lambda.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 17:10:31 +0000 (18:10 +0100)]
core: Remove make_lambda.

* mes.c (make_lambda): Remove.

4 years agocore: Remove type.c.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 17:05:45 +0000 (18:05 +0100)]
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.

4 years agocore: Remove gc_show.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 16:05:04 +0000 (17:05 +0100)]
core: Remove gc_show.

* mes.c (gc_show): Remove.

4 years agocore: Remove add_environment.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 16:02:23 +0000 (17:02 +0100)]
core: Remove add_environment.

* mes.c (add_environment): Remove.  Update callers.
  (scm_symbol_dot): New global.

4 years agocore: Remove make_string.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 15:38:07 +0000 (16:38 +0100)]
core: Remove make_string.

* mes.c (MAKE_STRING): New macro.
  (make_string): Remove.  Update callers.
* string.c: Update callers.

4 years agocore: Remove make_ref.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 15:31:56 +0000 (16:31 +0100)]
core: Remove make_ref.

* mes.c (MAKE_REF): New macro.
  (make_ref): Remove.  Update callers.

4 years agocore: Remove make_char.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 15:26:00 +0000 (16:26 +0100)]
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.

4 years agocore: Remove make_number.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 15:22:19 +0000 (16:22 +0100)]
core: Remove make_number.

* mes.c (MAKE_NUMBER): New macro.
  (tmp_num_, tmp_num_2): New function.
  (make_number): Remove.  Update callers.

4 years agoRemove make_function.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 15:02:36 +0000 (16:02 +0100)]
Remove make_function.

* mes.c (make_function): Remove.

4 years agocore: Remove make_keyword.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 14:53:57 +0000 (15:53 +0100)]
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.

4 years agocore: Remove make_macro.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 14:47:52 +0000 (15:47 +0100)]
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.

4 years agocore: Simplify lookup.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 10:31:34 +0000 (11:31 +0100)]
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.

4 years agoRemove lookup-char.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 10:26:35 +0000 (11:26 +0100)]
Remove lookup-char.

* reader.c (lookup_char): Remove.
* module/mes/read-0.mes (lookup-char): Remove.
  (read-word): Rewrite using quote.

4 years agocore: Cleanup symbol initialization and lookup.
Jan Nieuwenhuizen [Fri, 23 Dec 2016 09:38:41 +0000 (10:38 +0100)]
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.