Commit Graph

478 Commits

Author SHA1 Message Date
Simon Forman c2eae95bb2 lshift and rshift for C. 2023-02-14 13:15:53 -08:00
Simon Forman f1db810370 or instead of ||, and instead of &&
Docs still TODO!
2023-02-14 12:27:46 -08:00
Simon Forman 8c36d8316e Hack to deal with trailing underscores. 2023-02-14 12:08:32 -08:00
Simon Forman 9c355166b6 Bring error message inline with other implementations. 2023-02-14 12:07:58 -08:00
Simon Forman 5ce30d41c3 Regularize defs.txt.
All three main interpreters use the same defs.txt file.
2023-02-14 10:23:23 -08:00
Simon Forman 2700ab8a7f Aliases for builtins in Python Joy. 2023-02-14 10:19:03 -08:00
Simon Forman 178e58f8bd Load embedded defs.txt, remove ≡ stuff.
I like that ≡ but I also like consistency.
2023-02-14 10:07:26 -08:00
Simon Forman 25c48e059b Splice defs.txt into joy.py to make "joy" script. 2023-02-14 09:52:01 -08:00
Simon Forman ae77bbda24 Move all the bigints code into own dir. 2023-02-14 08:48:08 -08:00
Simon Forman e771e0182b Make /\ and \/ check that their args are Booleans. 2023-02-14 08:40:32 -08:00
Simon Forman ad0f135376 Don't let defs shadow builtins. 2023-02-14 08:39:52 -08:00
Simon Forman f0c94aeed8 regularize defs.txt; new andies.
I made a crude facility in the C impl for excluding definitions that
would replace built-in commands.  This should be improved, eh?

I also started on renameing the logical Boolean ops
https://todo.sr.ht/~sforman/thun-der/29
2023-02-14 08:27:17 -08:00
Simon Forman f37ef42cb4 Note to self...
This bit of code works, but I'm not sure why, or even if it's just an
illusion of working, and here lurks a nasty bug?
2023-02-14 07:56:52 -08:00
Simon Forman e35ecea25e Unify the various defs.txt files...
Work in progress.  THis is broken now.
2023-02-14 07:55:09 -08:00
Simon Forman a828169b34 initialization/1 FTW! 2023-02-12 20:39:26 -08:00
Simon Forman 1540338306 Minor cleanup.
To the first serious Joy code: bigints!
2023-02-12 20:11:40 -08:00
Simon Forman b0d79f77f7 minor refactor 2023-02-12 19:19:51 -08:00
Simon Forman 5bccaff9f2 Conform!
cons and loop check type before number.
Don't print '<- top'.
2023-02-12 18:45:56 -08:00
Simon Forman aacd9764fe Make Python and C interpreters conform.
The Python one still checks number before type with get_n_items().
I can live with that for now.
2023-02-12 16:17:27 -08:00
Simon Forman eb38a7e817 fdiv
This is why you compile and run tests /before/ you commit changes, eh?
2023-02-12 16:04:37 -08:00
Simon Forman b6d4175a78 Bring behaviour inline with joytest.
Pop has it's own error message.

Div should be "floor" division

> fdiv rounds q down towards -infinity, and r will have the same sign as
> d. The f stands for “floor”.

https://gmplib.org/manual/Integer-Division
2023-02-12 16:01:19 -08:00
Simon Forman 51b32bbc0a Quiet mode for C. 2023-02-12 15:15:01 -08:00
Simon Forman 6f3b942ded Build manifest for sr.ht. 2023-02-10 08:10:47 -08:00
Simon Forman 75591f36ba minor cleanup 2023-02-10 08:09:31 -08:00
Simon Forman acfa19239e null, small
https://todo.sr.ht/~sforman/thun-der/23
2023-02-09 10:58:08 -08:00
Simon Forman 035fb00939 minor cleanup 2023-02-09 08:28:31 -08:00
Simon Forman 101a0241d3 and, or (Boolean ops).
"not not" serves as a kind of type-checking identity function. "not"
will error out on non-Boolean values, or the absence of a second arg.
2023-02-09 07:52:50 -08:00
Simon Forman 66f47f8e36 divmod, xor 2023-02-09 06:59:39 -08:00
Simon Forman 8016fd697a Allow for redefinition of user defs.
And some protection for inscribe, empty quotes or quotes that do not
have a symbol at the first item are just consumed without affecting the
user defs.

