Jan Nieuwenhuizen
0fab33da36
Revert "mes: un-defmacro optargs. WIP"
...
This reverts commit 5da527c540dc0e1481a010899233b4e806fe37da.
2018-01-07 14:52:09 +01:00
Jan Nieuwenhuizen
a8e8f0a1e3
mes: un-defmacro optargs. WIP
2018-01-06 09:29:11 +01:00
Jan Nieuwenhuizen
6f81fe41b0
mes: Add define-macro*.
...
* module/mes/optargs.mes (define-macro*): New macro.
2018-01-06 11:09:10 +01:00
Jan Nieuwenhuizen
5d68fc44ba
mes: Evaluate test of COND only once.
...
* module/mes/base-0.mes (cond): Evaluate test of COND only once.
Fixes cond tests with side effects (Nyacc).
* tests/base.test ("cond side effect"): Test it.
2018-01-05 10:01:50 +01:00
Jan Nieuwenhuizen
c60e79ae11
mes: #\page is whitespace.
...
* module/srfi/srfi-14.mes (char-set:whitespace): Add #\page.
2018-01-04 22:26:29 +01:00
Jan Nieuwenhuizen
cab272a101
mes: #<eof> is not a character.
...
* module/mes/display.mes (display):
* module/mes/type-0.mes (char?): -1 is not a character.
(eof-object?): New function.
* tests/base.test ("#<eof>"): Test it.
* module/mes/scm.mes (eof-object?): Remove.
(unread-char): Return character (WAS: integer).
2018-01-04 21:36:46 +01:00
Jan Nieuwenhuizen
0e06928320
mes: open-input-string: peek fix.
...
* module/mes/guile.mes (open-input-string): Return actual tell.
* tests/guile.test ("open-input-string peek"): Test it.
2018-01-04 19:32:35 +01:00
Jan Nieuwenhuizen
28d0c259ed
mes: with-input-from-string: peek fix.
...
* module/mes/guile.mes (with-input-from-string): Return actual tell.
* tests/guile.test ("with-input-from-string peek"): Test it.
2018-01-04 18:35:26 +01:00
Jan Nieuwenhuizen
fd13741eb3
mescc: Resurrect guile-1.8.
...
* guile/mescc.scm: Use GUILE_LOAD_COMPILED_PATH instead of -C.
[guile]: Include syncase.
* module/language/c99/compiler.scm [guile]: Stub pretty-print-c99.
Set stack to unlimited.
* module/language/c99/info.scm [guile]: Include (ice-9 syncase).
* module/mes/as-i386.scm [guile]: Likewise.
* module/mes/guile.scm [guile]: Add compose, export it.
2018-01-03 08:33:55 +01:00
Jan Nieuwenhuizen
c5f9623c55
mes: Add string-drop-right.
...
* module/srfi/srfi-13.mes (string-drop-right): New function.
2018-01-03 06:53:02 +01:00
Jan Nieuwenhuizen
1f8a217694
mescc: cleanups.
...
* guile/mescc.scm: Cleanups.
* module/language/c99/compiler.mes:
* module/language/c99/compiler.scm:
* module/language/c99/info.mes:
* module/language/c99/info.scm:
* module/mes/getopt-long.mes:
* module/mes/optargs.mes:
* module/mes/optargs.scm:
* module/mes/repl.mes:
* module/mes/scm.mes:
* scripts/mescc.mes:
2018-01-02 21:35:55 +01:00
Jan Nieuwenhuizen
5757ef3069
nyacc cpp-debugging, tests
2018-01-02 20:41:59 +01:00
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