1
1
mirror of https://github.com/kanaka/mal.git synced 2024-10-26 14:22:25 +03:00
Commit Graph

287 Commits

Author SHA1 Message Date
Andy Chu
02028e90a4 impls/bash: Minor changes to make it run under OSH
OSH is a bash-compatible shell: https://www.oilshell.org/

reader.sh:

- Put the constant regex pattern in a string literal.  This simplifies
  it by removing mixed regex vs. shell quoting, and implicit
  concatenation with $'\n'.

  This is suggested by the bash manual:
  https://www.gnu.org/software/bash/manual/bash.html#Conditional-Constructs

  "Storing the regular expression in a shell variable is often a useful
  way to avoid problems with quoting characters that are special to the
  shell."

- Initialize __reader_tokens as an array, not a string.

  https://www.oilshell.org/release/0.8.pre6/doc/known-differences.html#values-are-tagged-with-types-not-cells

env.sh:

Simplify quoting in 'eval' expressions.  This quotes associative array keys,
which is required by OSH to avoid dynamic parsing.

  https://www.oilshell.org/release/0.8.pre6/doc/known-differences.html#strings-vs-bare-words-in-array-indices
  http://www.oilshell.org/blog/2016/10/20.html

core.sh:

Quote associative array keys.  '<' and '>' are shell operators and OSH doesn't
have a special case when inside [].

----

With this change, OSH can run tests just like bash, e.g.:

$ osh impls/bash/stepA_mal.sh tests/step4_if_fn_do.mal

----

Test results are the same before and after this change:

$ NO_DOCKER=1 ./.travis_test.sh test bash

FAILURES:
SOFT FAILED TEST (line 295): (f (+ 1 1)) -> ['',true]:
    Expected : '.*\ntrue'
    Got      : '(f (+ 1 1))\nfalse'

TEST RESULTS (for ../tests/stepA_mal.mal):
    1: soft failing tests
    0: failing tests
  106: passing tests
  107: total tests
2020-06-13 10:57:13 -07:00
Joel Martin
73a159ad78
Merge pull request #497 from alimpfard/xslt
XSLT impl
2020-06-01 14:27:47 -05:00
AnotherTest
a135441218 XSLT: Use blocking reads instead of a polling thread 2020-06-01 23:47:33 +04:30
AnotherTest
43c2dd50e5 XSLT impl: Limit jvm memory to 2GB 2020-05-30 23:37:21 +04:30
AnotherTest
80e3d5eb0b Break some lines to make the code more readable 2020-05-30 23:37:21 +04:30
AnotherTest
4c9d183230 only print last result if in repl 2020-05-30 23:37:21 +04:30
AnotherTest
fd99084ca6 no more infinite boot times!
move the repl inside XSLT itself, as a result, we'll exit the repl
after 100000000 iterations, but...that's probably enough for a lot
of things
2020-05-30 23:37:21 +04:30
AnotherTest
e4882d7d71 attempt to speed execution up
by booting up multiple instancees of saxon, waiting for a signal
This doesn't really help much, since most of our tests are very small
however, it does lower the overall boot time (assuming travis can do
real concurrency)
2020-05-30 23:37:21 +04:30
AnotherTest
73e80a3974 ...add default target back 🤦
I'm sorry, travis....
2020-05-30 23:37:21 +04:30
AnotherTest
645a03553a makefile tweak to avoid failure~ 2020-05-30 23:37:21 +04:30
AnotherTest
a1252d40dd eliminate unnecessary env serialisations
gains about 40% performance (on average?)
2020-05-30 23:37:21 +04:30
AnotherTest
1c2f45cfe5 format all xslt files 2020-05-30 23:37:21 +04:30
AnotherTest
92ff68a8b1 remove irrelevant comment 2020-05-30 23:37:20 +04:30
AnotherTest
0365ac1252 we can now self-host 🎉 2020-05-30 23:37:20 +04:30
AnotherTest
8ff20ab862 try to avoid spammy "No such file or directory" errors
it doesn't happen on my machine, not sure why it does that
2020-05-30 23:37:20 +04:30
AnotherTest
64eb1e7d56 we can now self-host...almost
Atoms still need some ironing out, something is not updating them
properly
Also unknown is an issue where `def!` is not updating the env, probably
related to the above problem
2020-05-30 23:37:20 +04:30
AnotherTest
091b0e0518 apply @kanaka's patch to Dockerfile 2020-05-30 23:37:20 +04:30
Joel Martin
13404d9173
Merge pull request #514 from alimpfard/jq-fix
Jq: Fix our share of #513
2020-05-29 20:53:22 -05:00
AnotherTest
ada8c52f53 Jq: Fix our share of #513 2020-05-30 06:02:26 +04:30
Ben Harris
42db60dc13 yorick: Fix evaluation of empty vectors in steps 2 and 3
This is achieved simply by propagating the code to detect empty vectors
(and lists, though I suspect that is unused) back from step 4 to the
earlier steps.
2020-05-29 09:57:33 +01:00
Ben Harris
a8e337b291 Step 2: Test empty vectors and hash-maps
An empty vector or hash-map should evaluate to itself, but I reached
the test of (empty? []) in step 4 before I discovered that I'd got []
evaluating to 0.  Add tests for both cases to step 2.
2020-05-28 11:28:38 +01:00
AnotherTest
f130c9a2f0 add a dockerfile with saxon in it 2020-05-24 02:27:17 +04:30
AnotherTest
c77e046409 be more spec-compatible with readline 2020-05-24 02:27:17 +04:30
AnotherTest
4c50b6736b add 'xpath-eval', and fix most running issues
- step7 still has the replEnv-values-are-not-captured issue
2020-05-24 02:27:17 +04:30
AnotherTest
d83ad64a13 fix (fn? +) ;=> false 2020-05-24 02:27:17 +04:30
AnotherTest
607023b703 rebase to kanaka/mal 2020-05-24 02:27:17 +04:30
Joel Martin
5952e9dcc9
Merge pull request #506 from gabrielmadruga/master
Update and fixes for the lua implementation.
2020-05-21 18:39:49 -05:00
Joel Martin
73cd4374ba
Merge pull request #508 from bjh21/bjh21-throwtests
Add tests for nested exception handlers
2020-05-21 18:07:15 -05:00
Ben Harris
e069ddff67 ps: Fix handling of exceptions thrown from catch* clause
PostScript's exception handling doesn't restore the dictionary or
operand stacks to the state they were in when the "stopped" operator
started, so mal's EVAL needs to do that itself.  To do this, it records
the current height of the stacks, but of course it does that in a
dictionary.  This means that when catching at exception, it relies on
the highest instance of "dictcnt" on the dictionary stack being the
correct one.  EVAL, however, was failing to restore the dictionary stack
at the right time.