Because the Gperf wordlist is checked before the user defs hash the
inscribe command cannot overwrite the commands defined in the wordlist.
2023-02-08 23:20:35 -08:00
Simon Forman 35d8ed498f User definitions with the inscribe command.
Using uthash http://troydhanson.github.io/uthash/index.html
2023-02-08 21:13:23 -08:00
Simon Forman b1d7a34eab unstack 2023-02-08 15:06:12 -08:00
Simon Forman 2be2d00e6b Handle definitions with non-alphanumeric chars in their names. 2023-02-08 12:50:23 -08:00
Simon Forman 832cbe34e4 Oh, LDFLAGS, right... 2023-02-08 11:55:33 -08:00
Simon Forman 2b54c0bc0a Initializers for Boolean values. 2023-02-07 20:53:44 -08:00
Simon Forman 94bcd2aa51 Minor cleanup. 2023-02-07 20:47:32 -08:00
Simon Forman efd77a2ffd Aliases can be put in KEYWORDS.in
This avoids the overhead of single-functions definitions for aliases.
2023-02-07 19:14:37 -08:00
Simon Forman 0c8e49d591 dispatch 2023-02-07 17:44:32 -08:00
Simon Forman b57cfdf825 Track KEYWORDS.txt after all. 2023-02-06 13:14:14 -08:00
Simon Forman 708e5ad3f5 eq, neq, gt, ge, lt, le 2023-02-06 13:09:37 -08:00
Simon Forman 05575d8a08 A bunch of definitions.
Still to do: the comparison functions.
2023-02-06 12:59:39 -08:00
Simon Forman 437e0af91d Use setjmp/longjmp to recover after errors.
Wow!  That was easy!
2023-02-06 00:30:25 -08:00
Simon Forman 0611aa3c05 Clean KEYWORDS.txt too. 2023-02-05 20:48:19 -08:00
Simon Forman 5b12385253 pop_list <=> pop_list_node
These names seem like they should be swapped.
2023-02-05 19:47:32 -08:00
Simon Forman b70231bcff minor cleanup 2023-02-05 19:40:16 -08:00
Simon Forman 3a11fcb834 loop
But it's pretty inefficient, eh?
2023-02-05 18:43:05 -08:00
Simon Forman 26a733f720 first, rest 2023-02-05 17:40:26 -08:00
Simon Forman d3a9a6ff7f A README file. 2023-02-05 14:54:33 -08:00
Simon Forman ccbf8d2b4c minor cleanup 2023-02-05 13:53:53 -08:00
Simon Forman 8bda5d511a Auto-generate defintions from defs.txt
But it doesn't yet handle names with non-C-indentifier characters in
them.
2023-02-05 13:50:16 -08:00
Simon Forman 291b6caa75 Generate definitions.h; swons 2023-02-05 13:38:59 -08:00
Simon Forman 78b59dda35 Put defs into a generated file.
This is only part of the solution, we still need to update joy.h and
KEYWORDS.txt when defs.txt changes, and we need to handle names that
have non-C-identifier characters in them.

But it's a start...
2023-02-05 13:04:31 -08:00
Simon Forman 6eae43c27f push_quote_onto_expression
doesn't push an empty list, unlike push_quote() which does.
2023-02-05 11:58:44 -08:00
Simon Forman a9e4f93cdc concat 2023-02-05 11:00:22 -08:00
Simon Forman 6ee3226a88 swap 2023-02-05 10:27:17 -08:00
Simon Forman 514eaef70f forgot to save 2023-02-05 10:23:50 -08:00
Simon Forman bafb2a318b No clear def. 2023-02-05 10:05:20 -08:00
Simon Forman ac47f39ea3 Remove def of clear.
It's a neat example of a custom implementation being more efficient than
the Joy code.
2023-02-05 10:04:20 -08:00
Simon Forman 09e9e340a5 stack 2023-02-05 10:00:18 -08:00
Simon Forman 8f4c98a051 swaack 2023-02-05 09:54:52 -08:00
Simon Forman 9563f738bd pop 2023-02-05 09:50:41 -08:00
Simon Forman 3d0b5ba266 cons 2023-02-05 09:40:47 -08:00
Simon Forman fe4ce60541 dip 2023-02-05 08:49:05 -08:00
Simon Forman 4b3117e349 minor cleanup 2023-02-05 08:38:15 -08:00
Simon Forman f34b4547a5 dup 2023-02-05 08:37:13 -08:00
Simon Forman 4181daf40c minor cleanup 2023-02-05 08:12:32 -08:00
Simon Forman b1a06979c2 truthy 2023-02-04 23:45:13 -08:00
Simon Forman 7874496090 Definitions.
There are things to like about this implementation and things to
dislike.

