jackhill/mal.git
5 years agoMerge pull request #396 from inkydragon/fix-test-on-windows
Joel Martin [Mon, 3 Jun 2019 15:05:00 +0000 (11:05 -0400)]
Merge pull request #396 from inkydragon/fix-test-on-windows

run test on cygwin

5 years agorun test on cygwin
woclass [Sun, 2 Jun 2019 14:22:52 +0000 (22:22 +0800)]
run test on cygwin

5 years agoMerge pull request #389 from bjh21/bjh21-mal-kw-outer
Joel Martin [Fri, 31 May 2019 16:27:27 +0000 (12:27 -0400)]
Merge pull request #389 from bjh21/bjh21-mal-kw-outer

mal: Use a keyword to link each environment to its outer one.

5 years agomal: Use a keyword to link each environment to its outer one.
Ben Harris [Mon, 27 May 2019 21:17:53 +0000 (22:17 +0100)]
mal: Use a keyword to link each environment to its outer one.

Heretofore, the mal implementation has linked each environment to its
outer environment by defining a special symbol, '--outer--' in that
environment.  This causes that symbol to be unusable by programs running
under that implementation.  For instance:

  (def! foo 123)
  (def! f (fn* (--outer--) foo))
  (f)

gives an error because overwriting '--outer--' breaks the environment
chain.

Happily, mal provides a way around this.  Keywords are guaranteed to
work as hashmap keys, so by using a keyword instead of a string as the
key for the outer environment, it can be hidden from user code.  This
also provides a motivation for keywords, which aren't otherwise used by
the mal implementation.

5 years agotravis_trigger.sh: Support .com and env var tokens
Joel Martin [Fri, 31 May 2019 03:50:20 +0000 (22:50 -0500)]
travis_trigger.sh: Support .com and env var tokens

5 years agoTravis: travis_trigger.sh script.
Joel Martin [Fri, 31 May 2019 02:37:47 +0000 (21:37 -0500)]
Travis: travis_trigger.sh script.

5 years agoMerge pull request #393 from bjh21/bjh21-bbc-basic
Joel Martin [Fri, 31 May 2019 03:15:00 +0000 (23:15 -0400)]
Merge pull request #393 from bjh21/bjh21-bbc-basic

bbc-basic: Increase Brandy heap size so we run out of memory less

5 years agobbc-basic: Enlarge Brandy's heap size.
Ben Harris [Thu, 30 May 2019 22:02:53 +0000 (23:02 +0100)]
bbc-basic: Enlarge Brandy's heap size.

Having found the perfect mal heap size to get self-hosting to work in
64-bit Brandy, I tried the performance tests, and they failed.  I've
therefore accepted that I need to increase Brandy's heap size, so I'm
doubling it to a megabyte.  That doesn't seem especially generous on
modern hardware.

5 years agobbc-basic: Slight tweak to heap size.
Ben Harris [Thu, 30 May 2019 21:31:12 +0000 (22:31 +0100)]
bbc-basic: Slight tweak to heap size.

Making the mal heap very slightly smaller allows the self-hosting test
to complete on a 64-bit host.

This is really not the right approach, though.  I should really just
give in and specify "-size 1024k" to Brandy, or have the GC somehow
detect that we're wasting a lot of memory on strings and it should run
early.  At the moment, there's a tiny range of heap sizes that
actually work.

5 years agoTravis: combine build into .travis_test.sh
Joel Martin [Thu, 30 May 2019 03:41:35 +0000 (22:41 -0500)]
Travis: combine build into .travis_test.sh

5 years agoVarious small self-host mode fixes.
Joel Martin [Wed, 29 May 2019 03:34:15 +0000 (22:34 -0500)]
Various small self-host mode fixes.

- clojure (cljs): self-host arity fix. Apparently ClojureScript
  functions that have metadata attached only support arity of 20. This
  is problem during self-host because the main EVAL cond macro is 22
  items so it blows up when applied in macroexpand. So we preserve the
  origin unadorned function through to macroexpand and use it there
  instead of the adorned function/macro.
- basic: fix build when in self-host qbasic mode.
- coffee, cs, dart, elisp, hy, rexx, vb: fix self-host reader errs. Preserve
  or extract the correct error message in try*/catch* loops so that it
  works for self-host error message printing as well.
