1
0
mirror of https://github.com/janet-lang/janet synced 2024-06-30 17:13:15 +00:00
Commit Graph

893 Commits

Author SHA1 Message Date
Jon Staab
40e6616df0 Add support for delete key in repl 2019-11-16 16:01:52 -08:00
Calvin Rose
bcd2089f71 Version 1.5.1 2019-11-16 17:17:13 -06:00
Calvin Rose
7553b277db Fix return value of update. 2019-11-16 15:50:21 -06:00
Calvin Rose
c9521e093e Fix windows issue with (file/read file :all)
When file was created with file/popen, the current optimization
of using fseek on windows fails due to windows not properly returning
and error code and just returning 0. Windows :(.
2019-11-11 20:05:00 -05:00
Calvin Rose
16f6261b44 Improve randomness of numbers from new rng.
First few numbers are very biased.
2019-11-10 17:44:59 -06:00
Calvin Rose
6b76ac3d18 Fix bug when appending buffer to self.
janet_to_string_b had a bug when printing buffers.
2019-11-10 14:57:09 -06:00
Calvin Rose
0d2844b7c9 Update to 1.5.0 2019-11-10 10:57:18 -06:00
Calvin Rose
719f7ba0c4 Default to UTC for date. 2019-11-09 16:57:21 -06:00
Calvin Rose
c9292ef648 Use /MD on windows.
Just makes things easier. Assume machines have msvcrt.dll
on them. If not, we can add msvcrt.dll to the dist folder and add to
installer.
2019-11-09 16:05:07 -05:00
Calvin Rose
dca247f01d Fix MSVC build warnings. 2019-11-09 10:12:40 -06:00
Calvin Rose
63e7ca4623 Fix warning on travis CI with Clang. 2019-11-09 10:10:07 -06:00
Calvin Rose
1f55d40a10 Fix janet_opt* api.
Inverted conditional made behavior incorrect. These
were not used in the core library, so were not tested.
2019-11-09 09:39:14 -06:00
Calvin Rose
aee1687215 Add RNG functionality to the math/ module.
The new RNG wraps up state for random number generation, so
one can have many rngs and even marshal and unmarshal them.
Adds math/rng, math/rng-uniform, and math/rng-int.

Also introduce `in` and change semantics for
indexing out of range. This commit enforces stricter
invariants on keys when indexing via a function call
on the data structure, or the new `in` function.

The `get` function is now more lax about keys, and will
not throw an error when a bad key is used for a data structure, instead
returning the default value.
2019-11-08 17:40:04 -06:00
Calvin Rose
9b605b27bd Address #174 - fix string/trim 2019-11-08 08:47:37 -06:00
Calvin Rose
c5010dffb4 Print error message on bad CLI usage.
This was a small regression when bundling cli-main
into boot.janet.
2019-11-05 12:51:15 -06:00
Calvin Rose
026f26f05f Improve error message in slice functions.
Check the first argument before trying to do range
checks.
2019-11-05 09:41:30 -06:00
Calvin Rose
cf2d3861d6 Make slice a c function.
This will allow future integration into the compiler
for more general destructuring.
2019-11-05 09:29:32 -06:00
Calvin Rose
6ceaf9d28d Add with-vars
This helps for temporarily setting vars in a safe
manner that is guaranteed not to leave vars in a bad state
(assuming that a fiber does not emit debug or use signal and
 is never resumed).
2019-10-31 21:58:43 -05:00
Calvin Rose
280dca3998 Add shell.c to the amalgamation.
This allows easy builds of the full interpreter with no
build system.

  1. Get janet.c, janet.h, janetconf.h, and shell.c in a directory. Edit
     janetconf.h as desired.
  2. gcc shell.c janet.c -lm -ldl -O2 -o janet (on GNU-Linux for example)
  3. ./janet -h (Yay!)
2019-10-29 19:18:44 -05:00
Calvin Rose
427b2638e0 Fix startup environment. 2019-10-29 18:47:54 -05:00
Calvin Rose
2541806dc1 Fix suite7 failing when run with no docstrings. 2019-10-29 18:28:41 -05:00
Calvin Rose
0d16b9e1a1 Move init.janet into cli-main in boot.janet
This makes it easier to get the CLI functionality when
embedding Janet, although the main reason is the init script
is now pre-compiled to bytecode when generating the boot image.
2019-10-29 18:16:32 -05:00
Calvin Rose
45c2819068 Improve flychecking.
Flychecking will now work correctly with arity checking, and
will better handle imports. Well structured modules should interact
cleanly with the flychecker in a mostly safe manner, but maliciously
crafted modules can execute arbitrary code. As such, the flychecker is
not a good way to validate completely untrusted modules.

We also extend run-context with an :evaluator option to replace
:compile-only. This is more flexible and allows users to create their
own flychecker like functionality.
2019-10-27 16:15:41 -05:00
Calvin Rose
d28925fdab Relax type checking when fuction position is nil
This lets the flychecker work as expected.
2019-10-24 15:17:19 -05:00
Calvin Rose
9097e36ea0 [] should evaluate to ()
This is consistent with most bracket tuples.
2019-10-20 14:06:28 -05:00
Calvin Rose
423b6db855 Fix memory leak with some string/ functions.
kmp_init leaked memory when called with an empty string.
2019-10-19 15:14:19 -05:00
Calvin Rose
bb54b940c0 Don't call fwrite with size = 0 2019-10-19 10:51:11 -05:00
Calvin Rose
8dd8af742a Add eprintf and make printf a C function.
This allows some more optimizations when printing to
buffers or when output is disabled. It also makes printf
more consistent with print and prin (Same with eprintf).
2019-10-19 10:30:29 -05:00
Calvin Rose
d47804d222 Add prin, eprint, and eprin functions.
The print family of functions now writes output
to an optional buffer instead of a file bound to :out.
This means output can be more easily captured an redirected.
2019-10-19 09:44:27 -05:00
Calvin Rose
8dd322c0be Fix webclient. 2019-10-14 20:55:04 -05:00
Calvin Rose
7fd0748c19 Update to 1.4.0 2019-10-14 20:35:13 -05:00
Calvin Rose
5f51476526 Remove a git attribute for linguist. 2019-10-12 22:03:34 -05:00
Calvin Rose
a18a251d16 Address some issues found in lgtm
Caught a few potentially issues with overflows, as well as use of
unsafe function localtime.
2019-10-10 22:59:43 -05:00
Calvin Rose
54b66a4199 Add shorthand package name support in jpm.
Package installation checks in the package listing if
the package name is not a url. The package listsing can be specified
via switch or env variable.
2019-10-10 18:11:45 -05:00
Calvin Rose
f9d57103f4 Improve peg error on unknown rule.
This helps a lot when debugging large, failing grammars.
2019-10-09 17:59:48 -05:00
Calvin Rose
f780df0aa6 Fix single threaded build option with meson.
By default, was building with the opposite of what was provided.
2019-10-05 20:35:11 -05:00
Calvin Rose
fede40f279 Relax requirement minimum arity of fn
A valid `fn` special could have only a parameter list, as
recommended by R. DuPlain.
2019-10-05 11:53:30 -05:00
Calvin Rose
e9f3dc7d5c Add varfn. 2019-10-03 20:20:42 -05:00
Calvin Rose
944347e828 Fix formatting.
Run make format.
2019-09-30 20:00:29 -05:00
Calvin Rose
7910a5feef Add compile time arity checking.
This should help catch a number of errors, but it
is a very shallow implementation of type checking. It will
catch some common misuses of functions at compile time
rather than runtime.
2019-09-30 19:50:42 -05:00
Calvin Rose
70ffe3b6bd Add slice function to core.
Returns immutable slices.
2019-09-24 19:44:36 -05:00
Calvin Rose
339dea9390 Add optional argument functions to c api.
These are just helpers to make parameters than can be nil with a
default value easier to handle in a consitent way.
2019-09-24 19:40:49 -05:00
Calvin Rose
b26a7bb22a Disallow the empty string for some string fns.
This will prevent these functions from being run
with empty strings, which usually produces useless
output, as the internal string search algorithm will
never "find" empty strings. This is by design, as it is
not always obvious which empty strings should be found in
the search text.
2019-09-24 13:23:18 -05:00
Calvin Rose
45dfc7cc96 Fix debug/break search algorithm. 2019-09-22 18:08:38 -05:00
Calvin Rose
8cda06b995 GCC seemed to not fill array of computed gotos.
This is expected as per the C standard, but segfaulted
unless all 255 labels were added.
2019-09-22 17:56:33 -05:00
Calvin Rose
a8afc5b81f Sourcemapping uses line, column instead of offsets.
This should be friendlier to most users. It does, however, mean
we lose range information. However, range information could be
recovered by re-parsing, as janet's grammar is simple enough to do this.
2019-09-22 17:18:28 -05:00
Calvin Rose
228d045a06 Fix formatting. 2019-09-22 15:17:06 -05:00
Calvin Rose
803c3fc235 Add line, col to error messages when available. 2019-09-22 15:13:21 -05:00
Calvin Rose
7bee204390 Fix installer. 2019-09-22 13:29:34 -04:00
Calvin Rose
7809f89dfc 1.3.1 Release
Small changes, mostly just fixing minor bugs.
2019-09-21 19:15:02 -05:00
Calvin Rose
8e427317cd Add mean function to boot.janet
Update changelog.
2019-09-19 21:21:14 -05:00
Calvin Rose
16127fc55c Remove printf in regalloc.c
This should never be hit unless there is a
bug in the compiler, but should be removed.
2019-09-15 18:17:43 -05:00
Calvin Rose
97d874f16b Fix small compiler bug (not freeing temp register). 2019-09-15 13:27:49 -05:00
Calvin Rose
39f1d81fd4 Use :length method for (length abstract)
Also adds the janet_lengthv API call. This is
needed because janet_length returns a 32 bit integer, where
as lengthv lets us return larger values (useful for typed arrays).

janet_mcall is an api function that should make it easier to call
a janet method from C code. It shares a similar signature with
janet_call.
2019-09-08 19:26:16 -05:00
Calvin Rose
99f147219a Add put-in. 2019-09-05 13:19:25 -05:00
Calvin Rose
7a13d24e6f Add get-in, update-in, and freeze to core. 2019-09-05 13:11:53 -05:00
Calvin Rose
96a3104fe2 Update to 1.3.0, add jpm.1 2019-09-04 23:44:23 -05:00
Calvin Rose
98eaadf2d1 Simplify peg caching further.
Remove the multiple caching tables we were using
and use the grammar table for caching. This works
well because we can use raw_get for checking the local cache, and normal
get fro checking the global cache.
2019-08-30 08:57:45 -05:00
Calvin Rose
54a04b5894 Fix some more recursion issues with pegs.
A keyword reference only counts as visited if we have
it as cached in the memoized->table, and we know it was
originally referenced from the same grammar table. If these
two conditions are true, then compilation must work correctly.

Also add janet_table_get_ex.
2019-08-29 19:56:04 -05:00
Calvin Rose
8bc8709d0e Try to address memoization problem in pegs. 2019-08-29 19:09:43 -05:00
Calvin Rose
060d11e4c2 Add Q and q formatters to buffer/format.
These are similar to P and p, but print values
on a single line for a much more compact version.
2019-08-24 22:53:45 -04:00
Calvin Rose
711fe64a51 Add backmatch operator to pegs.
(backmatch [tag?]) is similar to a back reference in regular expressions
(NOT to backwards capture in a peg). It only matches a pattern if
it exactly matches the text of the last capture. It does not consume
or push any captures to the capture stack.
2019-08-24 18:57:01 -04:00
Calvin Rose
292be33b9d Fix some stack overflow bugs. 2019-08-19 01:19:51 -04:00
Calvin Rose
81789a6930 Add wasm to architectures returned by os/arch. 2019-08-18 10:08:52 -05:00
Calvin Rose
28fb2403d9 Add os/arch to core.
Also allow setting custom keywords for compiled
os name and architecture name.
2019-08-18 10:00:04 -05:00
Calvin Rose
54170d92db Add some color to stacktraces in repl. 2019-08-12 19:20:01 -05:00
Calvin Rose
ec62e871dd Update to version 1.2.0. 2019-08-08 18:51:24 -05:00
Calvin Rose
ab782d8896 Add optional default value to get.
Also update CHANGELOG.md
2019-08-06 18:12:00 -05:00
Calvin Rose
c84ddefc53
Merge pull request #156 from curist/take-and-drop
Take and drop
2019-08-06 17:35:55 -05:00
curist
5802155882 Update take/drop - while/until.
to be more consistent with take/drop
2019-08-06 15:33:55 +08:00
curist
ee8a68f7b2 Fix take/drop comments. 2019-08-06 14:25:09 +08:00
curist
61bbeebfba Update take/drop implementation.
No more preserves input type.
2019-08-06 14:19:22 +08:00
curist
18da183ef7 Add take/drop. 2019-08-06 14:00:05 +08:00
Calvin Rose
19c6714f06 Fix MSVC warnings and errors. 2019-08-05 20:19:46 -05:00
Calvin Rose
2193193b12 Improve error message on bad method calls. 2019-08-05 19:06:58 -05:00
Calvin Rose
850a2d7f79 Allow method calls on typed arrays. 2019-08-05 18:51:53 -05:00
Calvin Rose
ca5dce5d9f Address #155.
Fix bug in janet_table_clone that leaked memory.
2019-08-05 17:52:05 -05:00
curist
d334f070a3 Update several docstrings. 2019-08-05 19:58:51 +08:00
Calvin Rose
44e752d737 Add shorthand function literals to janet.
These are similar to the function literals from Clojure
(also Fennel), and should make short functions for maps, filters, etc.
easier to write.
2019-08-04 12:25:52 -05:00
Calvin Rose
02ce3031e9 Fix comp case with arity of exactly 5. 2019-08-03 14:53:14 -05:00
Calvin Rose
6caf8d3d56 Make comp create variadic functions. 2019-08-03 13:57:11 -05:00
Calvin Rose
b18f1e8127 Keep count fo allocated memory via malloc.
We normally only track memory allocated with janet_gcalloc, but
if only a few very large normal memory blocks are allocated, the GC
will never run. Se simply need to increment a count when we allocate
memory so that the next time we enter the VM, we will be able to
run a collection if needed.
2019-07-31 00:24:13 -05:00
Calvin Rose
3e67916971 Fix MSVC warning. 2019-07-28 18:44:00 -05:00
Calvin Rose
8bbe518696 Executables linking to natives working on linux.
This involves a bunch of machinery in cook.janet
and even a little bit in the janet C API.
2019-07-28 13:27:20 -05:00
curist
c2ef58d880 Update math/log docstring 2019-07-28 22:18:36 +08:00
Calvin Rose
7e97687c9e Update windows installation and automation. 2019-07-27 21:44:44 -04:00
Calvin Rose
d6a1faa380 Typos. 2019-07-27 11:36:48 -05:00
Calvin Rose
3c133bd677 Add more values for (os/which)
Some bsd flavors.
2019-07-27 11:29:40 -05:00
Calvin Rose
efc38b87de Preemptive version bump. 2019-07-27 09:40:35 -05:00
Calvin Rose
a3a3e4c0dc Add (dyn :executable).
Also remove process/args.
2019-07-27 09:31:03 -05:00
Calvin Rose
dfe00fee94 Building standalone binaries on linux working.
Mostly changes to cook and jpm. Also some
code for file associations in the windows installer, and
adding the :linux value from os/which (instead of just :posix).
2019-07-26 22:43:54 -05:00
Calvin Rose
a0e98b9aa8 Deprecate process/args and add use macro.
Use is a shorthand for (import module :prefix "").
process/args has been replaced by (dyn :args) at
the top level.
2019-07-20 16:57:07 -05:00
Calvin Rose
0d3986abbb Update cook and add an install test. 2019-07-19 19:40:51 -05:00
Calvin Rose
e0fe8476aa Address issue #143
Fix some logic in module/expand-path.
2019-07-15 17:39:50 -05:00
Calvin Rose
0ca0180f27 More "correct" emscripten support. 2019-07-14 16:11:00 -05:00
Calvin Rose
21a355c89f Small changes to help with latest emscripten. 2019-07-14 09:58:11 -05:00
Calvin Rose
e528b86a2a Ensure no carriage returns end up in doc strings. 2019-07-12 09:14:37 -04:00
Calvin Rose
2e6ee39506 Fix windows build issues. 2019-07-12 08:47:11 -04:00
Calvin Rose
894877a0e3 Address issue #142
Also add janet_wrap_number_safe to API.
2019-07-12 07:23:24 -05:00
Calvin Rose
3928136670 Begin update to 1.1.0. 2019-07-08 18:16:17 -05:00