Commit graph

586 commits

Author SHA1 Message Date
Jan Nieuwenhuizen 83549786ed mescc: No comments in M1 when running on Mes.
* module/language/c99/compiler.mes (ast-comment): If mes?, return nil.
2018-04-07 13:13:26 +02:00
Jan Nieuwenhuizen 5867ac4afe mescc: Trace globals.
* module/language/c99/compiler.mes (mescc:trace): New function.  Use
  throughout.
2018-04-07 12:56:17 +02:00
Jan Nieuwenhuizen da724cdaa1 Revert "core: Add member."
This reverts commit 921686a0a3b06281f1804d04e6d4a0344dda507a.
2018-04-07 13:15:26 +02:00
Jan Nieuwenhuizen f33d23bca1 core: Add member.
* src/lib.c (member): New function.
* module/mes/scm.mes (member): Remove.
2018-04-07 12:18:50 +02:00
Jan Nieuwenhuizen 5e9c539f57 mescc: trace M1 dumping.
* module/language/c99/compiler.mes (info->object): Add tracing.
* module/mes/M1.mes (object->M1): Add tracing.
2018-04-07 10:24:57 +02:00
Jan Nieuwenhuizen 30262dcdc1 mescc: Also print `parsing: input' when using -E.
* module/language/c99/compiler.mes (c99-input->ast): Print `parsing:
  input'.
  (c99-input->info): Remove that.
2018-04-06 07:18:19 +02:00
Jan Nieuwenhuizen 0a4030838c core: Add equal2?.
* src/lib.c (equal2_p): New function.
* module/mes/base.mes (equal2?): Remove.
2018-04-05 20:01:04 +02:00
Jan Nieuwenhuizen 6a9621ebf3 core: Add memq.
* lib/mes.c (memq): New function.
* module/mes/scm.mes (memq): Remove.
2018-04-05 11:03:09 +02:00
Jan Nieuwenhuizen 76e1b0582f mes: Remove duplicate memq.
* module/mes/base-0.mes (memq): Remove.
2018-04-05 11:02:06 +02:00
Jan Nieuwenhuizen 9fc27ee25a mes: Single environment lookup for variables, SICP chapter 3.
* src/mes.c (t): Add TVARIABLE.
  (scm_vm_eval_deref): New vm special.
  (make_vref_): New internal function.
  (eval_apply): WIP: replace symbols with their variable reference.
* src/gc.c (gc_loop): Handle TVARIABLE.
* src/lib.c (display_helper): Handle TVARIABLE.
* module/mes/type-0.mes (<cell:variable>): New variable.
  (cell:type-alist): Add it.
  (variable?): New function.
* module/mes/display.mes (display): Handle <variable>.
2017-12-09 08:33:50 +01:00
Jan Nieuwenhuizen 4c9690996c mes: Iterative recursive macro expand.
* src/mes.c (eval_apply): Iterative recursive macro expand.
* src/posix.c (set_current_input_port): Return previous port.
* module/mes/catch.mes (%eh): Use core:display.
* module/mes/display.mes (display-cut, display-cut2): Move macro
  definitions to toplevel.