- mal: pathing issue in ./run script that affected the wasm
  implementation path permissions
- miniMAL: remove extraneous command line printing of "nil".
- ps: inc function was not actually defined.
- rust: write warning about missing .mal-history to stderr to fix
  self-host failure in step6.
- wasm: the map function was stopping on nil values; fix the list end
  check. Double the macroexpand stack so that sumdown test in stepA
  tests passes without mac stack overflow.
- yorick: read from /dev/stdin in readline builtin function.

5 years agoTravis: detect special self-host-test branch.
Joel Martin [Tue, 28 May 2019 04:21:57 +0000 (23:21 -0500)]
Travis: detect special self-host-test branch.

- If the branch name is "self-host-test" then do self-hosted test.
- Fix pass through of *_MODE values during self-hosting.
- Add capability to skip of build/test/perf during self-host.
- Skip self-host for basic, io, logo, make.
- Reformat travis.yml list for better alignment

5 years agoMerge pull request #390 from bjh21/bjh21-bbc-basic
Joel Martin [Tue, 28 May 2019 20:55:24 +0000 (16:55 -0400)]
Merge pull request #390 from bjh21/bjh21-bbc-basic

bbc-basic: Assorted fixes

5 years agobbc-basic: Shrink mal heap a little.
Ben Harris [Tue, 28 May 2019 19:48:56 +0000 (20:48 +0100)]
bbc-basic: Shrink mal heap a little.

On 64-bit systems, Brandy uses rather a lot of memory for string arrays,
so having the heap too large runs it out of memory.

5 years agobbc-basic: Add comment explaining sizing of mal heap.
Ben Harris [Tue, 28 May 2019 19:47:13 +0000 (20:47 +0100)]
bbc-basic: Add comment explaining sizing of mal heap.

5 years agoMerge pull request #388 from bjh21/bjh21-large-files-step6
Joel Martin [Tue, 28 May 2019 17:30:27 +0000 (13:30 -0400)]
Merge pull request #388 from bjh21/bjh21-large-files-step6

step6: Test loading of a large (>255 byte) file earlier than before.

5 years agoMerge pull request #392 from asarhaddon/ada-unterminated-string
Joel Martin [Tue, 28 May 2019 17:26:25 +0000 (13:26 -0400)]
Merge pull request #392 from asarhaddon/ada-unterminated-string

ada: fix the fix for unterminated strings

5 years agoMerge pull request #391 from asarhaddon/test-let-recursive-def
Joel Martin [Tue, 28 May 2019 17:22:41 +0000 (13:22 -0400)]
Merge pull request #391 from asarhaddon/test-let-recursive-def

Test mutual recursion in let*

5 years agoTest mutual recursion in let* without vectors, which are deferrable.
Nicolas Boulenguez [Tue, 28 May 2019 14:36:21 +0000 (16:36 +0200)]
Test mutual recursion in let* without vectors, which are deferrable.

Thanks to bjh21 for spotting this inconsistency.

5 years agoada: fix the fix for unterminated strings
Nicolas Boulenguez [Tue, 28 May 2019 14:22:21 +0000 (16:22 +0200)]
ada: fix the fix for unterminated strings

Thanks bjh21. I have been distracted by a less important issue (should
"\a" be read as "\a" or "a"?).

5 years agoTest mutual recursion in let*
Nicolas Boulenguez [Tue, 28 May 2019 13:18:57 +0000 (15:18 +0200)]
Test mutual recursion in let*

5 years agobbc-basic: Fix accidental quadratic behaviour in string handling.
Ben Harris [Mon, 27 May 2019 21:51:09 +0000 (22:51 +0100)]
bbc-basic: Fix accidental quadratic behaviour in string handling.

The code for constructing long strings in FNstring_concat and 'slurp'
was accidentally quadratic in the size of output.  This meant that it
consumed BASIC heap space in inordinate quantities for storing strings.
Mal doesn't monitor the usage of the BASIC heap, so it didn't run the
garbage collector and instead suffered a fatal error.  Making these
functions use sane amounts of memory avoids that problem.