Things to like:

- It works.
- The defs are baked into the wordlist.

Cons:

- The def bodies are built at start time by parsing strings.  it would
  be nice to somehow generate initializer literals if possible.  But
  would that mess up the garbage collector?
- It requires manual labor to update the defs when defs.txt changes.  It
  would be nice to have a solution that *make* can use.
2023-02-04 23:08:39 -08:00
Simon Forman 15482c1fdd A first attempt at definitions. 2023-02-04 22:58:38 -08:00
Simon Forman b70229d727 Almost truthy... 2023-02-04 22:58:16 -08:00
Simon Forman 6159165acd div and mod 2023-02-04 19:34:38 -08:00
Simon Forman 720f36a4c0 clear 2023-02-04 19:21:13 -08:00
Simon Forman c3e786aed9 branch combinator. 2023-02-04 19:19:48 -08:00
Simon Forman 21f99aac96 i combinator. 2023-02-04 19:05:26 -08:00
Simon Forman bd525cc7ac Depend on joy.h. 2023-02-04 18:59:59 -08:00
Simon Forman 62ed15d17a Minor cleanup, print_stack. 2023-02-04 18:51:58 -08:00
Simon Forman 8b4d265ed9 Minor cleanup. 2023-02-04 13:46:29 -08:00
Simon Forman b76213ff7e Expression is a list-of-lists now.
That way we don't have to concatinate quotes onto it all the time.
Instead we amortize in the next_term() function.
2023-02-04 13:38:28 -08:00
Simon Forman 45865acc2f Cmp, comes with GMP. 2023-02-04 12:47:45 -08:00
Simon Forman 42e7724e77 Boolean singleton values. 2023-02-04 11:27:03 -08:00
Simon Forman 81eebc5b9b Boolean singleton values. 2023-02-04 10:25:14 -08:00
Simon Forman 71c25e7bbd Node head is pointer now. 2023-02-04 08:12:30 -08:00
Simon Forman 2e4381b2c0 JoyListPtr too 2023-02-04 07:55:11 -08:00
Simon Forman 1eb8f1dde1 Use JoyListPtr. 2023-02-04 07:52:36 -08:00
Simon Forman 99fb04397f sub and mul through judicious (I hope) use of macros. 2023-02-03 19:38:18 -08:00
Simon Forman ecf79b9de0 pop_any(), pop_int(), and add 2023-02-03 15:46:52 -08:00
Simon Forman 3ae0e5b3a6 Interpret symbols.
C has function pointers, we can put them in the Gperf wordlist, this
makes the interpreter really simple.  No need for a dictionary (yet).

Implementing the basis functions will be a bit of a slog, and
I still have to implement definitions, but this is starting to shape up
nicely.
2023-02-03 11:48:32 -08:00
Simon Forman f2b2b92c2c Yet more minor cleanup. 2023-02-03 09:39:02 -08:00
Simon Forman 7df01dfe5e More minor cleanup. 2023-02-03 09:30:11 -08:00
Simon Forman 64eb28a648 Minor cleanup. 2023-02-03 09:27:30 -08:00
Simon Forman 8647f40895 newJoyList 2023-02-03 09:18:32 -08:00
Simon Forman fb40b11fb0 Can haz function pointers in my worldist. 2023-02-03 08:13:57 -08:00
Simon Forman cd98e01efc typedef for the win! 2023-02-02 20:45:28 -08:00
Simon Forman f74a0fe0fa make clean rule 2023-02-02 17:02:55 -08:00
Simon Forman 4be1cc5767 Use gperf to save memory.
We check terms to see if they're in the wordlist, if they are we reuse
the string from the wordlist instead of allocating a new one.