2018-03-04 10:05:55 +01:00
Jan Nieuwenhuizen 9c8e2dbd9f mes: Add incremental test suite.
* check-boot.sh: New file.
* check.sh: Invoke it.
* module/srfi/srfi-16.mes: New file.
* scaffold/boot/00-zero.scm: New file.
* scaffold/boot/01-true.scm: New file.
* scaffold/boot/02-symbol.scm: New file.
* scaffold/boot/03-string.scm: New file.
* scaffold/boot/04-cons.scm: New file.
* scaffold/boot/04-quote.scm: New file.
* scaffold/boot/05-list.scm: New file.
* scaffold/boot/06-tick.scm: New file.
* scaffold/boot/07-if.scm: New file.
* scaffold/boot/08-if-if.scm: New file.
* scaffold/boot/10-cons.scm: New file.
* scaffold/boot/11-list.scm: New file.
* scaffold/boot/12-car.scm: New file.
* scaffold/boot/13-cdr.scm: New file.
* scaffold/boot/14-exit.scm: New file.
* scaffold/boot/15-display.scm: New file.
* scaffold/boot/16-if-eq-quote.scm: New file.
* scaffold/boot/20-define-quote.scm: New file.
* scaffold/boot/20-define-quoted.scm: New file.
* scaffold/boot/20-define.scm: New file.
* scaffold/boot/21-define-procedure.scm: New file.
* scaffold/boot/22-define-procedure-2.scm: New file.
* scaffold/boot/23-begin.scm: New file.
* scaffold/boot/24-begin-define.scm: New file.
* scaffold/boot/25-begin-define-2.scm: New file.
* scaffold/boot/26-begin-define-later.scm: New file.
* scaffold/boot/26-define-define.scm: New file.
* scaffold/boot/27-lambda-define.scm: New file.
* scaffold/boot/28-define-define.scm: New file.
* scaffold/boot/29-lambda-define.scm: New file.
* scaffold/boot/2a-lambda-lambda.scm: New file.
* scaffold/boot/2b-define-lambda.scm: New file.
* scaffold/boot/2c-define-lambda-recurse.scm: New file.
* scaffold/boot/2d-define-lambda-set.scm: New file.
* scaffold/boot/2e-define-second.scm: New file.
* scaffold/boot/30-capture.scm: New file.
* scaffold/boot/31-capture-define.scm: New file.
* scaffold/boot/32-capture-modify-close.scm: New file.
* scaffold/boot/33-procedure-override-close.scm: New file.
* scaffold/boot/34-cdr-override-close.scm: New file.
* scaffold/boot/35-closure-modify.scm: New file.
* scaffold/boot/36-closure-override.scm: New file.
* scaffold/boot/37-closure-lambda.scm: New file.
* scaffold/boot/38-simple-format.scm: New file.
* scaffold/boot/40-define-macro.scm: New file.
* scaffold/boot/41-when.scm: New file.
* scaffold/boot/42-if-when.scm: New file.
* scaffold/boot/43-or.scm: New file.
* scaffold/boot/44-or-if.scm: New file.
* scaffold/boot/45-pass-if.scm: New file.
* scaffold/boot/46-report.scm: New file.
* scaffold/boot/47-pass-if-eq.scm: New file.
* scaffold/boot/48-let.scm: New file.
* scaffold/boot/49-macro-override.scm: New file.
* scaffold/boot/4a-define-macro-define-macro.scm: New file.
* scaffold/boot/4b-define-macro-define.scm: New file.
* scaffold/boot/4c-quasiquote.scm: New file.
* scaffold/boot/50-primitive-load.scm: New file.
* scaffold/boot/51-module.scm: New file.
* scaffold/boot/52-define-module.scm: New file.
* scaffold/boot/53-closure-display.scm: New file.
* scaffold/boot/60-let-syntax.scm: New file.
* scaffold/boot/closure.scm: New file.
* scaffold/boot/compose.scm: New file.
* scaffold/boot/data/bar.mes: New file.
* scaffold/boot/data/i.scm: New file.
* scaffold/boot/data/module.mes: New file.
* scaffold/boot/foo.scm: New file.
* scaffold/boot/lambda-star.scm: New file.
* scaffold/boot/vector.scm: New file.
* tests/boot.test: New file.
* tests/boot.test-guile: New file.
* tests/srfi-16.test: New file.
* tests/srfi-16.test-guile: New file.
2018-01-25 06:58:44 +01:00
Jan Nieuwenhuizen 459e4f6a57 mes: Boot from MES_BOOT, boot-0.scm.
* src/mes.c (load_env): Softcode loading of boot-0.scm from
  environment variabl MES_BOOT.
* module/mes/boot-00.scm: New file.
* module/mes/boot-01.scm: New file.
* module/mes/boot-0.scm: Rename from read-0.mes.
* module/mes/module.mes: New file.
2018-02-03 21:43:52 +01:00
Jan Nieuwenhuizen f077364bce mes: reader: reader_ prefix; read/write char/string in core.
* src/posix.c (peek_char, read_char, read_string, unread_char, write_char): New function.
* src/reader.c: Use reader_ prefix.

r#	bootstrappable.org
2018-01-06 07:58:23 +01:00
Jan Nieuwenhuizen 91070593e9 mes: More informative error reporting for number asserts.
* src/math.c (assert_number): New function.  Update assert () users.
2018-01-25 07:00:48 +01:00
Jan Nieuwenhuizen 3d93eea456 mes: simple-format: support ~A, ~S.
* module/mes/display.scm (simple-format): support ~A, ~S.
2018-02-03 20:06:38 +01:00
Jan Nieuwenhuizen 7b8f69972e mes: Rename make-vector to core:make-vector.
* src/vector.c (make_vector_): Rename from make_vector.  Update callers.
2018-01-07 16:26:36 +01:00
Jan Nieuwenhuizen a5ede4d4d6 mes: Better error reporting.
* src/lib.c (write_error_): New function.
* src/mes.c (error, check_apply): Use it.
  (append2, set_car_x): Upon error, call error (WAS: assert).
2018-01-07 16:08:11 +01:00
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