Jan Nieuwenhuizen
4b349fabf1
mescc: Cache data-offset too.
...
* module/mes/elf-util.mes (data-offset): Add cache.
2017-03-18 08:58:15 +01:00
Jan Nieuwenhuizen
a14c3d937a
mescc: Support assignment with comparison.
...
* module/language/c99/compiler.mes (expr->accu): Handle assignment -> accu.
* doc/examples/t.c (test): Test it.
* doc/examples/mini-mes.c (eval_apply): Use it.
2017-03-18 08:25:15 +01:00
Jan Nieuwenhuizen
4c59078002
mescc: Support assignment test.
...
* module/language/c99/compiler.mes (test->jump->info): Handle assignment.
* doc/examples/t.c (test): Test it.
2017-03-18 08:17:18 +01:00
Jan Nieuwenhuizen
b22eee36df
mescc: Fix simple value tests.
...
* module/language/c99/compiler.mes (test->jump->info): Test accu
before jumping. Fixes simple value tests.
2017-03-17 23:49:29 +01:00
Jan Nieuwenhuizen
f03a2e7500
mescc: Struct by value.
...
* build-aux/mes-snarf.scm (symbol->names, function->header,
function->environment): Remove struct by value assignment
workarounds.
* module/language/c99/compiler.mes (ast->info): Remove struct by value
assignment debug printing.
2017-03-17 22:45:48 +01:00
Jan Nieuwenhuizen
a4d65166c0
mescc: Support generic initializer.
...
* module/language/c99/compiler.mes (ast->info): Support generic
declaration using initializer. Supports struct field initializer.
* doc/examples/t.c (struct_test): Test it.
* doc/examples/mini-mes.c (call_lambda, eval_apply, write_byte,
display_): Use it. (call_lambda): (eval_apply,
list_of_char_equal_p): Use it.
2017-03-17 17:54:37 +01:00
Jan Nieuwenhuizen
ddd880bdc8
mescc: Remove last hardcodings for identifiers.
...
* module/language/c99/compiler.mes (ident->accu, ident->base):
Use local:ptr, type->size to remove hard coding of functionx, c1.
(expr->accu): Use type->size to remove hard coding of size byte.
(decl->type): Also handle typename, bail out if type not found.
(type->size): Print identifier and and bail out if type not found.
(formal:ptr): New function.
(formals->locals): Use it to set pointer value of parameter. WAS: 0.
(ast->info): Remove functionx hardcoding.
(getchar): Rename c1 to c.
* doc/examples/t.c: Test it.
2017-03-17 17:32:23 +01:00
Jan Nieuwenhuizen
cbee04c4b8
mescc: Support function call with enum value.
...
* doc/examples/mini-mes.c: Remove debug printing.
* module/language/c99/compiler.mes (push-global, push-local,
push-global-address, push-local-address, push-local-de-ref): Return
list of lambda.
(push-ident): Support push constant. Fixes mini-mes,
cstring_to_list.
* doc/examples/t.c (test): Test it.
2017-03-17 08:37:45 +01:00
Jan Nieuwenhuizen
a2f180ba4a
mescc: Fix d-sel comparisons.
...
* module/language/c99/compiler.mes (ast->info): Save base while
computing accu. Fix comparison using d-sel in second argument.
* doc/examples/t.c: Test it.
* doc/examples/mini-mes.c (assq): Use it.
2017-03-14 00:15:13 +01:00
Jan Nieuwenhuizen
d039b00349
mescc: Fix for character array s[0].
...
* module/language/c99/compiler.mes (expr->arg, expr->accu, ast->info):
Use type size to calculate index.
* doc/examples/t.c: Test it.
* doc/examples/mini-mes.c (cstring_to_list): Simplify.
2017-03-13 19:38:38 +01:00
Jan Nieuwenhuizen
03c37b2e22
mescc: Support mini-mes running scheme program with builtins.
...
Mini-mes, compiled with either gcc or mescc, now runs a memory dump of
this mini-0.mes program
(begin
(write-byte (make-cell 0 0 65))
(write-byte (make-cell 0 0 66))
(write-byte (make-cell 0 0 67))
(write-byte (make-cell 0 0 10))
#f)
when read and dumped by (gcc-compiled) mes-32.
* build-aux/mes-snarf.scm: FIXES ..collapse?
* module/language/c99/compiler.mes (ast->info): Bail out on unhandled
declarations. Was: verbosely skip.
2017-03-12 12:02:12 +01:00
Jan Nieuwenhuizen
1322d99c22
mescc: Support [for] itoa.
...
* module/mes/libc-i386.mes (i386:accu%base): New function.
* module/mes/libc-i386.scm: Export it.
* module/language/c99/compiler.mes (expr->accu): Use it to support mod.
* doc/examples/t.c (itoa): New function.
(test): Test it.
* doc/examples/mini-mes.c (itoa)[!__GNUC__]: New function.
2017-03-12 11:05:20 +01:00
Jan Nieuwenhuizen
3268027e46
mescc: Support do .. while.
...
* module/language/c99/compiler.mes (ast->info): Support do-while.
* doc/examples/t.c (test): Test it.
2017-03-12 11:05:00 +01:00
Jan Nieuwenhuizen
76f1a89cef
core+mini-mes: Replace manual snippets by snarfed includes.
...
* build-aux/mes-snarf.scm (symbol->source, function->header,
function->source, function->environment): Add workarounds to
avoid struct-copy initializers.
* GNUmakefile (mini-mes): Snarf symbols and functions.
* scaffold/mini-mes.c: Include mini-mes.h, mini-mes.symbols.h,
mini-mes.symbols.i, mini-mes.i, mini-mes.environment.i.
Add snarfable symbol/special definitions.
(type_t): Prefix all types with `T', update users.
(assert_defined, gc_push_frame, gc_peek_frame, gc_init_cells): Mark
as internal.
* mes.c (type_t): Prefix all types with `T', update users.
* scaffold/mini-mes.c (eq_p, type_, car_, cdr_,
list_of_char_equal_p, lookup_macro, write_byte): New functions (from
mes.c).
(assq): Add debugging, workaround.
2017-03-10 20:56:18 +01:00
Matt Wette
b43380c8d8
nyacc: removed start from lalr-spec -- not needed
2017-03-05 13:22:51 -08:00
Matt Wette
2f1e0e6360
nyacc: working javascript interpreter in guile
2017-03-03 17:07:29 -08:00
Matt Wette
07310be6d0
nyacc: lex fixes for char-lit
2017-03-02 16:23:44 -08:00
Matt Wette
9c4e5247c2
nyacc: cleaned up documentation
2017-03-01 18:11:40 -08:00
Matt Wette
be4d33f022
nyacc: working on C99 UG as a memo
2017-02-28 17:19:48 -08:00
Matt Wette
6c536c0e9d
nyacc: new release 0.76.5
2017-02-28 09:57:49 -08:00
Matt Wette
953a57b663
nyacc: fixed bug in pretty-print-c99 wrt i-sel
2017-02-28 09:53:41 -08:00
Matt Wette
f7ab751dcd
nyacc: merge from 0.76.4
2017-02-25 07:36:57 -08:00
Matt Wette
72b0dbe2bd
nyacc: new release 0.76.4
2017-02-23 17:31:24 -08:00
Matt Wette
14d6407bc9
nyacc: new release 0.76.3
2017-02-23 05:38:49 -08:00
Matt Wette
e00dc59ac0
nyacc: more bugs in cpp tokl->string
2017-02-23 05:37:25 -08:00
Matt Wette
7bb78f15b8
nyacc: new release 0.76.2
2017-02-22 17:14:07 -08:00
Matt Wette
8580e706f8
nyacc: fixed more CPP issues
2017-02-22 17:12:32 -08:00
Matt Wette
f7fb6ac395
nyacc: new release 0.76.1
2017-02-22 08:26:40 -08:00
Matt Wette
2c6a6dc47d
nyacc: fixed C99 CPP to deal with numbers correctly
2017-02-22 08:23:27 -08:00
Matt Wette
62154122b3
nyacc: merge master 0.76.0
2017-02-20 13:45:45 -08:00
Matt Wette
34c0f46c62
nyacc: new release 0.76.0
2017-02-19 08:28:25 -08:00
Matt Wette
a301ce53df
nyacc: worked c99/util2.scm udecl->mspec
2017-02-19 08:26:30 -08:00
Matt Wette
047590bd5e
nyacc: new release 0.75.6
2017-02-18 17:11:12 -08:00
Matt Wette
bed639f680
nyacc: fixed some c99/util2 items
2017-02-18 17:06:50 -08:00
Matt Wette
5bf49dfb54
nyacc: merged in 0.75.5 from master and inc version
2017-02-17 10:21:52 -08:00
Matt Wette
9559240282
nyacc: new release 0.75.5
2017-02-17 08:30:20 -08:00
Matt Wette
883a93ce60
nyacc: new release 0.74.4
2017-02-16 16:14:42 -08:00
Matt Wette
f831edafe9
nyacc: minor cpp fixes
2017-02-16 16:12:40 -08:00
Matt Wette
5b34d2b2e7
nyacc: merge from 0.75.3
2017-02-16 11:03:11 -08:00
Matt Wette
16bf996c93
nyacc: new release 0.75.3
2017-02-16 06:26:10 -08:00
Matt Wette
2d35221753
nyacc: new release 0.75.2
2017-02-16 06:24:56 -08:00
Matt Wette
49a7200b72
nyacc: new release 0.75.1
2017-02-16 06:12:32 -08:00
Matt Wette
2b57b3dc6e
nyacc: new release 0.74.0
2017-02-15 20:49:07 -08:00
Matt Wette
1ae749b25f
nyacc: I think cpp is working now
2017-02-15 19:58:29 -08:00
Matt Wette
5baa7f33b1
nyacc: working cpp now, I hope
2017-02-14 19:24:59 -08:00
Matt Wette
8a821d03d6
nyacc: CPP not yet working for file mode
2017-02-12 14:29:18 -08:00
Matt Wette
ea7f0b3a01
nyacc: working on cpp issues
2017-02-11 13:04:38 -08:00
Matt Wette
d03ea06c84
nyacc: C99 CPP for code is better
2017-02-05 07:52:44 -08:00
Matt Wette
e534225328
nyacc: starting to work on reframing
2017-01-20 14:51:55 -08:00
Matt Wette
85cb3731cc
nyacc: more CPP fixes
2017-01-18 17:26:41 -08:00
Matt Wette
50fc6f6966
nyacc: redesign lang/c99/cppbocy.scm:scan-cpp-input
2017-01-17 05:50:45 -08:00
Jan Nieuwenhuizen
f738d4381d
mescc: Support goto in while body.
...
* module/language/c99/compiler.mes (ast->info): Support goto in while
body.
* doc/examples/t.c (test): Test it.
2017-03-10 07:01:51 +01:00
Jan Nieuwenhuizen
f612feec47
core+mini-mes: Move function name to struct function.
...
* module/language/c99/compiler.mes (expr->arg): Handle char arguments.
* doc/examples/cons-mes.c (struct function): Add name field.
* doc/examples/mini-mes.c: Likewise.
(mes_builtins): Update.
* mes.c: Likewise.
* build-aux/mes-snarf.scm: Update.
2017-03-09 23:27:12 +01:00
Jan Nieuwenhuizen
e9560e95a5
mescc: Support strings in struct initialization.
...
* module/mes/elf-util.mes (add-s:-prefix, drop-s:-prefix): New functions.
* module/mes/elf-util.scm: Export them.
* module/language/c99/compiler.mes (string->global): Add `s:' prefix
to global strings. Update users.
(expr->arg): Update.
(expr->accu): Handle string expressions.
(initzer->global): New function.
(struct-field): Handle string field.
* doc/examples/t.c: Test it.
* doc/examples/mini-mes.c: Use it.
dun!
2017-03-09 08:14:27 +01:00
Jan Nieuwenhuizen
64e73dcf29
mescc: Display sexps better.
...
* module/mes/elf.mes (make-elf): Only display data sections smaller
than 200 bytes.
* doc/examples/mini-mes.c (simple_bload_env): Read mini-0-32.mes.
* doc/examples/cons-mes.c (display_): Support symbols and specials.
* doc/examples/tiny-mes.c: Likewise.
* lib.c:
* mes.c:
2017-03-07 22:33:59 +01:00
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
78e70f9024
mescc: Support struct assignment.
...
* module/mes/libc-i386.mes (i386:base-address->accu-address,
i386:accu+n, i386:base+n): New functions.
* module/mes/libc-i386.scm: Export them.
* module/language/c99/compiler.mes (ast->info): Use them.
* doc/examples/t.c: Test them.
* doc/examples/cons-mes.c: Drop workarounds.
* doc/examples/mini-mes.c: Likewise.
* mes.c:
2017-03-02 20:26:13 +01:00
Jan Nieuwenhuizen
08ea0da745
mescc: Fix add, sub, lshift.
...
* module/language/c99/compiler.mes (expr->accu): Fix add, sub, lshift.
* doc/examples/t.c: Test them.
* doc/examples/cons-mes.c:
* doc/examples/mini-mes.c:
2017-03-02 20:19:53 +01:00
Jan Nieuwenhuizen
c9b251616a
mescc: Support any expression as arg.
...
* module/language/c99/compiler.mes (expr->arg): Also push parameter,
always return info.
(ast->info): Loop over args. Fixes using function calls in arguments.
* module/mes/libc-i386.mes (i386:push-arg): Remove.
(i386:call, i386:call-accu): Remove arguments parameter.
* doc/examples/t.c: Test it.
2017-02-27 07:50:33 +01:00
Jan Nieuwenhuizen
394a3925be
mescc: Rename expr->accu*.
...
* module/language/c99/compiler.mes (expr->accu*): Rename from expr->accuX.
2017-03-02 06:41:19 +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
184c9f2641
mescc: Mini-mes runs (cons 0 1) dump.
...
* module/mes/libc-i386.mes (i386:Xjump-z, i386:Xjump-c,
i386:Xjump-nc): New functions.
* module/mes/libc-i386.scm: Export them.
* module/language/c99/compiler.mes (case->jump-info, test-jump->info,
ast->info): Use them.
* doc/examples/t.c: Test it.
* doc/examples/mini-mes.c: Run it.
2017-02-24 13:27:39 +01:00
Jan Nieuwenhuizen
70e4aec861
mescc: Run mini-mes.
...
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 15:22:39 +01:00
Jan Nieuwenhuizen
452b231645
mescc: bugfix: arg as function call.
...
* module/language/c99/compiler.mes (expr->arg):
2017-01-21 13:17:24 +01:00
Matt Wette
e00d18b59f
nyacc: new release 0.74.3
2017-01-15 08:51:21 -08:00
Matt Wette
50301b8fd7
nyacc: CPP working better now
2017-01-15 08:47:49 -08:00
Matt Wette
7e39956858
nyacc: something working
2017-01-14 15:16:28 -08:00
Matt Wette
532687f6d8
nyacc: still debugginug
2017-01-14 13:30:47 -08:00
Matt Wette
bd3f15af64
nyacc: working # and ## I think, but lots of debug output too
2017-01-11 16:37:58 -08:00
Matt Wette
5652db7984
nyacc: exceptions worked on.. still need to fix #
2017-01-11 08:14:45 -08:00
Matt Wette
d644043ef8
nyacc: new release 0.74.2
2017-01-10 20:10:32 -08:00
Matt Wette
91023edbf4
nyacc: fixed C99 use of 'defined XYZ' (no parens)
2017-01-10 20:06:28 -08:00
Matt Wette
09b9c41dba
nyacc: merged master
2017-01-10 18:57:27 -08:00
Matt Wette
cc5f5ac96f
nyacc: working on fixes
2017-01-10 18:56:00 -08: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
2bb9f2b818
mescc: Support global pointer assignments.
...
* module/mes/libc-i386.mes (base->accu-ref, local-ref->base): New functions.
* module/mes/libc-i386.scm: Export them.
* module/language/c99/compiler.mes (base->ident-ref, ident-ref->base):
New functions.
2017-01-17 18:57:41 +01:00
Jan Nieuwenhuizen
bf9539c565
mescc: Add data as loadable ELF section.
...
* module/mes/elf.mes (make-elf): Add data as loadable section too.
2017-01-17 18:48:54 +01:00
Jan Nieuwenhuizen
11f7f67a45
mescc: Support switch.
...
* module/language/c99/compiler.mes (case->jump-info): New function.
(ast->info): Use it.
* doc/examples/t.c (swits): Test it.
2017-01-17 19:03:08 +01:00
Jan Nieuwenhuizen
04218971c5
mescc: Handle enums.
...
* module/language/c99/compiler.mes (<types>, <constants>): New slots for info.
(make, clone): Add them.
(.types, .constants): New accessors.
2017-01-10 22:44:01 +01:00
Jan Nieuwenhuizen
961559f32e
mescc: Update for.
...
* module/language/c99/compiler.mes (ast->info): Rewrite for to use
test->jump->info.
2017-01-10 20:51:29 +01:00
Jan Nieuwenhuizen
5fae0f7bff
scm: Add string-delete.
...
* module/srfi/srfi-13.mes (string-delete): New function.
2017-01-17 18:48:28 +01:00
Jan Nieuwenhuizen
c3eacb58df
mescc: Support ?.
...
* module/language/c99/compiler.mes (ast->info): Support cond-expr.
* scaffold/t.c (test): Test it.
2017-01-10 20:27:44 +01:00
Jan Nieuwenhuizen
b0e0ab014f
mescc: Support open, read.
...
* module/mes/libc-i386.mes (i386:write): Fix comment.
(i386:open, i386:read): New functions.
* module/mes/libc-i386.scm: Export them.
* module/language/c99/compiler.mes (i386:libc): Add them.
(getchar, putchar): New libc functions.
(libc): Add them.
2017-01-10 20:35:52 +01:00
Jan Nieuwenhuizen
4726a6c9ce
mescc: Support globals.
...
* module/language/c99/compiler.mes (write-any): Catch writing of
procedure and give more debug information.
(ref-local, ref-global): Remove.
(push-global-ref, push-global, push-ident-ref): New functions.
(push-ident): New function.
(expr->arg): Use them.
(ident->accu, ident->accu, accu->ident, value->ident, ident->base):
Take info parameter, also handle globals.
(ident-address->accu, ident->global, cstring->number): New functions.
(ast->info): Update.
* module/mes/libc-i386.mes (i386:ret-local): Remove.
(i386:push-global-ref): Rename from i386:ref-global.
(i386:push-local): Rename from i386:ref-local.
(i386:value->local): Rename from i386:local-assign.
(i386:push-global, i386:push-local-ref, i386:value->global,
i386:local-address->accu): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-10 20:12:06 +01:00
Jan Nieuwenhuizen
36f9d584c5
mescc: Small ELF tweaks allowing debugging with gdb.
...
* module/mes/elf.mes (make-elf): Change note section to comment. Fixes
readelf. Add SHF-ALLOC to .text and .data.
2017-01-09 20:06:32 +01:00
Jan Nieuwenhuizen
b98a2dda6e
mescc: Handle && in if and while.
...
* scaffold/t.c (test): Add strcmp tests.
* module/language/c99/compiler.mes (expr->arg):
(test->jump->info): New function.
(ast->info): Use it.
* module/mes/libc-i386.mes (i386:global->accu):
(i386:base-mem->accu): Rename from i386:mem->accu.
(i386:byte-base-mem->accu): Rename from i386:base-mem->accu.
(i386:accu-not, i386:global->accu, i386:xor-accu): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-08 17:51:40 +01:00
Jan Nieuwenhuizen
7667fb95c0
mescc: Proper support for i++,++i,i--,--i.
...
* module/language/c99/compiler.mes (ast->info): Bugfix: locals.
Add i--, --i. Properly support i++, ++i.
* module/mes/libc-i386.mes (i386:function-locals): Support 8 local vars.
* scaffold/t.c (test): Test it.
2017-01-07 21:53:12 +01: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
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
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