5 years agostep6: Test loading of a large (>255 byte) file earlier than before.
Ben Harris [Mon, 27 May 2019 09:31:32 +0000 (10:31 +0100)]
step6: Test loading of a large (>255 byte) file earlier than before.

I just introduced a bug in the BBC BASIC implementation meaning that
'load-file' was broken on files over 255 bytes long, and it was only
caught by the optional test of 'time-ms' in step A.  This change brings
forward the relevant part of that test so the failure can be detected
earlier and more obviously, at the same time as the other tests of
'load-file'.

5 years agoMerge pull request #386 from asarhaddon/test-let-recursive-def
Joel Martin [Mon, 27 May 2019 19:49:02 +0000 (15:49 -0400)]
Merge pull request #386 from asarhaddon/test-let-recursive-def

test recursive definitions in let*

5 years agoMerge pull request #385 from asarhaddon/ada-unterminated-string
Joel Martin [Mon, 27 May 2019 19:42:13 +0000 (15:42 -0400)]
Merge pull request #385 from asarhaddon/ada-unterminated-string

ada: fix unterminated string and creation of object directory by Make.

5 years agobbc-basic: Clean up long-string support.
Ben Harris [Mon, 27 May 2019 11:51:20 +0000 (12:51 +0100)]
bbc-basic: Clean up long-string support.

When I first implemented support for strings over 255 characters long, I
did so quite crudely, and the procedures to construct long strings
modified the mal objects passed into them.  This was unfortunate: no
other routine (apart from PROCatom_reset, of course) modified an object
in the mal heap after it had escaped from the "types" library.  It also
led to quite a few annoying bugs.

This is now fixed: all routines that modify long strings now return a
new object as necessary, and leave the arguments unchanged.  This is
probably rather slower than the old code, but it's also much cleaner.

5 years agobbc-basic: Remove the word "partial" from the README.
Ben Harris [Sun, 26 May 2019 12:38:54 +0000 (13:38 +0100)]
bbc-basic: Remove the word "partial" from the README.

5 years agobbc-basic: Slight printer tidying.
Ben Harris [Sun, 26 May 2019 12:38:25 +0000 (13:38 +0100)]
bbc-basic: Slight printer tidying.

When printing a vector, don't allocate a string for "(" and then
immediately throw it away.

5 years agobbc-basic: Make metadata on string-like types work.
Ben Harris [Sun, 26 May 2019 12:36:39 +0000 (13:36 +0100)]
bbc-basic: Make metadata on string-like types work.

The new string handling makes this simpler than forbidding it.

5 years agobbc-basic: Radically simplify string storage.
Ben Harris [Sun, 26 May 2019 12:28:16 +0000 (13:28 +0100)]
bbc-basic: Radically simplify string storage.

Rather than having a separately indexed array of strings, S$(), with
its own free-list in S%(), we now keep string values in an array,
Z$(), whose indices parallel those in Z%(), so Z$(x) is the string
value of the object at Z%(x,y).  This saves a fair amount of
complexity at the expense of slightly more memory usage.

5 years agotest recursive definitions in let*
Nicolas Boulenguez [Sat, 25 May 2019 17:20:06 +0000 (19:20 +0200)]
test recursive definitions in let*

Detected while attempting to rewrite let* with fn*.

5 years agoada: fix unterminated string and creation of object directory by Make.
Nicolas Boulenguez [Wed, 22 May 2019 23:18:37 +0000 (01:18 +0200)]
ada: fix unterminated string and creation of object directory by Make.

5 years agoMerge pull request #371 from asarhaddon/extend-core.mal
Joel Martin [Tue, 21 May 2019 03:42:28 +0000 (22:42 -0500)]
Merge pull request #371 from asarhaddon/extend-core.mal

Extend core.mal

5 years agolib/tests: report parsing errors, move threading out of steps
Nicolas Boulenguez [Sun, 19 May 2019 17:20:20 +0000 (19:20 +0200)]
lib/tests: report parsing errors, move threading out of steps

When testing `foo.mal`, it makes sense to report parsing errors in
`foo.mal`.

Move tests of `->` and `->>` from `tests/step8_macros.mal` to
`tests/lib/theading.mal`.

Add `lib/trivial.mal`.

