Jan Nieuwenhuizen
b354da6f02
mes: getopt-long: fix multi-opt and unclumping.
...
* module/mes/getopt-long.scm (remove-if-not): Remove.
(option-spec): Add value field. Update users.
(expand-clumped-singles): Simplify, fix.
(process-options): To get an option's value, use value instead of
value-policy. Fixes multi-opt.
* tests/getopt-long.test: New file.
* make.scm (mes-tests): Add it.
* check.sh (tests): Add it.
* tests/getopt-long.test-guile: New symlink.
2018-01-02 07:05:41 +01:00
Jan Nieuwenhuizen
4dfad613bf
mes: Support equal? with arbitrary number of arguments.
...
* module/mes/base.mes (equal2?): Rename from equal?.
(equal?): Implement.
2018-01-01 23:00:01 +01:00
Jan Nieuwenhuizen
72a4f7eba2
mescc: Use records for mes too.
...
* module/language/c99/info.mes: Use info.scm records, remove
simplistic list data structures.
2018-01-01 22:21:15 +01:00
Jan Nieuwenhuizen
c096a81cb5
mescc.mes: Use write for preprocessing output.
...
* scripts/mescc.mes (source->ast): Use core:write instead of pretty-print.
2018-01-01 21:13:46 +01:00
Jan Nieuwenhuizen
81404179c1
mes: Add write, core:write.
...
* src/lib.c (display_helper, fdisplay_): Add parameter, write_p.
Update callers. When write_p: write quoted strings.
(write_, write_port_): New function.
* module/mes/read-0.mes (write): New function.
2018-01-01 21:10:15 +01:00
Jan Nieuwenhuizen
1601bc18cc
mes: Add string-null?.
...
* module/srfi/srfi-13.mes (string-null?): New function.
2018-01-01 16:41:15 +01:00
Jan Nieuwenhuizen
244d11a2af
mes: Add dirname.
...
* module/mes/guile.mes (dirname): New function.
2018-01-01 16:40:23 +01:00
Jan Nieuwenhuizen
08562b168d
test: Add syntax tests.
...
* tests/syntax.test: New file.
* tests/syntax.test-guile: New file.
fixup: 1b0696f9 (Jan Nieuwenhuizen 2018-01-01 15:53:13 +0100 40) , (lambda ()
2018-01-01 15:53:13 +01:00
Jan Nieuwenhuizen
562d91466c
Revert "mes: use array-based stack. WIP: will not survice gc."
...
This reverts commit 7fb653f68c2dbf8bc83cce4bd138439c600b538f.
2017-12-17 07:42:49 +01:00
Jan Nieuwenhuizen
da20d92c77
mes: use array-based stack. WIP: will not survice gc.
...
* src/mes.c (STACK_SIZE)[MES_ARRAY_STACK]: New variable.
(g_stack_array): New variable.
(g_stack): Change type to SCM*.
* (gc_push_frame)[MES_ARRAY_STACK]: Use g_stack_array, g_stack.
(gc_peek_frame): Likewise.
(gc_pop_frame): Likewise.
* src/gc.c (gc_check): Likewise.
(gc): Likewise.
2017-12-14 07:05:53 +01:00
Jan Nieuwenhuizen
0f042b6ea6
mes: Reimplement records.
...
* module/srfi/srfi-9.mes (define-record-type): New macro.
* AUTHORS: Update.
* module/mes/record-0.mes: Remove.
* module/mes/record.mes: Remove.
* module/srfi/srfi-9-psyntax.mes: Remove.
* module/srfi/srfi-9.scm: Remove.
* make.scm: Remove them.
2017-12-12 00:12:42 +01:00
Jan Nieuwenhuizen
eb0505300c
mes: Fix display of closure.
...
* module/mes/display.mes (display): Drop extra ( at start of *closure*, *circ*.
* src/lib.c (display_helper): Likewise.
2017-12-11 07:06:21 +01:00
Jan Nieuwenhuizen
30efe5ffbc
mes: Resurrect define, define-macro in C core.
...
* make.scm (bin.gcc, bin.mescc): Use MES_C_READER=1.
* src/mes.c (scm_symbol_define, scm_symbol_define_macro): New symbol.
(scm_vm_eval_define): New special.
(scm_symbol_c_define): New symbol.
(MAKE_MACRO): New define.
(eval_apply)[MES_C_DEFINE]: Handle define, define-macro.
(mes_symbols): Define %c-define for use in read-0.mes.
* module/mes/read-0.mes: Do not implement full scheme define if %c-define.
* module/mes/quasiquote.mes (sexp:define, env:define, env:macro): New function.
(define-macro): New macro. FIXME
* module/mes/psyntax.mes (define): New macro. FIXME
2017-12-09 08:24:38 +01:00
Jan Nieuwenhuizen
065cee9bda
mes: Fix initial display.
...
* module/mes/read-0.mes (display): Fix.
2017-12-10 15:51:35 +01:00
Jan Nieuwenhuizen
a2f6511f5e
mescc: Allow invoking git mescc.mes from elsewhere.
...
* src/mes.c (load_env): Look in MES_PREFIX too. Add debug printing.
* scripts/mescc.mes: Consider MES_PREFIX.
* guile/mescc.scm (%prefix): Consider MES_PREFIX.
* module/mes/base-0.mes (string->list): New function, move from type-0.mes.
(%moduledir): Consider MES_PREFIX.
* module/mes/type-0.mes (string->list): Remove.
2017-12-09 22:38:51 +01:00
Jan Nieuwenhuizen
ccddde9a84
mescc: Output performance hacks: use core:display.
...
* src/lib.c (display_): Write to g_stdout (WAS: STDOUT).
* module/mes/guile.scm (guile): Declare and export core:display core:display-error.
* module/mes/M1.mes (object->M1): Use core:display and string-append
instead of format.
* module/mes/guile.mes (with-input-from-string): Add debugging.
(open-input-string): Likewise.
(read-string): Likewise. Re-implement.
(drain-input): Use read-string.
2017-12-09 20:10:57 +01:00
Jan Nieuwenhuizen
572b45f4cd
mes: Nyacc support: substring/copy, substring/shared.
...
* module/srfi/srfi-13.mes (substring/copy, substring/shared): Define
to substring.
2017-12-09 22:45:38 +01:00
Jan Nieuwenhuizen
85b5422c35
mes: Nyacc support: Read old characters.
...
* src/reader.c (read_character)[MES_C_READER]: Support reading old
characters: #\bel, #\bs, #\vt.
2017-12-09 22:36:53 +01:00
Jan Nieuwenhuizen
6a4f601424
mescc: Use small, bootstrappable syntax rather than huge psyntax seed.
...
* module/nyacc/lex.mes (mes): Use syntax (WAS: psyntax).
* module/mes/pmatch.mes (mes): Likewise.
* module/nyacc/lang/c99/parser.mes (srfi-9): Use syntax (WAS: srfi-9-psyntax).
2017-12-09 10:55:46 +01:00
Jan Nieuwenhuizen
2aafee0163
mes: Fix for pmatch on bootstrappable syntax-rules.
...
* module/mes/pmatch.scm (ppat): Do not use let.
* tests/pmatch.test ("pmatch nyacc minimal", "pmatch nyacc"): Test it.
2017-12-09 15:04:32 +01:00
Jan Nieuwenhuizen
4ce75e8f4b
mescc: Tinycc support: Respect word size better.
...
* stage0/x86.M1 (movzwl_0x32(%ebp),%eax,movzwl_0x8(%ebp),%eax): New
define.
* module/mes/as-i386.mes (i386:push-word-local-de-ref,
i386:word-local->accu): New function.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (push-local-de-ref): Respect word size.
(ident->accu): Likewise.
2017-12-03 16:33:35 +01:00
Jan Nieuwenhuizen
3636818b1a
mescc: prefix string labels with _.
...
* module/mes/M1.mes (object->M1): Prefix string lables with _.
2017-12-02 14:04:41 +01:00
Jan Nieuwenhuizen
60b7048e21
mescc: prefix local labels with _.
...
* module/language/c99/compiler.mes (expr->accu): prefix local labels with _.
2017-12-02 12:59:07 +01:00
Jan Nieuwenhuizen
c3fdfedb20
mes: resurrect full reader in C core.
...
* module/mes/read-0.mes (defined?): New function.
(eat-whitespace, read-env, read-word, read-block-comment,
read-line-comment, read-list, read-character, read-hex, read-octal,
reader:read-string, lookup, read-hash, read-word): Only define if
not %c-reader.
* module/mes/base-0.mes (defined?): Remove.
* src/mes.c[MES_C_READER]: Set ARENA_SIZE=10000000.
(scm_symbol_quasiquote scm_symbol_unquote,
scm_symbol_unquote_splicing, scm_symbol_syntax,
scm_symbol_quasisyntax, scm_symbol_unsyntax,
scm_symbol_unsyntax_splicing): New symbol.
(scm_symbol_c_reader): New symbol.
(MAKE_KEYWORD)[MES_C_READER]: New define.
(mes_symbols): Define %c_reader.
* src/reader.c (read_word_)[MES_C_READER]: Extend to full Scheme
reader.
(eat_whitespace)[MES_C_READER]: Likewise.
(read_block_comment, read_hash, read_word, read_character,
read_octal, read_hex, append_char, read_string)[MES_C_READER]:
Likewise.
* make.scm (bin.gcc,bin.mescc): Define MES_C_READER=1.
2017-11-29 21:42:50 +01:00
Jan Nieuwenhuizen
74c4197467
mescc: Mescc-tools support: char foo[BAR] = {'a', 'b', 'c'}.
...
* stage0/x86.M1 (mov____%al,0x8(%ebp), mov____%al,0x32(%ebp),
mov____%ax,0x8(%ebp), mov____%ax,0x32(%ebp)): New define.
* module/mes/as-i386.mes (i386:accu->local+n,i386:byte-accu->local+n,
i386:word-accu->local+n): New function.
* module/language/c99/compiler.mes (accu->local+n): New function.
(initzer->data): Return char as single byte.
(decl->info): Support char foo[BAR] = {'a', 'b', 'c'}.
* scaffold/tests/66-local-char-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-11-27 19:51:18 +01:00
Jan Nieuwenhuizen
0fa18b338d
build: mlib/include to include, move mlib to lib.
...
* include: Move from mlib/include.
* lib: Move from mlib.
* BOOTSTRAP: Update.
* HACKING: Update.
* guile/guix/make.scm: Update.
* make.scm: Update.
* module/language/c99/compiler.mes: Update.
2017-11-22 16:23:48 +01:00
Jan Nieuwenhuizen
7fb74feb46
mes: resurrect running MesCC: handle \t in strings.
...
* module/mes/read-0.mes (reader:read-string): Handle \t. Fixex M1 output.
2017-11-20 23:22:53 +01:00
Jan Nieuwenhuizen
e81cb61b87
mes: Nyacc support: with-fluids.
...
* module/mes/fluids.mes (with-fluids): New macro.
* tests/fluids.test ("with-fluids"): Test it.
2017-11-20 23:21:25 +01:00
Jan Nieuwenhuizen
448b167c09
mes: resurrect running MesCC: update info interface.
...
* module/language/c99/info.mes (type?, global?, local?): New function.
(make-global): Remove name parameter.
* module/nyacc/lang/c99/pprint.mes: New file.
2017-11-20 23:17:50 +01:00
Jan Nieuwenhuizen
761ea8b23f
mes: Add last.
...
* module/srfi/srfi-1.mes (last): New funcion.
2017-12-17 13:32:17 +01:00
Jan Nieuwenhuizen
fc0e0a732f
mes: Add reverse-list->string.
...
* module/srfi/srfi-13.mes (reverse-list->string): New function.
2017-11-20 06:49:27 +01:00
Jan Nieuwenhuizen
302282dcdb
Revert "mescc: Grok char foo[] parameter."
...
This reverts commit c4cc75105db48b550cd515751b766b2e7a88ddc3.
2017-11-19 20:50:06 +01:00
Jan Nieuwenhuizen
cb90e51068
mescc: Grok char foo[] parameter.
...
* module/language/c99/compiler.mes (function->text+data): Grok char
foo[] parameter.
2017-11-19 19:59:18 +01:00
Jan Nieuwenhuizen
e77e56c5b0
mescc: Grok char *const foo[];
...
* module/language/c99/compiler.mes (ast-strip-const): Grok char *const argv[];
2017-11-19 16:46:43 +01:00
Jan Nieuwenhuizen
66a78f68cb
mescc: cleanup obsolete Nyacc 0.7x compatibility.
...
* module/language/c99/compiler.mes (ast-type->type, ast->type
expr->accu, struct-field, decl->info,): Remove obsolete Nyacc 0.7x
patterns.
2017-11-18 21:05:43 +01:00
Jan Nieuwenhuizen
02e70486a1
mescc: Tinycc support: struct struct array.
...
Support
struct foo
{
struct bar baz[N];
struct bar bla*[M];
};
* module/language/c99/compiler.mes (expr->accu):
* scaffold/tests/7n-struct-struct-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-11-17 15:24:45 +01:00
Jan Nieuwenhuizen
67afa2a397
mescc: Tinycc support: empty for.
...
* module/language/c99/compiler.mes (test-jump-label->info): Handle
empty expression.
* make.scm (add-tcc-test "45_empty_for"): Test it.
2017-11-16 05:52:47 +01:00
Jan Nieuwenhuizen
b24fcbad60
mescc: Tinycc support: workaround lack of long long support.
...
* module/language/c99/compiler.mes (i386:type-alist): Use size=4 for
long long as a workaround.
2017-11-14 19:39:46 +01:00
Jan Nieuwenhuizen
dc65de59ce
mescc: refactor expr->accu, expr->accu*, fixes nontrivial struct by value assign.
...
* module/language/c99/compiler.mes: (pke): New function.
(expr->number): Rename from p-expr->number. Update callers.
(decl->info, init-declr->pointer, struct-field): Several pointeryness fixes.
(expr->accu*, expr->accu): Remove special-casing for foo.bar,
foo->bar, foo[bar]. Fixes struct by value assign for non-trival
expressions.
(accu->ident, ident-address->accu, ident->accu):
(base->ident-address, ident->base): Remove.
* scaffold/tests/7k-for-each-elem.c (test): Test it.
* scaffold/tests/7c-dynarray.c (test): Test it.
* scaffold/tests/7m-struct-char-array-assign.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-11-11 13:45:53 +01:00
Jan Nieuwenhuizen
66204d56c0
mescc: Support Nyacc-0.81.0.
...
* module/language/c99/compiler.mes (ast->info): Handle asm-expr from
Nyacc 0.81.0.
2017-09-10 21:09:23 +02:00
Jan Nieuwenhuizen
9555d90174
mescc: Tinycc support: struct by value assign.
...
* module/language/c99/compiler.mes (expr->accu): warn for unsupported
sizes.
* scaffold/tests/7h-struct-assign.c (test): Test it.
2017-09-10 16:59:53 +02:00
Jan Nieuwenhuizen
7619190d5c
build: compile crt1.c, libc-mesc.c and <input>.c separately.
...
* mlibc/crt1.c: New file.
* mlibc/libc-mes.c (_start): Remove.
* mlibc/libc-gcc.c (_start): Remove.
* make.scm (LINK.hex2, bin.mescc): Move from guile/guix/make.scm.
* guile/guix/make.scm (LINK.hex2, bin.mescc): Remove.
2017-09-10 16:59:43 +02:00
Jan Nieuwenhuizen
3560ee6c95
mescc: Tinycc support: fix *--p = 'x'.
...
* module/language/c99/compiler.mes (expr->accu): Respect size in *--p = 'x'.
* scaffold/tests/23-pointer.c (test): Test it.
2017-08-27 16:58:56 +02:00
Jan Nieuwenhuizen
19ea4fa268
mescc: Tinycc support: initializer arithmetic.
...
* module/language/c99/compiler.mes (p-expr->bool): New function
(p-expr->number): Support bitwise-and, bitwise-not, cast, cond-expr.
2017-08-27 12:57:50 +02:00
Jan Nieuwenhuizen
989bfdbd25
mescc: Tinycc support: array of struct of any size.
...
* module/language/c99/compiler.mes (accu*value): New function
(expr->accu*): Use it to support array of struct of any size.
* scaffold/tests/7l-struct-any-size-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-08-27 11:23:45 +02:00
Jan Nieuwenhuizen
69073e1954
mescc: Tinycc support: pointer arithmetic with pointer-variable.
...
* module/language/c99/compiler.mes (expr->accu): pointer arithmetic with pointer-variable.
* scaffold/tests/76-pointer-arithmetic.c (test): Test it.
* mlibc/include/stdarg.h (va_start): Update for fixed pointer arithmetic.
2017-08-26 10:16:53 +02:00
Jan Nieuwenhuizen
8649f7a923
mescc: Tinycc support: pointer arithmetic with &variable.
...
* module/language/c99/compiler.mes (expr->pointer): Handle ref.
* scaffold/tests/76-pointer-arithmetic.c: Test it.
2017-08-25 06:58:15 +02:00
Jan Nieuwenhuizen
0875ce655a
mescc: Tinycc support: pointer arithmetic with variable.
...
* module/language/c99/compiler.mes (expr->accu): Support pointer
arithmetic with variable: p + i, p - i, p += i, p -= i.
* scaffold/tests/76-pointer-arithmetic.c (test): Test it.
2017-08-23 07:08:16 +02:00
Jan Nieuwenhuizen
1e23dbaf17
mescc: Tinycc support: handle pointerness, siziness for cast foo*.
...
* module/language/c99/compiler.mes (expr->pointer): Support cast foo*.
(expr->size): Likewise.
* scaffold/tests/7k-for-each-elem.c: Test it
* make.scm (add-scaffold-test): Build it.
2017-08-23 06:55:25 +02:00
Jan Nieuwenhuizen
3392f7241a
mescc: Tinycc support: struct.struct.
...
* module/language/c99/compiler.mes (field:name):
(field:pointer):
(field:size):
(field:type):
(field-field):
(field-offset):
(struct-field): Support struct.struct.
* scaffold/tests/7i-struct-struct.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-08-10 21:36:49 +02:00