(I've always wanted to use Gperf so I'm pretty stoked about this!)
2023-02-02 16:58:44 -08:00
Simon Forman 0a66f2b804 Ignore object files. 2023-02-02 16:14:11 -08:00
Simon Forman 8dcaee342d minor cleanup 2023-02-02 16:13:15 -08:00
Simon Forman a2a18a1d05 Gperf. 2023-02-02 16:12:59 -08:00
Simon Forman 70fc8c612c Minor cleanup. 2023-02-02 13:22:11 -08:00
Simon Forman e342fb31de True and False values. 2023-02-02 13:06:07 -08:00
Simon Forman ab8b26d6f0 Copyright, etc. 2023-02-02 11:14:58 -08:00
Simon Forman dee703ea52 Fix bug with no trailing spaces.
Gotta update that pointer, eh?
2023-02-02 10:58:03 -08:00
Simon Forman e393016a32 I was post-incrementing when I should have been pre-incrementing!
D'oh!
2023-02-02 08:52:27 -08:00
Simon Forman b759582439 Simple terms work. Problem is with sub-lists. 2023-02-02 08:36:13 -08:00
Simon Forman ebae69c391 Parsing isn't this hard? 2023-02-02 08:32:45 -08:00
Simon Forman 9356e5394b Um, don't do that.
I wonder where the data was winding up?
2023-02-01 20:36:18 -08:00
Simon Forman 288142c01a Minor cleanup. 2023-02-01 20:34:49 -08:00
Simon Forman bb41bf619d Remove separate parser code. 2023-02-01 20:34:04 -08:00
Simon Forman 5d47512bf5 Print true, false, and lists. 2023-02-01 20:33:04 -08:00
Simon Forman b09055f299 Print ints. 2023-02-01 20:28:24 -08:00
Simon Forman 202747cfbb Print list. 2023-02-01 20:09:03 -08:00
Simon Forman cd0bfc09d2 Text to expr coming along. 2023-02-01 19:26:50 -08:00
Simon Forman 8ae9851c0f Need to be able to store a string. 2023-02-01 18:37:10 -08:00
Simon Forman 66cbbac1cc Minor cleanup. 2023-02-01 18:35:11 -08:00
Simon Forman 6b87e46e00 Minor cleanup.
Don't pass NULL to strpbrk().
2023-02-01 17:39:37 -08:00
Simon Forman 5118881e6c Handle stretches of blanks.
Don't create zero-length strings.
2023-02-01 17:25:54 -08:00
Simon Forman 9762502ea6 Nice skeleton of parser. 2023-02-01 17:17:35 -08:00
Simon Forman 6694d3d596 Almost there on parsing. 2023-02-01 16:57:46 -08:00
Simon Forman 2f71db945a trim_leading_blanks 2023-02-01 16:40:14 -08:00
Simon Forman b8b37af1a4 Let's parse. 2023-02-01 16:02:19 -08:00
Simon Forman e32d1d22e6 Don't version the binary. 2023-02-01 15:26:07 -08:00
Simon Forman e44dd3c9e6 I think I'm doing this right? 2023-02-01 15:25:21 -08:00
Simon Forman 5a32c649f9 minor style glitch 2023-02-01 14:56:11 -08:00
Simon Forman e211fff94f Minor cleanup. 2023-02-01 14:55:21 -08:00
Simon Forman 28fa767593 Messing around with C. 2023-02-01 14:23:54 -08:00
Simon Forman 109cddae12 Readline support would be nice. 2022-10-17 17:51:12 -07:00
Simon Forman ec5036bf63 This and that. 2022-10-15 20:04:27 -07:00
Simon Forman 74f936efa0 Cleanup and refactoring.
Bug when subtracting identical numbers.  It gives

    [false 0]

When it should be

    [false]

or better yet

    [true]

