1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-19 17:47:53 +03:00
Commit Graph

3825 Commits

Author SHA1 Message Date
Nicolas Boulenguez
9a22e8a653 lua: merge eval and eval AST 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
56252444c8 lua: remove a safe but unneeded code line from Env::new 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
f15b7b4f10 lua: introduce a printer._pr_seq helper 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
15c7be28ec lua: improve consistency of keyword handling 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
91f2156ae6 lua: call hash_map instead of reimplementing it 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
3e8079e7b1 lua: simplify Makefile 2024-08-26 10:00:47 -05:00
Nicolas Boulenguez
309731037e lua: update Dockerfile 2024-08-26 10:00:47 -05:00
Joel Martin
74efdd942e README: fix mode after python2/python3 renaming 2024-08-26 09:58:34 -05:00
Nicolas Boulenguez
688503d2cc Rename python implementations to python2 and python3, see #665 2024-08-26 09:57:14 -05:00
Nicolas Boulenguez
87b283a350 python.2: fix tests, use source checkers and more python3 features
Check the whole code with flake8, pylint and mypy.

Report all possible errors with extensive context.

Demonstrate iterators, decorators, functional tools, chain maps,
dataclasses, match statements, assignments expressions.

Implement environments with python chain maps.

Rewrite the reader without external dependencies (but inspired by the
ptk library).  The motivation was that no external library is fully
type-checked for now.

Avoid name clashes when possible (print, read, readline, types).

Write the readline history file at exit, not after each prompt.

Replace printer.pr_str as methods of MAL objects.  This is idiomatic
python, and improves the error reporting.

Change some representations so that the python equality matches the
MAL equality.  The recursion is now implicit.

Remove -O from ./run.  It took me a while to understand that run-time
assertions were disabled!  MAL is about development, not performance.

Dispatch the special forms from a dict, for readability (pylint
rightfully complains that there are too many return statements in
eval_()).

Copy the recursion overflow fix, the python interaction from the first
python implementation.

Add tests detecting that nil false 0 () [] "" are distinct, and that 0
() are not False when tested (in python False == 0 and an empty
container is tested ).

Add tests checking that metadata does not affect equality (they do
with a naive python dataclass).
2024-08-24 10:16:32 -05:00
老刘
db7c10a689 vbs: remove NO_SELF_HOST for run self-host test on Github Action 2024-08-24 10:05:34 -05:00
老刘
3e040b4946 vbs: modify run for Github Action test 2024-08-24 10:05:34 -05:00
Joel Martin
3307f07dfa GHA: self-host by default. Skip jq, nasm, powershell, xslt, vbs
Xslt may never be able to do full self-hosted tests. Powershell succeeds
but doubles the total runtime for the GHA workflow.

We would definitely like jq, nasm, and possibly vbs to be fixed for
self-hosted tests.
Ticket tracking fixes: https://github.com/kanaka/mal/issues/662
2024-08-22 17:05:19 -05:00
Joel Martin
fd626a7317 GHA: add self-hosted step for windows jobs.
Add --no-pty to self-hosted vbs/vbscript TEST_OPTS
2024-08-22 15:51:24 -05:00
Joel Martin
78006357e9 .gitignore: add xslt history, .local, zig-cache. 2024-08-22 14:59:33 -05:00
Joel Martin
12cb3fca2b GHA, ci.sh: dump debug log in separate step.
- In ci.sh just print the path to the debug log file on errors.
- In GHA workflow, dump the debug log in a separate final step if there
  were errors. This will make it more usable for tracking down errors.
2024-08-22 14:59:33 -05:00
Joel Martin
e9dd8c53e5 sml: fix mlton self-host. Full syntax err in catch*
In mlton mode, syntax errors caught in the try/catch block were being
processed as "SyntaxError" without any additional context/message.
Explicitly pass the full message always.
2024-08-22 14:59:33 -05:00
Joel Martin
a2973ab0b8 xslt, c, zig: test for, fix seq parsing EOF errors
xslt:
- The reader was returning the an odd args error when a hash-map literal
  was not closed. This was because the the parsing error happened and
  then the odd args test happened after and overwrote the parsing error.
- Also, fix the read-string function so that if an error is set by the
  reader, this is converted to a full error that bubbles up.

c:
- read_list errors were not being detected/propagated in read_hash_map
  after calling read_list.

zig:
- reader errors were not being caught in the rep loop until step 8, so
  those errors in step6 and step7 were causing the REPL to exit.
2024-08-22 14:59:33 -05:00
Joel Martin
39563fdf7d vala: fix self-host: fix defmacro! return value.
The mal implementation uses the defmacro! function from the host
language/environment and assumes that it returns a macro function (and
ignores the environment modification effect). The vala implementation
was setting the is_macro flag at the wrong time so that the final
returned value from defmacro! was a function without the macro flag set.

Also, add a deferrable test of `defmacro!` to make sure it returns
a macro.
2024-08-21 09:29:40 -05:00
Joel Martin
a160866767 ps: return one value from macro? (fixes self-host)
In the false case, macro? was returning the input and false instead of
just false (missing pop for the false case).
2024-08-20 09:26:04 -05:00
Joel Martin
78000d6d9e powershell: fix self-host. Add fn? and [nil] tests.
Two problems were causing powershell self-hosting to fail:
* Some mal core functions are declared using `Get-Command` to hoist the
  lower level function and this didn't work with the `fn?` command. So
  add a stepA test for `(fn? list?)` and fix the `fn?` command to check for
  CommandInfo types too.
