Jan Nieuwenhuizen
8d1e001ab2
mescc: Have micro-mes use strcmp to print help.
...
* doc/examples/micro-mes.c (main): Add --help.
* module/language/c99/compiler.mes (info?): New function.
(expr->accu): Handle function call and sub.
(ast->info): Handle if not, and, de-ref, eq, sub, return f ().
* module/mes/libc-i386.mes (i386:accu-zero?, i386:Xmem-byte->accu,
i386:Xmem-byte->base, i386:jump-byte-nz, i386:jump-byte-z,
i386:test-byte-base, i386:Xjump-byte-z, i386:sub-byte-base): New
functions.
* module/mes/libc-i386.scm: Export them.
2017-01-06 00:20:05 +01: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
4a3e419e30
mescc: Refactor compiler.
...
* module/language/c99/compiler.mes (make, clone): Lightweight functional
GOOPS-like list-based info structure.
(make-text+globals+locals): Remove.
(ast->info): Rename from statement->text+globals+locals, refactor.
Update callers.
(function->info): Rename from function->globals, refactor. Update
callers.
(ast-list->info): New function.
2017-01-05 00:55:46 +01:00
Jan Nieuwenhuizen
21a6f2ca52
scm: Fix psyntax/keyword/optargs interaction bug.
...
* module/mes/psyntax-0.mes (self-evaluating?): Add keyword?.
* module/mes/pmatch.mes (mes): Add missing psyntax dependency.
* module/mes/optargs.scm (rest-arg->keyword-binding-list): Make error
messages non-constant.
* tests/optargs.test ("clone <info>"): New test.
2017-01-07 01:08:29 +01:00
Jan Nieuwenhuizen
c60f19e041
mescc: Compile file supplied on command line.
...
* scripts/mecc.mes: Pass (command-line) to main.
2017-01-03 23:48:12 +01:00
Jan Nieuwenhuizen
3c35f59e63
nyacc: Add cpp to c99 mes module.
...
* module/nyacc/lang/c99/parser.mes: Include (nyacc lang c99 cpp).
2017-01-03 22:12:12 +01:00
Jan Nieuwenhuizen
f106dbfdae
mescc: Rename symbols to globals.
...
* module/language/c99/compiler.mes:
2017-01-03 18:34:49 +01:00
Jan Nieuwenhuizen
38dc229a01
mescc: Have micro-mes use if not to segfault.
...
* module/language/c99/compiler.mes (write-any): Check explicitly on
number?, report error otherwise.
(statement->text+symbols+locals): Remove statement-offset.
Handle compounds. Handle very specific if.
(function->symbols): Remove unused text-offset.
* doc/examples/micro-mes.c (main): If argc > 1 print argv1. Fixes
segfault :-)
* module/mes/elf-util.mes (symbols->text): Loop rather than map,
feed text-offset.
* module/mes/libc-i386.mes (i386:local-test, i386:jump-le): New
functions.
* module/mes/libc-i386.scm: Export them.
2017-01-03 18:22:56 +01:00
Jan Nieuwenhuizen
296449c615
mescc: Have micro-mes print argv.
...
* module/language/c99/compiler.mes (expr->arg): Bugfix argv: Use
size=4 (int).
(statement->text+symbols+locals): Bugfixes: array-ref, initialize with
immediate, initialize with local.
(formals->locals): Bugfix: formals counted down from -1 [WAS: down to
-1].
* module/mes/libc-i386.mes (i386:call): Reverse args pushes to match
formals index changes.
(i386:write): Update for changed formals push order.
(i386:mem->accu, i386:value->accu): New functions.
* module/mes/libc-i386.scm (mes): Export them.
* doc/examples/micro-mes.c (eputs, puts, fputs): Make identical with
mescc's implementations.
(main): Print argv[0] and (unconditionally; crash if not given) argv[1].
2017-01-03 12:33:34 +01:00
Jan Nieuwenhuizen
01177f7324
mescc: Have micro-mes print argc.
...
* module/language/c99/compiler.mes (accu->ident): New function.
(statement->text+symbols+locals): Use it to implement initialization
with immediate, local.
(_start): Call main with argc,argv [WAS: 0,0].
* module/mes/libc-i386.mes (i386:push-accu, i386:accu->local): New
functions.
* module/mes/libc-i386.scm: Export them.
* doc/examples/micro-mes.c (main): Return argc as exit status.
2017-01-03 12:52:59 +01:00
Jan Nieuwenhuizen
b93d5188ea
mescc: Support literal .byte in asm ().
...
* module/language/c99/compiler.mes (expr->arg): Handle array-ref (int
only).
(byte->hex, asm->hex): New functions.
(statement->text+symbols+locals): Use it to implement asm ().
2017-01-03 12:45:47 +01:00
Jan Nieuwenhuizen
ea7e3f4952
mescc: Remove data section from disassembly.
...
* module/mes/elf.mes (make-elf): Remove executable bit from data.
2017-01-03 12:43:00 +01:00
Jan Nieuwenhuizen
109cbdd1e7
mescc: Formals, local variables.
...
* module/language/c99/compiler.mes (statement->text+symbols+locals):
Rename from statement->text+symbols. Handle locals.
(formals->text): Add proper function preamble.
(formals->locals): Add formals as locals.
(expr->accu, ident->accu, ident->base, ident-ref, global-ref): New
functions.
(strlen, eputs, fputs, puts): New functions.
(libc): New variable.
(i386:libc): Rename from libc. Remove eputs and puts.
* module/mes/libc-i386.mes (i386:eputs, i386:puts: Remove.
(i386:call, i386:ret): Handle locals as argument.
(i386:function-locals, i386:function-preamble, i386:jump,
i386:local->accu, i386:local-add, i386:local-assign,
i386:local->base, i386:ref-global, i386:ref-local, i386:ret-local,
i386:mem-byte->accu, i386:test-jump, i386:write): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-02 23:21:33 +01:00
Jan Nieuwenhuizen
57e11b3147
mescc: Nicer functions/parameters.
...
* module/mes/libc-i386.mes (eputs, exit, puts): Save stack pointer,
fill parameter registers from stack.
* module/language/c99/compiler.mes (formal->text): Fill parameter
registers from stack memory.
(formals->text): Save stack pointer.
2017-01-02 07:41:56 +01:00
Jan Nieuwenhuizen
0315d42306
mini-mes: Parse with Nyacc.
...
* doc/examples/mini-mes.c: Parse with Nyacc.
2017-01-02 07:50:44 +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
eb3fed2a00
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.
2017-04-02 11:55:37 +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
cd44770258
scm: Avoid xpath's shadowing of filter.
...
* module/sxml/xpath.scm (xpath:filter): Rename from filter. Fixes
shadowing of core filter.
2017-01-03 22:18:22 +01:00
Matt Wette
5e988b4ebf
nyacc: fixes didn't get in in 0.74.0
2017-01-08 16:59:20 -08:00
Matt Wette
c5b99d79b7
nyacc: ugh. fixes did not take, why?
2017-01-08 16:56:24 -08:00
Matt Wette
16755c68b5
nyacc: new release 0.74.0
2017-01-08 13:06:33 -08:00
Matt Wette
cafdfbb0bb
nyacc: minor fixes
2017-01-08 13:00:57 -08:00
Matt Wette
9c32a41370
nyacc: lots of C99/CPP fixes. now more robust for code mode
2017-01-08 12:16:28 -08:00
Matt Wette
0b46949f48
nyacc: lots of fixes to make CPP more robust; now need to test
2017-01-07 16:06:09 -08:00
Matt Wette
baea80d962
nyacc: updates for cpp-ok/not-ok
2017-01-06 08:03:41 -08:00
Matt Wette
2df0f57a30
nyacc: fixed c99/CPP bug: need to skip space before lparen
2017-01-02 07:42:23 -08:00
Matt Wette
7b665385c9
nyacc: have something working for in-place include
2017-01-01 19:40:27 -08:00
Matt Wette
f5d1522166
nyacc: working on cpp-include fix
2017-01-01 07:54:21 -08:00
Matt Wette
6309b99aaa
nyacc: creating fixes for 0.73.0
2016-12-31 08:33:07 -08:00
Matt Wette
5251e707ab
nyacc: new release 0.73.0
2016-12-25 19:34:40 -08:00
Matt Wette
e589c81c8d
nyacc: misc updates; see ChangeLog
2016-12-25 19:31:09 -08:00
Matt Wette
4c4706f17e
nyacc: multiple fixes
2016-12-03 07:19:35 -08:00
Matt Wette
4d5102dffd
nyacc: starting devel on 0.72.0
2016-08-09 05:45:52 -07:00
Jan Nieuwenhuizen
1e8d27fb7d
nyacc: Move README.nyacc.
...
* module/nyacc/README.nyacc: Moved from README.nyacc.
2016-12-26 08:06:49 +01:00
Jan Nieuwenhuizen
fa0d10e121
nyacc: Add README.nyacc.
...
* README.nyacc: New file.
2016-12-26 08:05:00 +01:00
Jan Nieuwenhuizen
15518f92af
tests: Move (ice-9 syncase) into cond-expand.
...
* tests/psyntax.mes: Move (ice-9 syncase) into cond-expand. Fixes
guile-2 deprecation messages.
2016-12-25 22:48:06 +01:00
Jan Nieuwenhuizen
1a58dbe3c6
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.
2017-03-26 22:27:20 +02:00
Jan Nieuwenhuizen
43a1774750
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.
2017-01-04 08:16:14 +01:00
Jan Nieuwenhuizen
e74a7584e9
repl: Fix expand in repl.
...
* module/mes/repl.mes (repl): Fix expand. Remove sc-expand.
2017-01-22 01:35:33 +01:00
Jan Nieuwenhuizen
712403752d
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.
2017-01-04 00:11:47 +01:00
Jan Nieuwenhuizen
1f9476aeca
repl: Use exception handling.
...
* module/mes/repl.mes (repl): Use catch to prevent exit upon error.
2016-12-28 20:49:19 +01:00
Jan Nieuwenhuizen
cb1fa49767
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.
2016-12-28 22:26:33 +01:00
Jan Nieuwenhuizen
2675f711a3
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.
2016-12-28 22:26: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
d0f7db73f9
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.
2016-12-28 22:04:57 +01:00
Jan Nieuwenhuizen
b66cd8627c
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.
2016-12-28 21:55:42 +01:00
Jan Nieuwenhuizen
b83d583755
Support radix for string->number, number->string.
...
* module/mes/scm.mes (string->number, number->string): Support radix.
2017-01-04 21:45:32 +01:00
Jan Nieuwenhuizen
a0baa98196
Add string-take, string-drop.
...
* module/srfi/srfi-13.mes (string-take, string-drop): New functions.
2017-01-04 21:45:24 +01:00