eh?
2022-10-15 11:05:17 -07:00
Simon Forman 062b01da55 That seems to work: addition and subtraction. 2022-10-15 09:52:58 -07:00
Simon Forman c130026895 Mostly done with addition and subtraction. 2022-10-14 21:01:18 -07:00
Simon Forman 0b4b79f884 Not quite as smooth as I'd hoped. 2022-10-14 20:36:50 -07:00
Simon Forman 6ade65ef0c Subtraction seems to work now. 2022-10-14 17:52:31 -07:00
Simon Forman e7f4a021fe Misc stuff. 2022-10-10 22:28:50 -07:00
Simon Forman 2cf2b56751 Dang it... 2022-10-10 18:39:35 -07:00
Simon Forman 56fdf1eb18 Minor cleanup. 2022-09-28 22:07:28 -07:00
Simon Forman abddda47da Minor cleanup.
Functional Programming FTW!
2022-09-28 21:56:53 -07:00
Simon Forman 61bcf3588a Apparently this is redundant.
Discovered by running `nim doc joy.nim`, compiling doesn't flag it.
2022-09-28 21:22:19 -07:00
Simon Forman ec46cb6a2b Clear out old docs; update defs.txt. 2022-09-28 18:28:25 -07:00
Simon Forman cdec813b24 I had to model it in Python
before writing it in OCaml.
2022-09-28 18:21:13 -07:00
Simon Forman 4200c6708e Improve compiling of step combinator. 2022-09-28 18:18:20 -07:00
Simon Forman 8159e102d3 coms, swap 2022-09-24 21:19:35 -07:00
Simon Forman d94153583c Comparison operations. 2022-09-24 21:00:45 -07:00
Simon Forman c591bf4138 branch, dip, i, loop
The core combinators (except fork).
2022-09-24 20:45:06 -07:00
Simon Forman 3ecd7ab595 Minor cleanup. 2022-09-24 19:39:10 -07:00
Simon Forman 5e786db63f Simple REPL.
Still very crude, and exceptions are not caught, but it works.
2022-09-24 19:33:29 -07:00
Simon Forman 10cdba844b Minor cleanup. 2022-09-24 14:54:07 -07:00
Simon Forman d99d9ee8aa concat
Ocaml's match is very powerful, respect, but if I want more precise
error messages (that conform to the joytest suite) then the extra
utility functions must be implemented and employed.

After that it's definition loading and the main REPL loop and I think
that's it, eh?
2022-09-24 14:29:03 -07:00
Simon Forman 07f47a3b7a autoformat 2022-09-24 14:16:44 -07:00
Simon Forman 0905cdc0da clear 2022-09-24 14:16:20 -07:00
Simon Forman 813502532b Autoformat. 2022-09-24 13:13:44 -07:00
Simon Forman 977928362c Evaluation is working.
It's all downhill from here, like in skiing!
2022-09-24 13:13:03 -07:00
Simon Forman 5db538cc5c Eval symbols... 2022-09-24 12:54:46 -07:00
Simon Forman c7966f7ac8 Working towards interpretation. 2022-09-24 12:44:20 -07:00
Simon Forman 754fd1d1dc Nice and clean.
I wonder what Ocaml programmers would think of this code?
2022-09-24 12:02:00 -07:00
Simon Forman 9e2d148fbf Parser.
Mighty battle.
2022-09-24 11:00:19 -07:00
Simon Forman 0d88895ead Order is preserved. 2022-09-24 09:01:16 -07:00
Simon Forman c96cd6e296 A couple of little comments. 2022-09-24 08:59:38 -07:00
Simon Forman 4ff78dd65c Parse tokens into joy_list.
That seemed a lot harder than it should have been...
2022-09-24 08:54:04 -07:00
Simon Forman 54d287bc32 A start of parsing tokens. 2022-09-23 19:35:15 -07:00
Simon Forman 97f715a10d Formatting. 2022-09-23 17:47:31 -07:00
Simon Forman f45d070856 I think I got the tokenizer right. 2022-09-23 17:31:16 -07:00
Simon Forman 4d7ed83238 So that's mutual recursion in Ocaml?
I like it.  Just change "let" to "and" and you're good-to-go.
2022-09-23 08:59:06 -07:00
Simon Forman d717b594c4 Ignoring _build. 2022-09-23 08:54:37 -07:00
Simon Forman d0477eb516 Ignore _build dirs. 2022-09-23 08:53:39 -07:00
Simon Forman 64d4a42978 autoformat 2022-09-23 08:38:17 -07:00
Simon Forman c76ae9979d Ocaml FTW! 2022-09-23 08:37:04 -07:00
Simon Forman 8cb04fc72d At this point...
...I'm just relearning C semantics.  (And they are garbage, as is widely
known.)