5 years agolib/ README.md should not repeat the process unless needed
Nicolas Boulenguez [Sun, 19 May 2019 17:17:55 +0000 (19:17 +0200)]
lib/ README.md should not repeat the process unless needed

5 years agoMerge pull request #382 from bjh21/bjh21-unterminated-string-fixes
Joel Martin [Sun, 19 May 2019 14:40:41 +0000 (09:40 -0500)]
Merge pull request #382 from bjh21/bjh21-unterminated-string-fixes

Unterminated string fixes: clojure, fantom, groovy, haxe, hy, io, java, julia, kotlin, livescript, matlab, miniMAL, objc, plpgsql, scala, vb, vimscript, yorick

5 years agoMerge pull request #383 from asarhaddon/ada2tco-do
Joel Martin [Sun, 19 May 2019 14:38:29 +0000 (09:38 -0500)]
Merge pull request #383 from asarhaddon/ada2tco-do

ada.2: optimize tail call recursion for last `do` evaluation

5 years agoMerge pull request #380 from bjh21/bjh21-bbc-basic
Joel Martin [Sun, 19 May 2019 14:29:27 +0000 (09:29 -0500)]
Merge pull request #380 from bjh21/bjh21-bbc-basic

BBC BASIC V implementation

5 years agovb: Detect more unterminated strings.
Ben Harris [Sun, 19 May 2019 10:57:54 +0000 (11:57 +0100)]
vb: Detect more unterminated strings.

I split the string-recognizing part of the read_atom regexp in two, one part for
recognising valid strings (using a fragment of the tokenising regexp) and
another to recognize invalid strings.  This follows the practice of other
implementations with a single read_atom regexp.

5 years agoobjc: Detect more unterminated strings.
Ben Harris [Sun, 19 May 2019 10:22:48 +0000 (11:22 +0100)]
objc: Detect more unterminated strings.

This is done by tightening the part of the read_atom regexp that
recognises valid strings.

5 years agomatlab: Detect more unterminated strings.
Ben Harris [Sun, 19 May 2019 10:00:26 +0000 (11:00 +0100)]
matlab: Detect more unterminated strings.

Rather than treating anything beginning and ending with '"' as a valid
string, we now use a regexp to detect a valid string and treat any other
token starting with '"' as an error.

This does not fix all of the bugs found by #359, though: there remains a
problem with long strings of backslashes in the input getting expanded
into too many backslashes in the resulting string.

5 years agominiMAL: Detect more unterminated strings.
Ben Harris [Sun, 19 May 2019 10:08:44 +0000 (11:08 +0100)]
miniMAL: Detect more unterminated strings.

Rather than treating anything beginning and ending with '"' as a valid
string, we now use a regexp to detect a valid string and treat any other
token starting with '"' as an error.

5 years agoplpgsql, scala, vimscript, yorick: Detect more unterminated strings.
Ben Harris [Sun, 19 May 2019 09:50:54 +0000 (10:50 +0100)]
plpgsql, scala, vimscript, yorick: Detect more unterminated strings.

This is achieved by tightening the regexp used to detect valid strings.

5 years agobbc-basic: Add a minimal Makefile.
Ben Harris [Sat, 18 May 2019 23:20:38 +0000 (00:20 +0100)]
bbc-basic: Add a minimal Makefile.

The automated testing system needs one.

5 years agobbc-basic: Travis and top-level README updates for new implementation.
Ben Harris [Sat, 18 May 2019 22:07:45 +0000 (23:07 +0100)]
bbc-basic: Travis and top-level README updates for new implementation.

5 years agobbc-basic: README updates.
Ben Harris [Sat, 18 May 2019 21:53:25 +0000 (22:53 +0100)]
bbc-basic: README updates.

5 years agobbc-basic: Find Brandy via ${BRANDY}, not ${SBRANDY}.
Ben Harris [Sat, 18 May 2019 21:46:27 +0000 (22:46 +0100)]
bbc-basic: Find Brandy via ${BRANDY}, not ${SBRANDY}.

The graphical versions work perfectly well here, so I don't think the
variable name should suggest the don't.  For instance, you might run:

BRANDY=brandy make repl^bbc-basic

