Jan Nieuwenhuizen
dd52f580fb
mescc: Compile all of mini-mes.
...
* module/language/c99/compiler.mes (case->jump-info): Support single statement.
* module/mes/elf-util.mes (function-prefix): Workaround for reversed
functions. FIXME!
* module/mes/elf.mes:
* scaffold/mini-mes.c (type_t): Rename FUNCTION to TFUNCTION for Nyacc.
Add missing symbols.
(eval_apply): Uncomment most.
* scaffold/tiny-mes.c:
* scaffold/cons-mes.c: Remove cruft.
2017-03-06 07:14:15 +01:00
Jan Nieuwenhuizen
07c4b02fa3
mescc: Fixes for goto.
...
* module/mes/libc-i386.mes (XXjump): New function.
* module/mes/libc-i386.scm: Export it.
* module/language/c99/compiler.mes (case->jump-info, ast->info): Use it.
* scaffold/t.c: Test it.
* GNUmakefile (cons-mes): New target.
* scaffold/cons-mes.c: New file.
* scaffold/mini-mes.c:
2017-04-02 12:13:04 +02:00
Jan Nieuwenhuizen
c210959c49
mescc: Read and display sexp dumped by mes.
...
* lib.c (dump)[MES_HACK]: Dump small hello-world sexp, to be handled by
* doc/examples/tiny-mes.c (display_): New function.
* module/mes/libc-i386.mes (i386:accu->base, i386:mem->accu,
i386:mem+n->accu): New functions.
* module/mes/libc-i386.scm: Export them.
* GNUmakefile (mes-32): New target.
2017-01-10 20:05:47 +01:00
Jan Nieuwenhuizen
6ffca4bf61
mescc: Add open/read C-tests.
...
* scaffold/m.c: New file.
* scaffold/tiny-mes.c: New file.
* GNUmakefile (m, tiny-mes): New targets.
* scaffold/micro-mes.c: Update gcc-libc bits.
* scaffold/mini-mes.c: Likewise.
2017-04-02 12:10:38 +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
107795b13c
mescc: Compile specific for loop.
...
* module/language/c99/compiler.mes (ast->info): Handle for, pre-inc.
* GNUmakefile (main): New target.
* doc/examples/main.c:
(exit, write, strlen,puts)[__GNUC__]: New functions; import from micro-mes.c
(_start): New function.
2017-01-05 21:24:56 +01:00
Jan Nieuwenhuizen
8989dab8b0
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.
2017-04-02 12:01:33 +02:00
Jan Nieuwenhuizen
7ec42c3cc7
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.
2016-12-31 09:03:07 +01:00
Jan Nieuwenhuizen
04bb0cb79d
Revert "core: Display me debuggor CPS+CC."
...
This reverts commit 6c327b5bdceae6fc59ac8cce4aed99ea0a491846.
2016-12-28 16:37:06 +01:00
Jan Nieuwenhuizen
134f39ce22
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.
2016-12-28 16:35:12 +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
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
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
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
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
8a78f45e25
Use include-from-path for psyntax.pp.
...
* module/mes/psyntax.pp: Rename from module/mes/psyntax-pp.mes.
* module/mes/psyntax.mes: Update.
* AUTHORS: Update.
2016-12-22 19:49:41 +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
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
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
c9c44ad63f
Add Nyacc example scripts.
...
* guile/nyacc-calc.scm: New file.
* guile/nyacc.scm: New file.
* scripts/nyacc-calc.mes: New file.
* scripts/nyacc.mes: New file.
* GNUmakefile (mes-check, guile-check): Run them.
2016-12-18 15:44:09 +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
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
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
d4dc29c498
Resurrect guile-mescc with guile-2.1.5.
...
* scripts/include.mes: Grep all files.
* GNUmakefile (mescc.cat): Update for mes-use-module; list all toplevel inputs.
* module/language/c/lexer.mes: Use (system base lalr).
* module/language/c/parser.mes: Likewise.
* module/language/c/compiler.mes: Likewise. Remove encoding on output port.
* scripts/mescc.mes: Remove BROKEN comment.
2016-12-17 10:57:38 +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
1aba68dc6a
Silence garbage collector.
...
* GNUmakefile: unexport MES_DEBUG.
2016-12-13 20:55:50 +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
b92a8f17f8
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.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
e4e29f00b0
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.
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
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
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
db2eb86a40
test: Run psyntax before record.
...
* GNUmakefile (TESTS): Run psyntax before record.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
70bdab7090
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.
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
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
d18542e25f
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.
2016-12-12 20:33:49 +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
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