Commit graph

767 commits

Author SHA1 Message Date
Jan Nieuwenhuizen 9f56b8b102 core: Always include reader.c, drop binary read-0-32.mo dependency.
* module/language/c99/compiler.mes (c99-input->full-ast): Remove
  obsolete __NYACC__ and MES_FULL defines.
* src/mes.c [!MES_FULL]: Include reader-mes.h.
  (mes_builtins) [!MES_FULL]: Include reader.mes.i, reader.me.environment.i.
  [!MES_FULL]: Include reader.c.
  (main) [!MES_FULL]: By default call load_env, only call bload_env
  when --load is supplied.  WAS: Always bload read-0-32.mo.
* src/reader.c (__end_of__mes_): Remove.
  (dump): Remove option of dumping tiny test program.
* make/mescc-mes.make ($(OUT)/$(TARGET), mescc.mes-ccompile,
  mescc.mes.c-compile-E): Depend on $(OUT)/mes, scripts/mes.
* src/src.make (mes.guile): Remove module/mes/read-32-0 dependency.
  Do not build $(OUT)/mes.mes.
* module/module.make (module/mes/read-0.mo, module/mes/read-0-32.mo,
  module/mes/tiny-0-32.mo): Remove targets.
  (CLEAN): Do not add them.  Neither install $(OUT)/mes.mes.
* .gitignore: Remove exceptions for them.
* make/install.make (install): Do not install them.
* HACKING: Update info about creating module/mes/read-32-0.mo.
* scaffold/mini-mes.c: Remove.
* scaffold/tiny-mes.c: Remove.
* scaffold/cons-mes.c: Remove.
* scaffold/scaffold.make (tiny-mes.libc, tiny-mes.guile, tiny-mes.mes,
  mini-mes.libc, mini-mes.guile, mini-mes.mes): Reemove targets.
2017-05-28 16:03:45 +02:00
Jan Nieuwenhuizen f6671eaf3e mescc: Add missing builtins.
* module/language/c99/compiler.mes (i386:type-alist): Add missing
  builtins.  TODO: identify and handle unsigned.
2017-05-27 09:28:08 +02:00
Jan Nieuwenhuizen bade7d5519 mescc: Support typedef and many TCC declaration variants.
* module/language/c99/compiler.mes (ast->info): Register typedefs in types.
  (enum-def-list->constants): Support addition and substraction in
  enum field values.
  (get-type): New function.  Use throughout.
2017-05-25 07:32:29 +02:00
Jan Nieuwenhuizen 3b4e7cd8a8 mescc: Handle comments anywhere.
* module/language/c99/compiler.mes (c99-input->full-ast): Rename from c99-input->full-ast.
  (ast-strip-comment, c99-input->ast): New functions.
  (ast->info): Remove comment exceptions.
2017-05-25 19:48:26 +02:00
Jan Nieuwenhuizen 92a330ff07 mescc: Support anonymous enums.
* module/language/c99/compiler.mes (enum-def-list->constants): New function.
  (ast->info): Support anonymous enum.