5 years agobbc-basic: Support strings longer than the underlying interpreter allows.
Ben Harris [Sat, 18 May 2019 21:28:13 +0000 (22:28 +0100)]
bbc-basic: Support strings longer than the underlying interpreter allows.

Brandy supports strings up to 65536 characters long, but ARM BBC BASIC V
only allows strings up to 255 characters.  Mal needs strings longer than
255 characters, so we implement them by chaining together several
strings in S$() to make one logical string from mal's point of view.
This has entailed far-reaching changes as lots of routines that used to
take BASIC strings (especially in the reader/printer area) now have to
take references to mal strings instead.  There are still a lot of places
that don't, though, so you can't use long strings as hash-map keys, for
instance.

This commit passes all the tests, but I wouldn't be surprised if there
are still bugs lurking somewhere.

5 years agobbc-basic: Support '=' on hash-maps.
Ben Harris [Sat, 18 May 2019 13:44:04 +0000 (14:44 +0100)]
bbc-basic: Support '=' on hash-maps.

Now that keys are sorted, it's just case of comparing the list of keys
and the list of values.  In fact, two equal hash-maps will have
precisely the same internal structure, but the core library need not
know that.

5 years agobbc-basic: Properly sort hash-map keys.
Ben Harris [Sat, 18 May 2019 13:38:32 +0000 (14:38 +0100)]
bbc-basic: Properly sort hash-map keys.

This turned out to be quite twiddly, and the code isn't quite as
obviously correct as it was.  Still, it seems to work correctly.

5 years agobbc-basic: Iterative implementation of 'get' and 'contains?'.
Ben Harris [Sat, 18 May 2019 12:58:14 +0000 (13:58 +0100)]
bbc-basic: Iterative implementation of 'get' and 'contains?'.

There's no good reason for these to be recursive.  Also they can
easily share code.

5 years agobbc-basic: Wrap BASIC and OS errors in a hash-map when they're caught.
Ben Harris [Sat, 18 May 2019 05:18:02 +0000 (06:18 +0100)]
bbc-basic: Wrap BASIC and OS errors in a hash-map when they're caught.

This allows mal code to get at the error number (ERR), which is what it
should look at to determine the meaning of the error.

5 years agobbc-basic: Correct comment describing use of S%().
Ben Harris [Sat, 18 May 2019 04:32:20 +0000 (05:32 +0100)]
bbc-basic: Correct comment describing use of S%().

5 years agobbc-basic: Disallow metadata on string-like types.
Ben Harris [Sat, 18 May 2019 04:30:05 +0000 (05:30 +0100)]
bbc-basic: Disallow metadata on string-like types.

Objects that have a direct reference into S$() can't safely be cloned,
because the GC assumes that when such an object is freed, the string
in S$() can be freed as well.  This assumption would be broken by
cloning, so the cloning of such types by FNwith_meta must be
disallowed.

This has the unexpected, but in retrospect obvious, consequence that
single-member hashmaps can't have metadata.  That's obviously a bit
silly, so a more comprehensive solution is probably warranted in due
course.

5 years agobbc-basic: Detect running out of heap memory.
Ben Harris [Thu, 16 May 2019 23:58:15 +0000 (00:58 +0100)]
bbc-basic: Detect running out of heap memory.

This happens when the garbage collector runs but frees no memory.
Raising a polite error explains what happens and offers a theoretical
possiblity of an application's recovering.

5 years agobbc-basic: Ensure that "Escape" errors propagate beyond mal.
Ben Harris [Thu, 16 May 2019 23:35:02 +0000 (00:35 +0100)]
bbc-basic: Ensure that "Escape" errors propagate beyond mal.

Rather than printing an error message and ending the program, it's
better to turn off our error handler and then re-raise the error.  This
ensures that if, for instance, mal is started from the Supervisor in
RISC OS, the error gets propagated back to the Supervisor error handler
and displayed properly.

This required a slight adjustment to the top-level ON ERROR handler.

5 years agobbc-basic: Don't try to add "deb-src" entries in Dockerfile.
Ben Harris [Thu, 16 May 2019 09:33:03 +0000 (10:33 +0100)]
bbc-basic: Don't try to add "deb-src" entries in Dockerfile.

Apparently that wasn't necessary, and indeed broke the build, on other
systems.