For instance, conside this code (from the tests):

  (try* (try* (throw "e1") (catch* e (throw "e2"))) (catch* e "c2"))

Each "try*" clause saves "dictcnt" into a dictionary on the dictionary
stack.  When the inner "catch*" clause fires, it pops the dictionary and
operand stacks to the correct point, but then calls the second "throw"
with the wrong value of "dictcnt" still visible.  The result is that the
"catch*" clause ends up running with the wrong value of "dictcnt" and
restoring the stacks to the wrong place, essentially executing the
_inner_ "catch*" clause again, whereupon the error doesn't get caught
because there's no "stopped" left on the PostScript execution stack.

The fix is to add another dictionary that's just used to hold "dictcnt"
and "stackcnt", and to pop that from the dictionary stack as soon as the
stacks have been restored (or when it becomes unnecessary because the
"try*" clause has returned normally).
2020-05-21 21:21:55 +01:00
Ben Harris
5fb74d336f Add tests for nested exception handlers
When implementing exceptions on top of longjmp() or similar, it's
necessary to make sure that exception handlers get properly restored
after the try* clause, and none of the existing step 9 tests covered
this.

There are two cases covered here: throwing an exception after a
successful try*, and throwing and exception from within a catch*.  In
both cases we make sure that an outer catch* does its job.
2020-05-19 10:28:21 +01:00
Gabriel M
d4fc4551a0 Change os.clock multiplier, update Dockerfile to use lua 5.3.5.5 2020-05-17 14:23:54 -03:00
Gabriel M
e2b93732eb Change \177 to \u{029e}, correctly define keyword, change loadstring to load 2020-05-15 23:09:09 -03:00
Gabriel M
a62a56f535 Add lrexlib-pcre through luarocks. 2020-05-15 22:04:45 -03:00
Gabriel M
783823f191 Remove usage of socket 2020-05-15 22:04:27 -03:00
Gabriel M
c2aba1b404 Lua Makefile improvements.
Clean lib folder, and find linenoise.so.
2020-05-15 14:32:55 -03:00
Ben Harris
d98d5c3b09 Step 6: Test read-string of a single atom at the end of input
All of the other read-string tests test forms whose end can be detected
before the end of the input string, either because they're naturally
self-terminating (lists, strings) or because there's white space after
them.  All of the uses of the reader from the REPL are similarly likely
to have input with a newline or similar at the end.

My BCPL implementation turned out to read one character past the end of
the input when the input ended inside an atom, and to incorporate that
one byte into the output.  The consequences of a buffer over-read are a
little unpredictable, so I've just written a test that was good enough
to catch the bug for me.
2020-05-10 14:30:09 +01:00
Joel Martin
8a19f60386 Move implementations into impls/ dir
- Reorder README to have implementation list after "learning tool"
  bullet.

- This also moves tests/ and libs/ into impls. It would be preferrable
  to have these directories at the top level.  However, this causes
  difficulties with the wasm implementations which need pre-open
  directories and have trouble with paths starting with "../../". So
  in lieu of that, symlink those directories to the top-level.

- Move the run_argv_test.sh script into the tests directory for
  general hygiene.
2020-02-10 23:50:16 -06:00