1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-08 17:59:55 +00:00
Commit Graph

505 Commits

Author SHA1 Message Date
Calvin Rose
cf05ff610f Add some fixes for serializing complex grammars. 2019-06-19 23:23:27 -04:00
Calvin Rose
fc46030e7d Add options to not include docstrings in binary.
This lets us build a smaller binary. The minimal tested
binary on x86-64 (with -Os, -s, and all options that shrink binary size
        turned on) is about 240 kB.
2019-06-19 19:43:38 -04:00
Calvin Rose
ff3bb66272 Add some test cases for module/expand-path 2019-06-19 12:48:29 -04:00
Calvin Rose
9ba8728176 Update module system.
Add relative imports and path normalization. This should
help towards a more composable build/dependency system.
2019-06-18 22:10:13 -04:00
Calvin Rose
e88a9af2f6 Add bytecode verification for peg unmarshaling. 2019-06-18 13:01:49 -04:00
Calvin Rose
446ab037b0 Allow marshaling pegs. 2019-06-17 23:40:02 -04:00
Calvin Rose
b4e25e5597 Add some string/check-set tests. 2019-06-10 14:11:07 -04:00
Calvin Rose
43520ac67d Add parser/clone. (#120) 2019-06-08 17:16:36 -04:00
Calvin Rose
f12f896020 Change test-install 2019-05-28 12:59:21 -04:00
Calvin Rose
698e89aba4 Fix comment macro arity #110 2019-05-25 22:50:15 -04:00
Calvin Rose
3f137ed0b1 Add keyword argument tests 2019-05-24 17:53:34 -04:00
Calvin Rose
a303704a7d Add some tests for the amalgamated source/
Adds tests to Makefile and CI on Poisx platforms.
2019-05-23 10:34:01 -04:00
Calvin Rose
0378ba78cc Add regression test. 2019-05-20 09:20:50 -04:00
Calvin Rose
232ea22dc5 Add string/triml, string/trimr, and string/trim. 2019-05-10 16:09:49 -04:00
Calvin Rose
bbcfaf1289 Fix use after free bug in buffer/format when printing self. 2019-05-08 15:25:25 -04:00
Andrew Chambers
1759252071 Fix use after free in buffer/push-string. 2019-05-08 10:49:25 -04:00
Calvin Rose
65ac17986a Address similar issue to #86
buffer/blit could trigger a use after free if a buffer is
blitted with itself and modifies its length.
2019-05-08 08:55:43 -04:00
Andrew Chambers
c70d59edee Add string/has-prefix? and string/has-suffix?. 2019-05-04 10:05:58 -04:00
Calvin Rose
7918add47d Allow dynamically setting output for printers
Some functions like print and debug/stacktrace print
to a file, usually stdout. This file can now be optionally set
via a dynamic variable.
2019-04-16 21:44:19 -04:00
Calvin Rose
2d7df6b78e Many changes for adding dynamic (fiber-level) scope.
- Allow passing a table to fibers, which make fiber level scope easier.
- Add fiber/getenv, fiber/setenv, dyn, and setdyn
- Remove meta, *env*, and *doc-width*
- Some functions changed dignatures, and no longer take an env
2019-04-16 15:41:45 -04:00
Calvin Rose
1596511175 Fix undefined behavior bug with errors.
janet_vm_return_reg should only be set when janet_continue
is called. Otherwise, a panic may dump it's error message in
the wrong place, resulting in undefined behavior (often showing
the last return value or worse, segfaulting).
2019-04-10 23:29:40 -04:00
Calvin Rose
d514eab627 Add regression test for #78 2019-04-09 09:14:40 -04:00
Calvin Rose
e239980da7 Quasiquoting bracketed tuples. 2019-03-31 14:15:26 -04:00
Calvin Rose
2c9195b507 More updates to meson
Redo amalg script so we can more easily run
it from Meson.
2019-03-23 13:50:50 -04:00
Calvin Rose
bad040665f Renamed bigint -> inttypes / int
A lot of refactoring larger integer types. Fix a number
of casting errors, but mostly rename things. Also try to
limit use of template-like macros as they bloat the binary
if not used in moderation. We were able to reduce the size of
typed array code as well by using a single view types.
2019-03-18 18:36:53 -07:00
J.-F. Cap
a07d76b264 use custom string to bigint reader in place of strtol
for better compatibility with default janet number reader
2019-03-18 18:36:53 -07:00
J.-F. Cap
1db6d0e0bc Trap INT64_MIN / -1 exception 2019-03-18 18:36:53 -07:00
J.-F. Cap
319575c864 bigint operators and some tests 2019-03-18 18:36:53 -07:00
Quan Nguyen
75dc08ff21 Fix nil error on drop-until fn 2019-03-10 12:39:55 -04:00
Calvin Rose
8ba1121161 Add early returns via break.
Inside a while loop, the argument to
break does nothing as while loops always
return nil.
2019-03-09 22:01:10 -05:00
Calvin Rose
4a111b38b1 Add break special.
The break special form can break out of both loops
and functions with an early (nil) return. Mainly useful
for generated code in macros, and should probably be discouraged
in user written code.
2019-03-09 17:15:50 -05:00
Calvin Rose
687a3c91f5 Add array/remove and update CHANGELOG. 2019-03-08 10:24:21 -05:00
Calvin Rose
0382dc976b More code to better integrate with size_t
Typed arrays use proper size_t support in more
places now.
2019-03-08 00:44:26 -05:00
Calvin Rose
69dcab2b55 Silence some casting size_t to double errors. 2019-03-07 22:44:17 -05:00
Calvin Rose
624be87c97 Add test for :down verb. 2019-03-03 23:55:38 -05:00
Calvin Rose
172261b89f Add a test-install target to the Makefile
This target will be used to check if an installation
of Janet is on the PATH, if native modules can be built
and used via the cook module, etc.
2019-03-03 14:48:17 -05:00
J.-F. Cap
fb5119bf43 Added some tests (suite 5) 2019-02-25 18:49:04 +01:00
Calvin Rose
340a6c4d8d Update marsh.c to use janet_panic for errors.
Before, we used a local setjmp/longjmp for error handling.
Using janet_panic means errors can be more easily expressive and
code can be smaller.

However, we still need to make vector memory get gc collected, as
panics can cause the runtime to skip janet_v_frees.
2019-02-22 10:12:25 -05:00
Calvin Rose
f4908ebc41 Update issue 53 regression test.
Some tests did not call assert so did not show up on report.
2019-02-21 19:19:47 -05:00
Calvin Rose
1147482e62 Address #53 - marshalling fiber strangeness
The unmarshaller was not tracking fibers in references.
2019-02-21 19:11:28 -05:00
Calvin Rose
811b1825cb Remove tuple/append and tuple/prepend.
Use the splice special instead.
2019-02-20 21:08:54 -05:00
Calvin Rose
a982f351d7 Address #50
Issues with range when called with 3 arguments.
2019-02-20 12:07:20 -05:00
Calvin Rose
029394db31 Add buffer/format as well as string/format.
buffer/format uses the old string/format behavior. `string/format` no
longer requires a buffer, and returns a string.
2019-02-16 13:59:38 -05:00
J.-F. Cap
0f0c415bcf Adde some tests for string/format 2019-02-16 16:28:10 +01:00
Calvin Rose
bdf03b4706 Fix unmarshalling integers directly, not through readint. 2019-02-15 14:01:32 -05:00
Calvin Rose
c6edf03ae8 Fix some code style, add tuple/type function.
We need to be able to detect tuple type from janet code, otherwise
tuples will contain hidden state. The tuple/type function is able
to detect the flags in the tuple so the programmer can access them
if needed.
2019-02-09 12:21:11 -05:00
Calvin Rose
f284776490 Address #24 2019-01-28 20:30:45 -05:00
Calvin Rose
38a7e4faf1 Disallow NaN as table/struct key.
Fix bugs and add tests for denormalized tables
and structs.
2019-01-28 11:50:33 -05:00
Calvin Rose
e755f98300 Address #23 2019-01-25 20:31:08 -05:00
Calvin Rose
b84b0e4828 Expose more of the module system.
The system path can more easily modified at runtime,
and the module/cache and module/loading tables are now exposed.
Properly cache native modules as well.
2019-01-18 12:04:34 -05:00
Calvin Rose
b4934ceddc Make parser errors a bit better for files with no closing
delimiters.
2019-01-17 23:43:46 -05:00
Calvin Rose
2c1b506213 Add tagged captures for a better (more correct) form of look behind. 2019-01-16 22:38:11 -05:00
Calvin Rose
612a245961 More work on peg. Disable indexed backrefs and replace substitution
with accumulation.
2019-01-16 21:11:55 -05:00
Calvin Rose
4eeadd7463 Add optional form to peg (shorthand for (between 0 1 patt)). 2019-01-15 14:08:03 -05:00
Calvin Rose
3a9b50ea4a Update peg doc and remame some peg specials. 2019-01-14 22:17:13 -05:00
Calvin Rose
90313afd40 Update PEG documentation and peg syntax.
Disable tail calls in the root scope for better
stacktraces, as the root scope may contain a single call
to a failing function, as in the case of the test suite.
2019-01-14 20:41:32 -05:00
Calvin Rose
d0ec89c7c1 Update Matchtime captures to not include all of the
matched text automatically, and fix pattern recursion
in grammars.
2019-01-14 17:44:21 -05:00
Calvin Rose
170e785b72 Fix recursion in grammars. 2019-01-14 15:06:35 -05:00
Calvin Rose
192705113e Add Matchtime captures to peg (Equivalent to LPegs lpeg.Cmt).
This allows that pattern to call an external function to
check if some text should match or not. This allows for
matching any possible language a computer can recognize.
2019-01-14 11:45:45 -05:00
Calvin Rose
ff0d3a0081 Compile pegs to bytecode with (peg/compile). Peg
performance is improved, and peg syntax has been expanded with a few
more keywords.
2019-01-13 23:54:41 -05:00
Calvin Rose
798c88b4c8 Update peg to allow functions over captures. Update C API
to make janet function calls easier and faster from C (still
needs an object pool for fibers, though). Fix bug in scan-number
and add many more peg tests.
2019-01-12 17:31:15 -05:00
Calvin Rose
83f4a11bf3 Add some more tests, add parameterized captures to patterns,
and fix some bugs.
2019-01-12 11:04:47 -05:00
Calvin Rose
d7626f8c57 Add more capturing capabilities including substitutions, as well
as back references for PEGs. More documentation is needed for PEG
syntax, but the amount required will need an external document, not
just a docstring.
2019-01-12 10:16:25 -05:00
Calvin Rose
40845b5c1b Initial peg implementation. Tree walk interpretted with
no captures, so not yet ready.
2019-01-11 19:22:24 -05:00
Calvin Rose
16ebb11181 Add buffer/bit functions and buffer/blit. Expose janet_gethalfrange
in the C api for less duplicated range checking code.
2019-01-09 13:25:51 -05:00
Calvin Rose
5b1a3b8208 Make grammar tool completely generate grammar from scratch.
Remove grammar from source tree.
2019-01-08 19:59:54 -05:00
Calvin Rose
67f26b7d72 Fix = should have been ==. Add some tests for vm type asserts. 2019-01-08 12:26:01 -05:00
Calvin Rose
d5bab72620 Add a test for making method calls 2019-01-07 14:54:39 -05:00
Calvin Rose
6f3bc3d577 Update copyright date, fix types, remove trailing whitespace. 2019-01-06 03:23:03 -05:00
Calvin Rose
5b62c8e6db Better working panic implementation and more cleanup in main vm loop. 2019-01-05 00:33:20 -05:00
Calvin Rose
b9c0fc8201 Allow calling keywords and symbols as functions to look
themselves up in a data structure. Allow calling  a data
structure to look up the argument.
2019-01-03 22:48:43 -05:00
Calvin Rose
ddba0010b0 Make test output less verbose. 2019-01-02 23:06:23 -05:00
Calvin Rose
a679f60e07 Add assembly test. 2019-01-02 19:58:27 -05:00
Calvin Rose
e9c94598e6 Add native keyword type to replace symbols with leading ':'
character.
2019-01-02 19:41:07 -05:00
Calvin Rose
0d4ab7dee0 Add some more test cases for bad arities. 2018-12-30 18:44:00 -05:00
Calvin Rose
6b4824c2ab Fix error behavior when calling functions with incorrect arities. 2018-12-30 18:41:44 -05:00
Calvin Rose
d724c5b959 Update number representation so that wrapping numbers isn't
doesn't need to check for NaNs. Change ordering of types.
2018-12-30 12:37:50 -05:00
Calvin Rose
7880d73201 Add some documentation for looping and the loop macro.
Also add :pairs verb to the loop macro and some more tests.
2018-12-29 17:23:31 -05:00
Calvin Rose
2bcedd5920 Remove indexing with numeric constants from janet. 2018-12-28 23:44:39 -05:00
Calvin Rose
6b95326d7c First commit removing the integer number type. This should
remove some complexity and unexpected behavior around numbers in
general as all numbers are the same number type, IEEE 754 double
precision numbers. Also update examples and tests, some of which were
out of date.

Some more testing may be needed for new changes to numbers.
2018-12-27 13:05:29 -05:00
Calvin Rose
17283241ab Fix bug in compiler with if form under certain conditions.
Begin bundled 'cook' tool for managing janet projects.
2018-12-25 15:32:42 -05:00
Calvin Rose
99e14a9b70 Rename bitwise operators. 2018-12-16 22:13:48 -05:00
Calvin Rose
03dbd79165 Rename the := special form to set so it does not look like a keyword. 2018-12-16 21:57:32 -05:00
Calvin Rose
bc8be266f5 Update match macro to test for array/tuples and table/structs. 2018-12-08 11:04:19 -05:00
Calvin Rose
11cd1279d7 Update Makefile and fix fiber issues. When
creating an invalid fiber with the C api, the
program could segfault. This protects against this kind
of segafault.
2018-12-02 15:29:21 -05:00
Calvin Rose
4e4dd31164 Change syntax for namespaces.
Add quasiquote, unquote, and unquote-splicing
as specials rather than a macro.
2018-11-30 22:49:21 -05:00
Calvin Rose
52c919d96f Add qq (, uq and uqs) for a quasiquote macro.
quasiquoting is not (yet) supported as a special
form and has no syntactic sugar.
2018-11-30 01:58:52 -05:00
Calvin Rose
7dbad20150 Update core and some examples to use the new
syntax.
2018-11-29 14:03:45 -05:00
Calvin Rose
b0c45fd15e Multisyms for easier access into structures. 2018-11-29 13:30:59 -05:00
Calvin Rose
8bfea73ee7 Fix web build again, simplify fibers and fiber
implementation code.
2018-11-26 09:03:26 -05:00
Calvin Rose
b2a1a4ec9b Add classes to core library. 2018-11-25 15:58:50 -05:00
Calvin Rose
d4ee760b3e Change format for declaring flexible arity functions. 2018-11-25 14:03:00 -05:00
Calvin Rose
d791077e25 Fix abstract? function. 2018-11-23 15:33:49 -05:00
Calvin Rose
184fe31e0c Add generator expressions for easier iteration.
Similar to python generator, but with the same
syntax as the loop macro.
2018-11-20 21:48:06 -05:00
Calvin Rose
92202e1c8b Add invert and simplify
env-lookups to env-lookup
2018-10-21 11:46:36 -04:00
Calvin Rose
98f2c6feab Add lookups for marshalling and unmarshalling.
Allow generating lookup tables from the current environment.
2018-10-21 01:35:07 -04:00
Calvin Rose
e8a4e83a0d Update Makefile, json native module,
and test suite 2.
2018-10-04 17:25:46 -04:00
Calvin Rose
f41dab8f6c Fix error in string.replace-all 2018-09-29 20:01:57 -04:00
Calvin Rose
5baf70f4c6 Add tests. 2018-09-06 14:22:34 -04:00
Calvin Rose
c8ef2a0d88 Rename to janet 2018-09-05 22:18:42 -04:00
Calvin Rose
45d0597294 Remove apply1 and optimize apply. 2018-08-26 12:53:39 -04:00
Calvin Rose
ecdef8de8b Working fiber marshaling. 2018-08-24 11:35:08 -04:00
Calvin Rose
f5b4bc4fdf Add array and tuple versions of map and for. 2018-08-23 11:10:48 -04:00
Calvin Rose
45f8db0360 Add a few more tests. 2018-08-23 10:27:42 -04:00
Calvin Rose
510feeed7f Allow marshaling of more functions for core.
Fix indentation in some files.
2018-08-22 21:41:25 -04:00
Calvin Rose
634ec85b07 Fix funcdef flags when marshaling. 2018-08-21 15:07:37 -04:00
Calvin Rose
600292fad4 Working function marhsaling 2018-08-21 14:16:55 -04:00
Calvin Rose
910cfd7ddf Lots of updates. Function marshaling WIP. 2018-08-19 20:21:27 -04:00
Calvin Rose
e05022f96c Add some more array tests. 2018-08-11 22:43:04 -04:00
Calvin Rose
06c755c98a Be stricter with function arity. 2018-08-03 13:41:44 -04:00
Calvin Rose
6b8b21ce77 Clarify closure in loop test. 2018-07-11 22:20:43 -04:00
Calvin Rose
abe7d592aa More work on closures in loops. Fix loop macro to
not store bindings as vars.
2018-07-11 22:18:24 -04:00
Calvin Rose
08f6c642d0 Fix not= and odd? 2018-07-08 11:31:24 -04:00
Calvin Rose
547529ebb2 Refactor dst_view_* functions. 2018-07-04 13:21:30 -04:00
Calvin Rose
52492282f2 Case tests. 2018-07-04 01:32:26 -04:00
Calvin Rose
5e2de33ae7 Remove some c functions in favor of bytecode. 2018-07-02 00:12:36 -04:00
Calvin Rose
6822400abe Fix large function compilation issue. 2018-07-01 15:53:57 -04:00
Calvin Rose
bb406133de New sourcemaps v1. 2018-06-28 23:37:04 -04:00
bakpakin
23dcfb986e Allow expressions as keys in destructuring. 2018-06-25 15:34:06 -04:00
Calvin Rose
0cf10946b0 Add first version of marsh (marshaling). 2018-06-12 14:24:45 -04:00
Calvin Rose
2a87dada47 Rename fiber.resume and fiber.yield to
resume and yield.
2018-06-09 13:08:30 -04:00
bakpakin
eba6242978 Update CMakeLists.txt for tests. 2018-06-08 16:54:08 -04:00
bakpakin
1690fee446 Add failure on top level error. 2018-06-08 15:58:23 -04:00
Calvin Rose
8a346ec655 Add option to cli interface to stop scanning options. 2018-05-26 14:17:44 -04:00
Calvin Rose
8bcb5e0019 Add where clause to list comprehension. 2018-05-23 23:43:48 -04:00
Calvin Rose
68895e27d4 Change import semantics. Fix gc bug with fibers. 2018-05-18 20:53:19 -04:00
Calvin Rose
f295692b50 Update copyright to 2018. Add string methods. 2018-05-17 23:41:20 -04:00
Calvin Rose
c0e373f420 Add some test code and fix sqlite3 native example. 2018-05-17 13:34:11 -04:00
Calvin Rose
51bdc41014 Change fiber signal model to add user signals. This
should allow easier implementations of eventloops,
threadpools, or custom data flows with fibers.
2018-05-16 22:09:36 -04:00
Calvin Rose
0fd9224e4a Proper re-entry into debug state nested fibers. 2018-05-16 09:24:34 -04:00
Calvin Rose
932a0324ee More work on renaming functions. Change long string syntax to use
backticks. Allow custom masks in fibers for custom error and debug
handling.
2018-05-09 17:01:58 -04:00
Calvin Rose
f47323c915 Change convention for naming modules and functions. 2018-05-08 19:40:28 -04:00
Calvin Rose
104b09d848 Make the -s option more useful. 2018-05-07 01:04:56 -04:00
Calvin Rose
55f0e759d9 Add extra information in repl to show state of parsing. 2018-05-06 23:25:59 -04:00
Calvin Rose
7e63427208 Update strtod.c to be less accepting of some badly formed numbers. 2018-05-06 15:27:52 -04:00
Calvin Rose
027b2a81c2 Shrink the public interface by hiding internal state. 2018-03-31 16:42:41 -04:00
Calvin Rose
0d5b57daee Remove exit in favor of os-exit. 2018-03-28 21:24:54 -04:00
Calvin Rose
db046fa8bb Clean up testing code a little bit. 2018-03-25 21:25:33 -04:00
Calvin Rose
a3ed7327c9 Make array literals require preceding @ character. 2018-03-24 12:48:42 -04:00
Calvin Rose
3e1e258546 Fix a compiler bug in the do special form. 2018-03-19 14:51:18 -04:00
Calvin Rose
8da838e12c Add macros for imperative programming (c style sugar). 2018-03-16 18:31:18 -04:00
Calvin Rose
807f9818a5 Add let macro. 2018-03-11 16:30:38 -04:00
Calvin Rose
2a0dc5f1ad Switch to assymetric coroutines instead of symmetric. 2018-03-11 15:35:23 -04:00
bakpakin
7f693796ea Differentiate total order comparison and numeric comparison 2018-02-09 11:57:58 -05:00
Calvin Rose
3e1f031576 Self host the repl, remove linenoise, and selfhost the
main client.
2018-02-07 00:44:51 -05:00
Calvin Rose
35ddc70888 Move ast into parser. Map keywords to symbols instead of
strings.
2018-02-03 13:55:55 -05:00
bakpakin
50bfa8de3f Add boot script which is loaded on start up. 2018-01-31 17:39:18 -05:00
bakpakin
ce5708af98 Switch over to Cmake fully. 2018-01-29 15:46:26 -05:00
bakpakin
b305a7c9bb Add macros in compiler. 2018-01-28 15:29:47 -05:00
bakpakin
8fe9881187 More work on adding c functions. Added buffer literals again. 2018-01-27 15:15:09 -05:00
bakpakin
5460ff19bf Begin C Function specialization in the compiler. 2018-01-24 17:59:00 -05:00
bakpakin
42a88de9e7 Add quick asm for adding apply and error to the stl. 2018-01-21 16:41:15 -05:00
bakpakin
911b0b15e8 Fix some bugs with inner closures. 2018-01-21 14:39:32 -05:00
bakpakin
d68eae9592 Add bytecode verification 2018-01-20 17:21:59 -05:00
bakpakin
30f62ca454 Major refactor and restructure. Add CMake for anticipated windows
support.
2018-01-19 16:43:19 -05:00