5 years agobbc-basic: Create a suitable Dockerfile and adapt "run" script.
Ben Harris [Wed, 15 May 2019 21:20:56 +0000 (22:20 +0100)]
bbc-basic: Create a suitable Dockerfile and adapt "run" script.

The dockerfile uses the Ubuntu source package of Brandy to build a
text-only version for testing.  The "run" script no longer depends on
the existence of sbrandy in a particular place in my home directory.

5 years agobbc-basic: Minor README updates.
Ben Harris [Wed, 15 May 2019 19:47:52 +0000 (20:47 +0100)]
bbc-basic: Minor README updates.

5 years agobbc-basic: Refer to the trees we use for hash-maps as "crit-bit trees".
Ben Harris [Wed, 15 May 2019 19:45:50 +0000 (20:45 +0100)]
bbc-basic: Refer to the trees we use for hash-maps as "crit-bit trees".

That seems to be the generic term, with PATRICIA being a particular
early implementaion.

5 years agobbc-basic: Replace PROCmake_macro with FNas_macro.
Ben Harris [Wed, 15 May 2019 19:34:06 +0000 (20:34 +0100)]
bbc-basic: Replace PROCmake_macro with FNas_macro.

FNas_macro makes a copy of its argument, converted into a macro, by
analogy with FNas_list and FNas_vector.

5 years agobbc-basic: Change how empty collections work.
Ben Harris [Wed, 15 May 2019 19:26:36 +0000 (20:26 +0100)]
bbc-basic: Change how empty collections work.

Rather that recognising them by address, they now have a special bit
set in their type words.  That means that adding metadata to an empty
collection doesn't cause it to cease being properly empty.

5 years agobbc-basic: Remove unused PROClist_to_array and FNarray_to_list.
Ben Harris [Wed, 15 May 2019 00:03:52 +0000 (01:03 +0100)]
bbc-basic: Remove unused PROClist_to_array and FNarray_to_list.

5 years agobbc-basic: Upgrade to the gensym-based 'or'.
Ben Harris [Tue, 14 May 2019 22:21:34 +0000 (23:21 +0100)]
bbc-basic: Upgrade to the gensym-based 'or'.

5 years agobbc-basic: Allow metadata on non-function types.
Ben Harris [Tue, 14 May 2019 22:19:26 +0000 (23:19 +0100)]
bbc-basic: Allow metadata on non-function types.

This is currently broken, but it passes all the tests, so I'll need
some better tests.

5 years agobbc-basic: Add 'seq' core function.
Ben Harris [Tue, 14 May 2019 22:17:21 +0000 (23:17 +0100)]
bbc-basic: Add 'seq' core function.

5 years agobbc-basic: Add 'string?', 'number?', 'fn?', and 'macro?' core functions.
Ben Harris [Tue, 14 May 2019 22:07:14 +0000 (23:07 +0100)]
bbc-basic: Add 'string?', 'number?', 'fn?', and 'macro?' core functions.

5 years agobbc-basic: Implement 'conj' core function.
Ben Harris [Tue, 14 May 2019 22:00:52 +0000 (23:00 +0100)]
bbc-basic: Implement 'conj' core function.

5 years agobbc-basic: Add 'time-ms' core function.
Ben Harris [Tue, 14 May 2019 21:54:12 +0000 (22:54 +0100)]
bbc-basic: Add 'time-ms' core function.

It uses TIME, since that's easily available on all platforms.

5 years agobbc-basic: Add step A to the RISC OS tokenizing script.
Ben Harris [Tue, 14 May 2019 21:53:31 +0000 (22:53 +0100)]
bbc-basic: Add step A to the RISC OS tokenizing script.

5 years agobbc-basic: Pass '-path' to Brandy so self-hosting tests find libraries.
Ben Harris [Mon, 13 May 2019 23:22:22 +0000 (00:22 +0100)]
bbc-basic: Pass '-path' to Brandy so self-hosting tests find libraries.

5 years agobbc-basic: Enlarge the reader token buffer again.
Ben Harris [Mon, 13 May 2019 23:13:12 +0000 (00:13 +0100)]
bbc-basic: Enlarge the reader token buffer again.

The later self-hosting steps are quite large.