I don't think there's much point to this (at the moment) because I don't
want to relearn C (at the moment) and Nim is available (at the moment.)

Really, I'm trying to do away with the entire relationship of C et. al.
to the underlying machine.  (For instance, Nim gives you a much nicer
relationship, without the vast distance that, say, Python imposes.)  I
should really look at other compiled languages, like Ocaml or Julia.
2022-09-22 20:43:25 -07:00
Simon Forman ae864909ee Create an int and add ints. 2022-09-22 20:08:24 -07:00
Simon Forman 5caa685bab Try using GC_register_finalizer? 2022-09-22 19:34:57 -07:00
Simon Forman 5ceab61ca1 Maybe this is the right thing to do?
https://stackoverflow.com/questions/59489221/using-the-gmp-library-with-boehms-garbage-collector
2022-09-22 19:00:40 -07:00
Simon Forman 813c5c0a23 What would a little C Joy look like?
Let's use GMP for ints and Boehm GC.
2022-09-22 17:26:28 -07:00
Simon Forman 92338037e7 Wait for both results together.
If one causes an error before the other is finished SIGKILL the other
job.  (I do not know if this will kill the sub-tasks if any.  The Python
docs say that with terminate() "descendant processes of the process will
not be terminated – they will simply become orphaned." but it doesn't
say whether that's true with kill().
2022-09-22 13:20:30 -07:00
Simon Forman 0904bad81b Capture and fwd exceptions in subforks.
(Should there be only one subtask?  Do the other quote in the main
proc?)
2022-09-22 11:41:16 -07:00
Simon Forman 50293908d9 Let's play with more cores. 2022-09-22 09:13:11 -07:00
Simon Forman caa4461217 Basic system, incomplete.
Still needs the rest of the core functions and defs.
Could read defs from a file at compile-time?
Integer math?  Boolean ops?  Just type inference and maybe compiling?
2022-09-20 17:56:18 -07:00
Simon Forman b49e7458c2 Parse the tokens into a Joy expression. 2022-09-20 17:14:41 -07:00
Simon Forman c8f67f02f9 Parser in GNU Prolog.
Wonky handling of UTF_8 blankspace.
2022-09-20 16:29:35 -07:00
Simon Forman 3f4e9d9fe2 The whole thing is kind of a mess. 2022-09-20 14:22:47 -07:00
Simon Forman d080cd20c7 Let simple joy be joy.
Still to do: clear away the rest of the old cruft.
2022-09-20 11:12:59 -07:00
Simon Forman 2367191918 Remove cruft. 2022-09-20 11:12:28 -07:00
Simon Forman a6ff9857d2 Add trace word back in.
Remove pretty_print module.

Still to do: update Nim implementation with a trace function. ;)
2022-09-20 10:19:45 -07:00
Simon Forman 36a9967e6c Fix typo in hyperlink in README. 2022-09-19 19:43:34 -07:00
Simon Forman fab172daf4 Minor cleanup. 2022-09-19 13:25:09 -07:00
Simon Forman b2a1f40155 Fixed bug in appN
while updating some Jupyter notebooks with the Joypy kernel.
2022-09-16 20:49:46 -07:00
Simon Forman 3d1dc6232e Remove old docs. 2022-09-16 17:54:42 -07:00
Simon Forman 77b1638d64 Check for minus before converting to int.
BigInts converts "-" to 0.  This happens in the parser before you get to
the evaluator.
2022-09-14 21:09:20 -07:00
Simon Forman 9d7a2a8fcb Minor cleanup, subtraction.
Testing with the joytest test suite revealed that I had forgotten to
implement subtraction.  This also unconvered a (maybe) bug in the
BigInts package where it converts "-" to zero.

https://git.sr.ht/~sforman/joytest

