Commit Graph

81 Commits

Author SHA1 Message Date
Simon Forman f194df8159 How would you compile this?
fn [+] step
2023-02-19 17:43:18 -08:00
Simon Forman 10edbd0ee0 Used "Artistic Style" (astyle) to check formatting. 2023-02-15 17:22:14 -08:00
Simon Forman db322b0b3b Emit error messages on stderr. 2023-02-14 17:52:52 -08:00
Simon Forman c2eae95bb2 lshift and rshift for C. 2023-02-14 13:15:53 -08:00
Simon Forman 9c355166b6 Bring error message inline with other implementations. 2023-02-14 12:07:58 -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 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 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 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 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 0c8e49d591 dispatch 2023-02-07 17:44:32 -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 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 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 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 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 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 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