5 years agobbc-basic: Stub implementations of optional step A core functions.
Ben Harris [Mon, 13 May 2019 23:10:56 +0000 (00:10 +0100)]
bbc-basic: Stub implementations of optional step A core functions.

These need to be present (but not functional) for the self-hosted mal to work.

5 years agobbc-basic: Simplify type codes.
Ben Harris [Mon, 13 May 2019 22:27:07 +0000 (23:27 +0100)]
bbc-basic: Simplify type codes.

Z%(x,2) and Z%(x,3) are always pointers or nil, so there's no need to
record whether they're used: FNgc_mark can just unconditionally mark
them.  This means that the only interesting question is whether Z%(x,1)
is a pointer, a string, or something else, which can be encoded in two
bits.  This still leaves us using five bits for the type code, but I
think the avoidance of special-case code is worth spending a bit on.

5 years agobbc-basic: Simplify 'first' and 'rest'.
Ben Harris [Mon, 13 May 2019 22:06:12 +0000 (23:06 +0100)]
bbc-basic: Simplify 'first' and 'rest'.

Rather than special-casing the empty list/vector, arrange that the
dedicated empty list/vector objects have the correct values in their
first and rest pointers.  Still dithering about whether to do that
to 'nil' as well.

This does mean that the internal FNfirst and FNrest don't error on an
empty list any more.  Nothing should have depended on that, but it might
mask some bugs.

5 years agobbc-basic: Add the README file that I've had kicking around for a while.
Ben Harris [Sun, 12 May 2019 23:14:33 +0000 (00:14 +0100)]
bbc-basic: Add the README file that I've had kicking around for a while.

5 years agobbc-basic: Increase reader token buffer again to 1024.
Ben Harris [Sun, 12 May 2019 23:07:47 +0000 (00:07 +0100)]
bbc-basic: Increase reader token buffer again to 1024.

Running the self-hosting tests looks to require this.

5 years agobbc-basic: Add '*host-language*' and a startup banner.
Ben Harris [Sun, 12 May 2019 22:54:28 +0000 (23:54 +0100)]
bbc-basic: Add '*host-language*' and a startup banner.

5 years agobbc-basic: Metadata support, including 'meta' and 'with-meta'.
Ben Harris [Sun, 12 May 2019 22:49:51 +0000 (23:49 +0100)]
bbc-basic: Metadata support, including 'meta' and 'with-meta'.

5 years agobbc-basic: Redesign storage of functions to use two cells.
Ben Harris [Sun, 12 May 2019 22:43:48 +0000 (23:43 +0100)]
bbc-basic: Redesign storage of functions to use two cells.

Functions were the only type using all three columns of Z%().  By
reducing that to two (at the expense of spreading a function over two
cells), we make space for storing a metadata pointer in Z%(x,3) of all
types.

5 years agobbc-basic: Add 'readline' core function.
Ben Harris [Sun, 12 May 2019 21:53:53 +0000 (22:53 +0100)]
bbc-basic: Add 'readline' core function.

5 years agobbc-basic: Beginning of step A.
Ben Harris [Sun, 12 May 2019 21:46:41 +0000 (22:46 +0100)]
bbc-basic: Beginning of step A.

5 years agobbc-basic: Make sure that '&' parameters are in a list, not a vector.
Ben Harris [Sun, 12 May 2019 21:08:03 +0000 (22:08 +0100)]
bbc-basic: Make sure that '&' parameters are in a list, not a vector.

5 years agobbc-basic: Add 'dissoc' and 'vals' core functions.
Ben Harris [Sun, 12 May 2019 20:52:15 +0000 (21:52 +0100)]
bbc-basic: Add 'dissoc' and 'vals' core functions.

5 years agobbc-basic: Add 'assoc' and 'keys' core functions.
Ben Harris [Sun, 12 May 2019 17:28:38 +0000 (18:28 +0100)]
bbc-basic: Add 'assoc' and 'keys' core functions.

'hash-map' is now implemented in terms of 'assoc'.

5 years agobbc-basic: Add 'get' and 'contains?' core functions.
Ben Harris [Sun, 12 May 2019 17:06:54 +0000 (18:06 +0100)]
bbc-basic: Add 'get' and 'contains?' core functions.