https://github.com/nim-lang/bigints/issues/116
2022-09-14 21:01:50 -07:00
Simon Forman 39008b351b Let simplejoy be joy.
Simple pleasures are the best.
2022-09-14 20:15:25 -07:00
Simon Forman f5265a2287 Remove old code. 2022-09-14 20:14:34 -07:00
Simon Forman 3f7adea56f Read defs.txt at compile-time.
I'd like to build the dict datastructure at compile-time too but I'm not
going to figure that out tonight.  It's enough that the defs are
embedded in the executable.  (You can see them with the strings utility.)
2022-09-14 20:08:40 -07:00
Simon Forman 30c57c180b basis complete 2022-09-14 18:51:58 -07:00
Simon Forman 0f79f089a6 dup, first, i, loop 2022-09-14 15:48:25 -07:00
Simon Forman f86e1b2e7c dip and cons 2022-09-14 15:04:07 -07:00
Simon Forman 129a5f776d Rewrite expression to use list instead of list node. 2022-09-14 14:36:29 -07:00
Simon Forman 9e5d699b0f Minor cleanup. 2022-09-14 13:31:44 -07:00
Simon Forman 3d199c1106 Reuse as_list(). 2022-09-14 11:24:56 -07:00
Simon Forman 9f04aa97e2 Cleaning up the code. 2022-09-14 10:49:13 -07:00
Simon Forman 6eb71b3c6e Nimpretty reformat. Two-space indentation. 2022-09-14 09:49:33 -07:00
Simon Forman 6b07d7d30b Minor cleanup 2022-09-14 09:46:31 -07:00
Simon Forman 94929e8520 Let's pile Nim code into one file too, why not? 2022-09-14 09:45:34 -07:00
Simon Forman aad2da35cf divmod
We don't need floor if we have only ints.

Id is too easy as a definition.

divmod is cool.
2022-09-12 16:38:14 -07:00
Simon Forman 1e3b2f76bb step, times 2022-09-12 16:07:21 -07:00
Simon Forman 8778f12b68 dipd, dipdd, cmp 2022-09-12 15:17:32 -07:00
Simon Forman f640f437f1 cond 2022-09-12 13:50:40 -07:00
Simon Forman 77bd7790f5 updated defs via make 2022-09-12 13:50:07 -07:00
Simon Forman 8ca20ec238 dunno what that was 2022-09-12 13:49:38 -07:00
Simon Forman a2cabe2189 Bringing over some of the "upgrades". 2 2022-09-11 14:07:55 -07:00
Simon Forman 4bd32f2c0b Bringing over some of the "upgrades". 2022-09-11 13:57:19 -07:00
Simon Forman cb553a1a65 id func 2022-09-11 11:46:10 -07:00
Simon Forman f7315291a9 clearing out cruft 2022-09-11 11:45:46 -07:00
Simon Forman a2cf184301 minor cleanup 2022-09-11 09:33:50 -07:00
Simon Forman 64946dc239 Put definitions in the docstring.
Why not? ¯\_(ツ)_/¯
2022-09-11 09:03:58 -07:00
Simon Forman aea619953d Model expr as stack-of-stacks, minor cleanup. 2022-09-11 08:57:45 -07:00
Simon Forman 16e6c77fa2 Don't bother to return the expression.
We mutate it instead of replacing it with new versions.
2022-09-10 17:42:38 -07:00
Simon Forman 4156da3511 Cleaner iteration of expression.
It's a destructive operation.  It breaks functional purity (but it could
be made functional by using a stack instead of a list for the stack.)

There's no point to returning the expression object now because it's
being mutated by the prepend() method (rather than being replaced by new
forms.)
2022-09-10 17:37:07 -07:00
Simon Forman 15c143e3d1 over
This slipped through the cracks, eh?  Should add a test to joytest.
2022-09-10 17:31:56 -07:00
Simon Forman 1032fc8e76 No point in a separate _parse() function. 2022-09-10 17:22:37 -07:00
Simon Forman 4fbe2ed4a0 Simpler tokenizer.
Once the syntax was simple enough the re.Scanner became overkill.