* A list with a single `$null` is treated specially by Powershell in
  a pipeline and was resulting in an empty Vector anywhere that `[nil]`
  was evaluated. Change all the pipelined uses of `ForEach` to
  `ForEach-Object` and wrap the result in an array construct `@( ... )`.
  Add a step2 test to make sure that `[nil]` is evaluated correctly.
2024-08-19 15:39:23 -05:00
Joel Martin
40aca13680 common-lisp: (list? nil) should be false (add test)
In common-lisp, self-hosted test4 was failing and it appeared that nil
and empty list () were being conflated. The root cause is that in
common-lisp the form `(list? nil)` was returning true. Fix this in the
core `list?` function.

There was no test for this case so add one to step4 tests.
2024-08-19 09:30:53 -05:00
Joel Martin
b31180cfd2 java,kotlin: fix double eval of last do position.
These implementations were double evaluating the last position of a do
form (off by one). Mostly this is just a performance issue until you
have something with side-effect in the last position such as prn's,
swap!'s or readline's. In self-hosted mode this become apparent with
large chunks of mal code in the last position. The symptoms were
repeated prns and multiple levels of readline being called, etc.

Add a step6 test that uses atoms to test this (should be in step
4 using prn side-effects but it's difficult to match across multiple
lines in a cross-platform way so we test using an atom in step6.

Also, remove cast in Kotlin that was causing a compile warning.
2024-08-19 09:01:41 -05:00
Joel Martin
7b23c7ed61 c.2/cpp/dart/swift5: fix try/TCO double eval bug
The try block needs to happen and be returned and not continue the TCO
loop. If it does then the successful result of a try block gets
evaluated an extra time so something like this `(try* (list 1) (catch*
e (prn :e e)))` will cause an exception. If an exception occurs, then
the catch block of a try/catch can loop/TCO without issue but not the
initial try form/block.
2024-08-18 15:27:51 -05:00
Joel Martin
412e50e306 common-lisp: update ubuntu 24.04. Fix key hashing bug.
Newer versions of sbcl now have the same sxhash issue on compound types
as the other common lisp implementations. So always dereference the
underlying base type when generating a hash. This fixes the bug in newer
sbcl that was resulting in `get` and `contains?` not working for
hash-maps.
2024-08-15 14:02:32 -05:00
老刘
b57cd56717 vbs: Handle cherry-pick conflicts 2024-08-15 09:15:44 -05:00
老刘
08856c34b5 vbs: Update the implementation counts 2024-08-15 09:15:44 -05:00
老刘
a8f59bfd6c vbs: Update 'io.vbs' 2024-08-15 09:15:44 -05:00
老刘
492336110c vbs: Merge branch 'kanaka:master' into master 2024-08-15 09:15:44 -05:00
老刘
a416719a57 vbs: rewrite stepA & core with IOWrap 2024-08-15 09:15:44 -05:00
老刘
ca9d6ee043 vbs: rewrite step9 using IOWrap 2024-08-15 09:15:44 -05:00
老刘
c6023577eb vbs: rewrite step8 using IOWrap 2024-08-15 09:15:44 -05:00
老刘
f4d2d91bb9 vbs: rewrite step7 using IOWrap 2024-08-15 09:15:44 -05:00
老刘
521fa87208 vbs: rewrite step6 using IOWrap 2024-08-15 09:15:44 -05:00
老刘
22a23d9c2a vbs: rewrite step5 using IOWrap 2024-08-15 09:15:44 -05:00
老刘
6e33dc8c3f vbs: rewrite step4 using IOWrap 2024-08-15 09:15:44 -05:00
老刘
176eca9c6a vbs: rewrite step3 using IOWrap 2024-08-15 09:15:44 -05:00
老刘
e8cf3057cd vbs: rewrite step2 use IOWrap 2024-08-15 09:15:44 -05:00
老刘
80e49c0509 vbs: Update io.vbs for avoid error 2024-08-15 09:15:44 -05:00
老刘
08b267b7f2 vbs: rewrite step1's IO with IOWrap 2024-08-15 09:15:44 -05:00
老刘
2a6174da20 vbs: rewrite step0 use IOWrap for test 2024-08-15 09:15:44 -05:00
老刘
b6503412ce vbs: Restore runtest.py 2024-08-15 09:15:44 -05:00
老刘
79aac15158 vbs: impl IOWrap class in io.vbs 2024-08-15 09:15:44 -05:00
老刘
5d55568c9c vbs: import variable MAL_VBS_IMPL_NO_STDERR & MAL_VBS_IMPL_ECHO_STDIN 2024-08-15 09:15:44 -05:00
老刘
7e7ff1fbca vbs: test WSH.Echo "\nuser>" 2024-08-15 09:15:44 -05:00
老刘
252bd160f2 vbs: Merge branch 'kanaka:master' into master 2024-08-15 09:15:44 -05:00
老刘
c91cc0ace7 vbs: uncomment impls for Action test 2024-08-15 09:15:44 -05:00
老刘
f4e63facdc vbs: remove runtest_backup.py 2024-08-15 09:15:44 -05:00
老刘
512579cab1 vbs: remove run.cmd 2024-08-15 09:15:44 -05:00
老刘
bb92d26d0f vbs: test step6 in github action success 2024-08-15 09:15:44 -05:00