5 years agobbc-basic: Adjust heap size so that step 8 doesn't suffer a stack overflow.
Ben Harris [Sun, 12 May 2019 15:54:14 +0000 (16:54 +0100)]
bbc-basic: Adjust heap size so that step 8 doesn't suffer a stack overflow.

5 years agobbc-basic: PATRICIA hashmaps now mostly working. Stack overflow in step 8.
Ben Harris [Sun, 12 May 2019 12:57:32 +0000 (13:57 +0100)]
bbc-basic: PATRICIA hashmaps now mostly working.  Stack overflow in step 8.

5 years agobbc-basic: PATRICIA hashmaps now working up to step 2.
Ben Harris [Sun, 12 May 2019 12:34:26 +0000 (13:34 +0100)]
bbc-basic: PATRICIA hashmaps now working up to step 2.

5 years agobbc-basic: Start of conversion to PATRICIA hashmaps: single-element hash-maps.
Ben Harris [Sun, 12 May 2019 10:19:03 +0000 (11:19 +0100)]
bbc-basic: Start of conversion to PATRICIA hashmaps: single-element hash-maps.

Not very useful, but enough to pass step 1.

5 years agobbc-basic: Rework of type identifiers to be more semantically useful.
Ben Harris [Sun, 12 May 2019 09:45:49 +0000 (10:45 +0100)]
bbc-basic: Rework of type identifiers to be more semantically useful.

Now the bottom four bits indicate the semantics of the various columns
of Z%, so the garbage collector can operate with no knowledge of any
specific types.  Instead, it can directly tell which fields need
followed when marking, and which represent strings to be freed.

5 years agobbc-basic: Implement 'hash-map' and 'map?' core functions.
Ben Harris [Sat, 11 May 2019 20:46:24 +0000 (21:46 +0100)]
bbc-basic: Implement 'hash-map' and 'map?' core functions.

5 years agobbc-basic: Correct error for core function argument not being a string.
Ben Harris [Sat, 11 May 2019 20:45:38 +0000 (21:45 +0100)]
bbc-basic: Correct error for core function argument not being a string.

5 years agobbc-basic: Make FNhashmap_contains, FNhashmap_get, and FNenv_find iterative.
Ben Harris [Sat, 11 May 2019 20:17:46 +0000 (21:17 +0100)]
bbc-basic: Make FNhashmap_contains, FNhashmap_get, and FNenv_find iterative.

Since BASIC doesn't do tail-call optimisation, we were needlessly
burning a lot of stack.

Now passes all tests (including deferrable and optional) up to step 8.

5 years agobbc-basic: Enlarge token buffer to 512 entries.
Ben Harris [Sat, 11 May 2019 19:32:50 +0000 (20:32 +0100)]
bbc-basic: Enlarge token buffer to 512 entries.

core.mal needed more than the 255 we allowed before.

5 years agobbc-basic: Add support for hash-maps to FNeval_ast (deferred from step 2).
Ben Harris [Sat, 11 May 2019 16:30:18 +0000 (17:30 +0100)]
bbc-basic: Add support for hash-maps to FNeval_ast (deferred from step 2).

5 years agobbc-basic: Simplify reader-macro code using FNalloc_list2.
Ben Harris [Sat, 11 May 2019 16:04:27 +0000 (17:04 +0100)]
bbc-basic: Simplify reader-macro code using FNalloc_list2.

5 years agobbc-basic: Add support for '^' reader macro.
Ben Harris [Sat, 11 May 2019 16:02:19 +0000 (17:02 +0100)]
bbc-basic: Add support for '^' reader macro.

5 years agobbc-basic: Reading and printing support for hash-maps (deferred from step 1).
Ben Harris [Sat, 11 May 2019 15:47:12 +0000 (16:47 +0100)]
bbc-basic: Reading and printing support for hash-maps (deferred from step 1).

5 years agobbc-basic: '*ARGV*' support when running under RISC OS.
Ben Harris [Sat, 11 May 2019 14:36:57 +0000 (15:36 +0100)]
bbc-basic: '*ARGV*' support when running under RISC OS.

This uses OS_GetEnv to get the command line, and OS_GSTrans to split it
into words, discarding the usual prefix for a BASIC program.