From
http://norvig.com/lispy.html
by way of
https://github.com/ckkashyap/s2c
2022-09-10 17:08:46 -07:00
Simon Forman 2ad303c247 A bit more docs. 2022-09-09 11:58:35 -07:00
Simon Forman f2791c02c3 Move ParseError to parser section; add a few type guards. 2022-09-08 20:59:12 -07:00
Simon Forman f08db94db1 Minor cleanup. 2022-09-08 14:25:02 -07:00
Simon Forman 359131f7b1 Expression objects.
This should be more efficient than concat().
2022-09-08 11:31:09 -07:00
Simon Forman eecc983b99 blacken 2022-09-08 10:37:46 -07:00
Simon Forman d7f047cee6 move stack code up under interp & minor edits 2022-09-08 09:06:26 -07:00
Simon Forman 20c4b90298 make type checks into Joy functions 2022-09-08 08:46:34 -07:00
Simon Forman ebdb8da03d move type checks and exceptions to bottom 2022-09-08 08:27:47 -07:00
Simon Forman ac326590db minor cleanup 2022-09-07 23:43:50 -07:00
Simon Forman e13a7b9f5c Remove debug session. 2022-09-07 22:23:23 -07:00
Simon Forman 69cb7febf6 That doesn't go there. 2022-09-07 21:15:09 -07:00
Simon Forman 9bb31cbc8a Minor cleanup. 2022-09-07 21:01:07 -07:00
Simon Forman 2c0a0aafcc halt and quit
halt captures the rest of the pending expression and stops evaluating,
but the interpreter loop keeps running.

quit ends the interpreter session and quits the Thun program.
2022-09-07 20:42:48 -07:00
Simon Forman 08f977324f Passes (updated) tests.
https://git.sr.ht/~sforman/joytest
2022-09-07 20:33:13 -07:00
Simon Forman 7594fb887f Harden up the types. 2022-09-07 19:39:00 -07:00
Simon Forman d7b445fdd4 Quiet mode for testing. Misc cleanup. 2022-09-07 17:27:36 -07:00
Simon Forman 660fdb0bef Just put ≡ inline. 2022-09-07 14:46:26 -07:00
Simon Forman 88f3cc4bbe Blacken the code. 2022-09-07 14:21:33 -07:00
Simon Forman 4f48ffbb5f Type-guard the ops. 2022-09-07 14:18:55 -07:00
Simon Forman 67fd88f68a Words and Help; use ≡ for definitions.
By using ≡ for definitions I can put docs in the DEFS string and easily
detect definitions by having them be each on their own line.
2022-09-07 13:13:46 -07:00
Simon Forman 29e6f160c6 It's a script. 2022-09-07 11:57:57 -07:00
Simon Forman 95366dde07 More docstrings. 2022-09-07 11:54:29 -07:00
Simon Forman 237f9bcfce Docstrings. 2022-09-07 11:46:59 -07:00
Simon Forman 51664c5856 Pylint is kind useless on this one. 2022-09-07 11:18:08 -07:00
Simon Forman acd0424287 Boolean literals. 2022-09-07 11:13:12 -07:00
Simon Forman 9fbcab6896 Docs (and strip trailing blanks.) 2022-09-07 10:42:20 -07:00
Simon Forman be13b72d93 Blacken the code (simplejoy.py)
I don't like it entirely but that's the point: nevermind your taste,
just use a simple and universal (Ha!) standard format(ter) and get on
with your life.
2022-09-07 09:41:08 -07:00
Simon Forman d6818620e3 Misc cruft. 2022-09-07 09:28:30 -07:00
Simon Forman 779ea5c7e5 Remove rust impl.
GitHub nagged me about some vuln in RE package or something?
https://github.com/calroc/Thun/security/dependabot/1
2022-09-07 09:24:20 -07:00
Simon Forman b386549226 Simple Joy 2022-09-07 09:23:02 -07:00
Simon Forman 4a5716d8b2 Rebuild HTML docs. 2022-08-16 15:26:07 -07:00
Simon Forman 3883cac99a Minor edits. 2022-08-15 16:20:59 -07:00
Simon Forman d0a253c503 Need to keep definition for ucons around
the Nim implementation has first and rest but not uncons.
2022-04-05 11:15:34 -07:00