2017-05-25 07:57:26 +02:00
Jan Nieuwenhuizen 6af7556d51 mescc: C99 header files and declaraions.
* libc/include/assert.h (assert_fail):
* libc/include/stdio.h:
+int eputs (char const* s);
+int fputs (char const* s);
+int puts (char const* s);
+int putchar (int c);
+int fputc (int c, int fd);
+int getchar ();
* libc/include/stdlib.h:
+char* getenv (char const* s)
+int atoi (char const *s);
+int *malloc (size_t);
+int *realloc (int *p, int size);
* libc/include/unistd.h (access):
* src/lib.c (display_helper):
* src/mes.c (read_input_file_env):
* src/posix.c: Include unistd.h.
2017-05-23 07:16:08 +02:00
Jan Nieuwenhuizen 174c7a5e22 guix: Update from Guix.
* guix.scm (mes): Update from Guix.
2017-05-23 20:11:51 +02:00
Jan Nieuwenhuizen 73b31ae00b build: Use separate preprocessing stage for mescc.
* make/mescc-guile.make (mescc.scm-c-preprocess, (mescc.scm-compile-E):
  New defines.
  [!MESC_DIRECT]Compile .o via separate preprocessed .E stage.
2017-05-22 21:15:58 +02:00
Jan Nieuwenhuizen cf51f3f5bd mescc: support -E.
* guile/mescc.scm (parse-opts): Add -E.
  (source->ast): New function.
  (main): Use it.
* scripts/mescc.mes (parse-opts): Add -E.
  (source->ast): New function.
  (main): Use it.
2017-05-22 19:22:18 +02:00
Jan Nieuwenhuizen 3c880bbb56 mescc: Refactor mlibc compilation.
* libc/libc-mes.c: New file.  Contents from module/mes/libc.mes, module/mes/libc-i386.mes.
* libc/libc-gcc.c: Rename from libc/mlibc.c, include libc/mstart.c
* libc/mstart.c: Remove.
* module/mes/libc-i386.mes: Remove.
* module/mes/libc-i386.scm: Remove.
* module/mes/libc.mes: Remove.
* module/mes/libc.scm: Remove.
* GNUmakefile (CFLAGS): Include libc-gcc.c (WAS: mlibc.c).
* make/bin-mlibc.make (C_FLAGS): Remove start.c include.
* make/mescc-guile.make: Rewrite using compile, link.
* make/mescc-mes.make: Likewise.
* scaffold/m.c: Update.
2017-05-21 22:25:02 +02:00
Jan Nieuwenhuizen 2027754a59 mescc: support -c, -o.
* module/language/c99/compiler.mes: Throughout: quote lambda's.
  (current-eval): New function.
  Thanks Andy!
  (object->list): New function.  Update callers.
  (c99-input->info): Dump a.o.
  (initzer->non-const, function:object->list): New functions.
  (info:object->list): New function.
  (c99-input->elf): Call it.
* module/mes/as-i386: Throughout: quote lambda's.
* scripts/mescc.mes (main): Rewrite.
* guile/mescc.scm (main): Likewise.
2017-05-17 13:56:25 +02:00
Jan Nieuwenhuizen bdd160241b mes: Bugifx for number->string radix > 10.
* module/mes/scm.mes (number->string): Bugfix for `10' -> hex/radix > 10.
2017-05-23 06:28:37 +02:00
Jan Nieuwenhuizen 21aff4c7ad mes: Simplify read-string.
* module/mes/guile.mes (read-string): Simplify, probably fix even.
2017-05-21 12:21:07 +02:00
Jan Nieuwenhuizen 78a066ff3f mescc: Remove LALR C frontend prototype.
* module/language/c/compiler.mes: Remove.
* module/language/c/lexer.mes: Remove.
* module/language/c/parser.mes: Remove.
2017-05-21 12:38:29 +02:00
Jan Nieuwenhuizen 11311bcaa7 mes: Add negate.
* module/mes/scm.mes (negate): New function.
2017-05-21 12:33:16 +02:00
Jan Nieuwenhuizen 45ce77df85 core: Add current-output-port, open-output-file, set-current-output-port.
* libc/include/fcntl.h: Declare it.  Add some fcntl defines.
* libc/include/stdio.h: Remove fcntl defines, Declare g_stdout.
* module/language/c99/compiler.mes (c99-input->ast): Define O_WRONLY, O_RDWR.
* module/mes/guile.mes (with-output-to-file, with-output-to-port): New functions.
* src/posix.c (current_output_port, open_output_file,
  set_current_output_port): New functions.
* libc/mlibc.c (open): Add optional mode parameter.
* module/mes/libc-i386.mes (i386:open): Forward third parameter.
* scaffold/mini-mes.c (main): Init g_stdout.
* src/mes.c (main): Likewise.
2017-05-19 06:56:47 +02:00
Jan Nieuwenhuizen 44c8f26bf0 mes: Support octal numbers in reader.
* module/mes/read-0.mes (read-octal): New function.
  (read-word): Use it.
* tests/read.test: Test it.
2017-05-19 21:10:08 +02:00
Jan Nieuwenhuizen 8dc593ab18 mes: Add getopt-long.
* module/mes/getopt-long.scm: New file, imported from Guile-1.8,
* module/mes/getopt-long.mes: Include it.
* AUTHORS: Mention it.
2017-05-18 22:03:02 +02:00
Jan Nieuwenhuizen dda7a7cd62 mes: Add string-rindex.
* module/srfi/srfi-13.mes (string-rindex): New function.
2017-05-19 00:41:01 +02:00
Jan Nieuwenhuizen 20b3c349bf mes: Support predicate with string-index.
* module/srfi/srfi-13.mes (string-index): Support predicate.
2017-05-19 00:51:23 +02:00
Jan Nieuwenhuizen 8f4b64fda7 mes: Add string-suffix?
* module/mes/scm.mes (string-prefix?): Refactor.
  (string-suffix?): New function.
2017-05-19 00:23:13 +02:00
Jeremiah Orians cd5c16cf74 Purging binary blobs
* mes.mes: Remove.
* module/mes/read-0-32.mo: Remove.
2017-05-27 07:29:20 +02:00
Jan Nieuwenhuizen 5ac5f71707 doc: Update.
* AUTHORS: Remove module/nyacc.
2017-05-15 07:01:01 +02:00
Jan Nieuwenhuizen a7b44853b4 doc: typo 2017-05-14 19:23:15 +02:00
Jan Nieuwenhuizen 1766c6b8bf guix hash: 0qqywk3siyhf08v7xac08lqldklrqfndlp495wgy6ii9fn93197k 2017-05-14 18:00:38 +02:00
Jan Nieuwenhuizen d4420bbcc9 Release 0.6.
* configure (VERSION): Bump.
2016-12-25 15:51:53 +01:00
Jan Nieuwenhuizen 3dc0c12a03 doc: Release update.
* NEWS: Update.
2017-05-06 17:46:41 +02:00
Jan Nieuwenhuizen a4a323c2bb test: Run 33/55 tests of ../tinycc/tests/test2 if avaiable.
* make/check-tinycc.make: New file.
* tinycc/tinycc.make: New file.
* GNUmakefile (SUBDIRS): Add tinycc.
2017-05-04 19:41:45 +02:00
Jan Nieuwenhuizen c43e285de5 build: Support i686, support development for arm.
* configure (CC32): Accept arm-* as 32 bit compiler.
  (check-compile-header-c, check-header-c): New functions.
  (parse-opts): New option: --with-courage.
  (main): Check for platform, stdio.h, limits.h.
2017-05-14 09:03:06 +02:00
Jan Nieuwenhuizen 7241756945 mescc: Minimal support for short.
* module/language/c99/compiler.mes (i386:type-alist): Add short.
2017-05-08 21:34:08 +02:00
Jan Nieuwenhuizen ae7a42671a mescc: Add strcpy.
* libc/include/string.h (strcpy): Declare.
* libc/mlibc.c (strcpy): New function.
* module/mes/libc.mes (strcpy): New function.
  (libc): Add it.
* scaffold/t.c (string_test): Test it.
2017-05-08 21:15:53 +02:00
Jan Nieuwenhuizen 5d0202bbf7 mescc: Enhance sizeof support.
* module/language/c99/compiler.mes (expr->accu): Support sizeof (simple-type),
  sizeof (var).
2017-05-08 21:32:32 +02:00
Jan Nieuwenhuizen ed3aa5be35 mescc: Support void return.
* module/language/c99/compiler.mes (ast-info): Support `return'.
2017-05-08 20:06:20 +02:00
Jan Nieuwenhuizen c64691797b nyacc: Unbundle.
* configure (check-version): Use keyword parameters, add #:command
  parameter.
  (main): Check for Nyacc.
* INSTALL: Mention Nyacc as dependency.
* make/guile.make (all-go): Compile in guile dir.
* module/module.make (SCM_FILES): Remove Nyacc filters.
* module/nyacc/BUGS: Remove.
* module/nyacc/ChangeLog: Remove.
* module/nyacc/README: Remove.
* module/nyacc/README.nyacc: Remove.
* module/nyacc/bison.scm: Remove.
* module/nyacc/export.scm: Remove.
* module/nyacc/import.scm: Remove.
* module/nyacc/lalr.scm: Remove.
* module/nyacc/lalr2.scm: Remove.
* module/nyacc/lang/c99/README: Remove.
* module/nyacc/lang/c99/body.scm: Remove.
* module/nyacc/lang/c99/cpp.scm: Remove.
* module/nyacc/lang/c99/cppmach.scm: Remove.
* module/nyacc/lang/c99/mach.d/c99act.scm: Remove.
* module/nyacc/lang/c99/mach.d/c99tab.scm: Remove.
* module/nyacc/lang/c99/mach.d/c99xact.scm: Remove.
* module/nyacc/lang/c99/mach.d/c99xtab.scm: Remove.
* module/nyacc/lang/c99/mach.d/cppact.scm: Remove.
* module/nyacc/lang/c99/mach.d/cpptab.scm: Remove.
* module/nyacc/lang/c99/mach.scm: Remove.
* module/nyacc/lang/c99/parser.scm: Remove.
* module/nyacc/lang/c99/pprint.scm: Remove.
* module/nyacc/lang/c99/util1.scm: Remove.
* module/nyacc/lang/c99/util2.scm: Remove.
* module/nyacc/lang/c99/xparser.scm: Remove.
* module/nyacc/lang/calc/parser.scm: Remove.
* module/nyacc/lang/util.scm: Remove.
* module/nyacc/lex.scm: Remove.
* module/nyacc/parse.scm: Remove.
* module/nyacc/util.scm: Remove.
2017-05-07 10:04:32 +02:00
Jan Nieuwenhuizen ec935e5667 mes: Consider GUILE_LOAD_PATH for include-from-path.
* module/mes/guile.scm (include-from-path): New macro.
2017-05-07 08:23:20 +02:00
Jan Nieuwenhuizen df878c59d9 mescc: Bugfixes for local char[].
* module/language/c99/compiler.mes (push-ident): Cater for local arrays.
  (expr->accu): Avoid post-inc/post-dec twice on rhs of assignment.
  Fix size lookup for local char arrayns.
2017-05-07 07:36:44 +02:00
Jan Nieuwenhuizen d1cacdc91e nyacc: Update to 0.78. 2017-05-06 22:35:46 +02:00
Jan Nieuwenhuizen 92c363701b mes: Add srfi-16 to Nyacc Guile support.
* module/mes/guile.mes: Include srfi-16 for Nyacc.
2017-05-06 22:47:45 +02:00
Jan Nieuwenhuizen c84f95beee mes: Basic support for string-index.
* module/srfi/srfi-13.mes (string-index): New function.
* tests/srfi-13.test ("string-index"): Test it.
2017-05-06 23:00:27 +02:00
Jan Nieuwenhuizen 529ab8caa1 mes: Support #\cr short form in reader.
* module/mes/read-0.mes (read-character): Support #\cr short form for #\return.
* module/mes/read-0-32.mo: Regenerate.
2017-05-06 22:49:08 +02:00
Jan Nieuwenhuizen 073f886203 mes: Support case-lambda.
* module/srfi/srfi-16.scm: New file.
* AUTHORS: Mention it.
* module/srfi/srfi-16.mes: New file.
2017-05-06 22:42:21 +02:00
Jan Nieuwenhuizen 0bc2c05dba mescc: Enhance enum support.
* module/language/c99/compiler.mes (ast->info): Support enum variable
  declaration.  Respect field value overrides.
2017-05-06 19:31:00 +02:00
Jan Nieuwenhuizen 390059a42d mescc: Support binary constants.
* module/language/c99/compiler.mes (cstring->number): Support binary 0bxxx values.
* scaffold/t.c (math_test): Test it.
2017-05-06 18:16:24 +02:00
Jan Nieuwenhuizen 2eae07de72 mescc: Support ==, != as expression value.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (expr->accu): Set accu to 0/1 for eq, ne.
* module/mes/as-i386.mes (i386:nz->accu, i386:z->accu,
  i386:accu<->stack): New functions.
* scaffold/t.c (math_test): Test it.
2017-05-06 17:30:14 +02:00
Jan Nieuwenhuizen be6e30a8fa mescc: Support &, ^.
* module/mes/as-i386.mes (i386:accu-and-base, i386:accu-xor-base): New functions.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (expr->accu): Support bitwise-and, bitwise-xor.
2017-05-06 14:57:39 +02:00
Jan Nieuwenhuizen 6272356959 mescc: Support struct pointers.
* module/language/c99/compiler.mes (expr->accu): Support
  &struct.field, struct->field.
  (ast->info): Support struct *foo = &bar;
* scaffold/t.c (struct_test): Test it.
2017-05-06 11:01:58 +02:00
Jan Nieuwenhuizen 5246de5e39 mescc: Support struct definition with variable declaration.
* module/language/c99/compiler.mes (ast->info): Support `struct foo {} bar;'.
2017-05-06 09:27:28 +02:00
Jan Nieuwenhuizen 68528219cb mescc: Support void functions.
* module/language/c99/compiler.mes (function->info): Add return if
  missing.  Fixes calling void functions (and functions where return
  is missing).
* scaffold/t.c (void_func): Test it.
2017-05-06 09:11:42 +02:00
Jan Nieuwenhuizen 6dc19bd040 mescc: Bugfix for break in switch not in compound.
* module/language/c99/compiler.mes (clause->jump-info): Rename from
  case->jump-info.
  (statements->clauses): New function.
  (ast->info): Use it.  Fixes switch statement with break in a case
  outside of a compound.
* scaffold/t.c (swits): Test it.
2017-05-06 08:39:04 +02:00
Jan Nieuwenhuizen f5372bdeff mescc: Enhance [int/pointer] array support.
* module/language/c99/compiler.mes (p-expr->type): Handle array-ref
  with any index.
  (ast->info): Support plain array declerations.
  (expr->accu): For size == 4, assume value in accu.  Fixes int/pointer arrays.
* scaffold/t.c: Test it.
2017-05-05 09:24:19 +02:00