OSDN Git Service

joypy/Thun.git
14 months agoand, or (Boolean ops). simpler
Simon Forman [Thu, 9 Feb 2023 15:52:50 +0000 (07:52 -0800)]
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.

14 months agodivmod, xor
Simon Forman [Thu, 9 Feb 2023 14:59:39 +0000 (06:59 -0800)]
divmod, xor

14 months agoAllow for redefinition of user defs.
Simon Forman [Thu, 9 Feb 2023 07:20:35 +0000 (23:20 -0800)]
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.

14 months agoUser definitions with the inscribe command.
Simon Forman [Thu, 9 Feb 2023 05:13:23 +0000 (21:13 -0800)]
User definitions with the inscribe command.

Using uthash http://troydhanson.github.io/uthash/index.html

14 months agounstack
Simon Forman [Wed, 8 Feb 2023 23:06:12 +0000 (15:06 -0800)]
unstack

14 months agoHandle definitions with non-alphanumeric chars in their names.
Simon Forman [Wed, 8 Feb 2023 20:50:23 +0000 (12:50 -0800)]
Handle definitions with non-alphanumeric chars in their names.

14 months agoOh, LDFLAGS, right...
Simon Forman [Wed, 8 Feb 2023 19:55:33 +0000 (11:55 -0800)]
Oh, LDFLAGS, right...

14 months agoInitializers for Boolean values.
Simon Forman [Wed, 8 Feb 2023 04:53:44 +0000 (20:53 -0800)]
Initializers for Boolean values.

14 months agoMinor cleanup.
Simon Forman [Wed, 8 Feb 2023 04:47:32 +0000 (20:47 -0800)]
Minor cleanup.

14 months agoAliases can be put in KEYWORDS.in
Simon Forman [Wed, 8 Feb 2023 03:14:37 +0000 (19:14 -0800)]
Aliases can be put in KEYWORDS.in

This avoids the overhead of single-functions definitions for aliases.

14 months agodispatch
Simon Forman [Wed, 8 Feb 2023 01:44:32 +0000 (17:44 -0800)]
dispatch

14 months agoTrack KEYWORDS.txt after all.
Simon Forman [Mon, 6 Feb 2023 21:14:14 +0000 (13:14 -0800)]
Track KEYWORDS.txt after all.

14 months agoeq, neq, gt, ge, lt, le
Simon Forman [Mon, 6 Feb 2023 21:09:37 +0000 (13:09 -0800)]
eq, neq, gt, ge, lt, le

14 months agoA bunch of definitions.
Simon Forman [Mon, 6 Feb 2023 20:59:39 +0000 (12:59 -0800)]
A bunch of definitions.

Still to do: the comparison functions.

14 months agoUse setjmp/longjmp to recover after errors.
Simon Forman [Mon, 6 Feb 2023 08:30:25 +0000 (00:30 -0800)]
Use setjmp/longjmp to recover after errors.

Wow!  That was easy!

14 months agoClean KEYWORDS.txt too.
Simon Forman [Mon, 6 Feb 2023 04:48:19 +0000 (20:48 -0800)]
Clean KEYWORDS.txt too.

14 months agopop_list <=> pop_list_node
Simon Forman [Mon, 6 Feb 2023 03:47:32 +0000 (19:47 -0800)]
pop_list <=> pop_list_node

These names seem like they should be swapped.

14 months agominor cleanup
Simon Forman [Mon, 6 Feb 2023 03:40:16 +0000 (19:40 -0800)]
minor cleanup

14 months agoloop
Simon Forman [Mon, 6 Feb 2023 02:43:05 +0000 (18:43 -0800)]
loop

But it's pretty inefficient, eh?

14 months agofirst, rest
Simon Forman [Mon, 6 Feb 2023 01:40:26 +0000 (17:40 -0800)]
first, rest

14 months agoA README file.
Simon Forman [Sun, 5 Feb 2023 22:54:33 +0000 (14:54 -0800)]
A README file.

14 months agominor cleanup
Simon Forman [Sun, 5 Feb 2023 21:53:53 +0000 (13:53 -0800)]
minor cleanup

14 months agoAuto-generate defintions from defs.txt
Simon Forman [Sun, 5 Feb 2023 21:50:16 +0000 (13:50 -0800)]
Auto-generate defintions from defs.txt

But it doesn't yet handle names with non-C-indentifier characters in
them.

14 months agoGenerate definitions.h; swons
Simon Forman [Sun, 5 Feb 2023 21:38:59 +0000 (13:38 -0800)]
Generate definitions.h; swons

14 months agoPut defs into a generated file.
Simon Forman [Sun, 5 Feb 2023 21:04:31 +0000 (13:04 -0800)]
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...

14 months agopush_quote_onto_expression
Simon Forman [Sun, 5 Feb 2023 19:58:44 +0000 (11:58 -0800)]
push_quote_onto_expression

doesn't push an empty list, unlike push_quote() which does.

14 months agoconcat
Simon Forman [Sun, 5 Feb 2023 19:00:22 +0000 (11:00 -0800)]
concat

14 months agoswap
Simon Forman [Sun, 5 Feb 2023 18:27:17 +0000 (10:27 -0800)]
swap

14 months agoforgot to save
Simon Forman [Sun, 5 Feb 2023 18:23:50 +0000 (10:23 -0800)]
forgot to save

14 months agoNo clear def.
Simon Forman [Sun, 5 Feb 2023 18:05:20 +0000 (10:05 -0800)]
No clear def.

14 months agoRemove def of clear.
Simon Forman [Sun, 5 Feb 2023 18:04:20 +0000 (10:04 -0800)]
Remove def of clear.

It's a neat example of a custom implementation being more efficient than
the Joy code.

14 months agostack
Simon Forman [Sun, 5 Feb 2023 18:00:18 +0000 (10:00 -0800)]
stack

14 months agoswaack
Simon Forman [Sun, 5 Feb 2023 17:54:52 +0000 (09:54 -0800)]
swaack

14 months agopop
Simon Forman [Sun, 5 Feb 2023 17:50:41 +0000 (09:50 -0800)]
pop

14 months agocons
Simon Forman [Sun, 5 Feb 2023 17:40:47 +0000 (09:40 -0800)]
cons

14 months agodip
Simon Forman [Sun, 5 Feb 2023 16:49:05 +0000 (08:49 -0800)]
dip

14 months agominor cleanup
Simon Forman [Sun, 5 Feb 2023 16:38:15 +0000 (08:38 -0800)]
minor cleanup

14 months agodup
Simon Forman [Sun, 5 Feb 2023 16:37:13 +0000 (08:37 -0800)]
dup

14 months agominor cleanup
Simon Forman [Sun, 5 Feb 2023 16:12:32 +0000 (08:12 -0800)]
minor cleanup

14 months agotruthy
Simon Forman [Sun, 5 Feb 2023 07:45:13 +0000 (23:45 -0800)]
truthy

14 months agoDefinitions.
Simon Forman [Sun, 5 Feb 2023 07:08:39 +0000 (23:08 -0800)]
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.

14 months agoA first attempt at definitions.
Simon Forman [Sun, 5 Feb 2023 06:58:38 +0000 (22:58 -0800)]
A first attempt at definitions.

14 months agoAlmost truthy...
Simon Forman [Sun, 5 Feb 2023 06:58:16 +0000 (22:58 -0800)]
Almost truthy...

14 months agodiv and mod
Simon Forman [Sun, 5 Feb 2023 03:34:38 +0000 (19:34 -0800)]
div and mod

14 months agoclear
Simon Forman [Sun, 5 Feb 2023 03:21:13 +0000 (19:21 -0800)]
clear

14 months agobranch combinator.
Simon Forman [Sun, 5 Feb 2023 03:19:48 +0000 (19:19 -0800)]
branch combinator.

14 months agoi combinator.
Simon Forman [Sun, 5 Feb 2023 03:05:26 +0000 (19:05 -0800)]
i combinator.

14 months agoDepend on joy.h.
Simon Forman [Sun, 5 Feb 2023 02:59:59 +0000 (18:59 -0800)]
Depend on joy.h.

14 months agoMinor cleanup, print_stack.
Simon Forman [Sun, 5 Feb 2023 02:51:58 +0000 (18:51 -0800)]
Minor cleanup, print_stack.

14 months agoMinor cleanup.
Simon Forman [Sat, 4 Feb 2023 21:46:29 +0000 (13:46 -0800)]
Minor cleanup.

14 months agoExpression is a list-of-lists now.
Simon Forman [Sat, 4 Feb 2023 21:38:28 +0000 (13:38 -0800)]
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.

14 months agoCmp, comes with GMP.
Simon Forman [Sat, 4 Feb 2023 20:47:45 +0000 (12:47 -0800)]
Cmp, comes with GMP.

14 months agoBoolean singleton values.
Simon Forman [Sat, 4 Feb 2023 19:27:03 +0000 (11:27 -0800)]
Boolean singleton values.

14 months agoBoolean singleton values.
Simon Forman [Sat, 4 Feb 2023 18:25:14 +0000 (10:25 -0800)]
Boolean singleton values.

14 months agoNode head is pointer now.
Simon Forman [Sat, 4 Feb 2023 16:12:30 +0000 (08:12 -0800)]
Node head is pointer now.

14 months agoJoyListPtr too
Simon Forman [Sat, 4 Feb 2023 15:55:11 +0000 (07:55 -0800)]
JoyListPtr too

14 months agoUse JoyListPtr.
Simon Forman [Sat, 4 Feb 2023 15:52:36 +0000 (07:52 -0800)]
Use JoyListPtr.

14 months agosub and mul through judicious (I hope) use of macros.
Simon Forman [Sat, 4 Feb 2023 03:38:18 +0000 (19:38 -0800)]
sub and mul through judicious (I hope) use of macros.

14 months agopop_any(), pop_int(), and add
Simon Forman [Fri, 3 Feb 2023 23:46:52 +0000 (15:46 -0800)]
pop_any(), pop_int(), and add

14 months agoInterpret symbols.
Simon Forman [Fri, 3 Feb 2023 19:48:32 +0000 (11:48 -0800)]
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.

14 months agoYet more minor cleanup.
Simon Forman [Fri, 3 Feb 2023 17:39:02 +0000 (09:39 -0800)]
Yet more minor cleanup.

14 months agoMore minor cleanup.
Simon Forman [Fri, 3 Feb 2023 17:30:11 +0000 (09:30 -0800)]
More minor cleanup.

14 months agoMinor cleanup.
Simon Forman [Fri, 3 Feb 2023 17:27:30 +0000 (09:27 -0800)]
Minor cleanup.

14 months agonewJoyList
Simon Forman [Fri, 3 Feb 2023 17:18:32 +0000 (09:18 -0800)]
newJoyList

14 months agoCan haz function pointers in my worldist.
Simon Forman [Fri, 3 Feb 2023 16:13:57 +0000 (08:13 -0800)]
Can haz function pointers in my worldist.

14 months agotypedef for the win!
Simon Forman [Fri, 3 Feb 2023 04:45:28 +0000 (20:45 -0800)]
typedef for the win!

14 months agomake clean rule
Simon Forman [Fri, 3 Feb 2023 01:02:55 +0000 (17:02 -0800)]
make clean rule

14 months agoUse gperf to save memory.
Simon Forman [Fri, 3 Feb 2023 00:58:44 +0000 (16:58 -0800)]
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!)

14 months agoIgnore object files.
Simon Forman [Fri, 3 Feb 2023 00:14:11 +0000 (16:14 -0800)]
Ignore object files.

14 months agominor cleanup
Simon Forman [Fri, 3 Feb 2023 00:13:15 +0000 (16:13 -0800)]
minor cleanup

14 months agoGperf.
Simon Forman [Fri, 3 Feb 2023 00:12:59 +0000 (16:12 -0800)]
Gperf.

14 months agoMinor cleanup.
Simon Forman [Thu, 2 Feb 2023 21:22:11 +0000 (13:22 -0800)]
Minor cleanup.

14 months agoTrue and False values.
Simon Forman [Thu, 2 Feb 2023 21:06:07 +0000 (13:06 -0800)]
True and False values.

14 months agoCopyright, etc.
Simon Forman [Thu, 2 Feb 2023 19:14:58 +0000 (11:14 -0800)]
Copyright, etc.

14 months agoFix bug with no trailing spaces.
Simon Forman [Thu, 2 Feb 2023 18:58:03 +0000 (10:58 -0800)]
Fix bug with no trailing spaces.

Gotta update that pointer, eh?

14 months agoI was post-incrementing when I should have been pre-incrementing!
Simon Forman [Thu, 2 Feb 2023 16:52:27 +0000 (08:52 -0800)]
I was post-incrementing when I should have been pre-incrementing!

D'oh!

14 months agoSimple terms work. Problem is with sub-lists.
Simon Forman [Thu, 2 Feb 2023 16:36:13 +0000 (08:36 -0800)]
Simple terms work. Problem is with sub-lists.

14 months agoParsing isn't this hard?
Simon Forman [Thu, 2 Feb 2023 16:32:45 +0000 (08:32 -0800)]
Parsing isn't this hard?

14 months agoUm, don't do that.
Simon Forman [Thu, 2 Feb 2023 04:36:18 +0000 (20:36 -0800)]
Um, don't do that.

I wonder where the data was winding up?

14 months agoMinor cleanup.
Simon Forman [Thu, 2 Feb 2023 04:34:49 +0000 (20:34 -0800)]
Minor cleanup.

14 months agoRemove separate parser code.
Simon Forman [Thu, 2 Feb 2023 04:34:04 +0000 (20:34 -0800)]
Remove separate parser code.

14 months agoPrint true, false, and lists.
Simon Forman [Thu, 2 Feb 2023 04:33:04 +0000 (20:33 -0800)]
Print true, false, and lists.

14 months agoPrint ints.
Simon Forman [Thu, 2 Feb 2023 04:28:24 +0000 (20:28 -0800)]
Print ints.

14 months agoPrint list.
Simon Forman [Thu, 2 Feb 2023 04:09:03 +0000 (20:09 -0800)]
Print list.

14 months agoText to expr coming along.
Simon Forman [Thu, 2 Feb 2023 03:26:50 +0000 (19:26 -0800)]
Text to expr coming along.

14 months agoNeed to be able to store a string.
Simon Forman [Thu, 2 Feb 2023 02:37:10 +0000 (18:37 -0800)]
Need to be able to store a string.

14 months agoMinor cleanup.
Simon Forman [Thu, 2 Feb 2023 02:35:11 +0000 (18:35 -0800)]
Minor cleanup.

14 months agoMinor cleanup.
Simon Forman [Thu, 2 Feb 2023 01:39:37 +0000 (17:39 -0800)]
Minor cleanup.

Don't pass NULL to strpbrk().

14 months agoHandle stretches of blanks.
Simon Forman [Thu, 2 Feb 2023 01:25:54 +0000 (17:25 -0800)]
Handle stretches of blanks.

Don't create zero-length strings.

14 months agoNice skeleton of parser.
Simon Forman [Thu, 2 Feb 2023 01:17:35 +0000 (17:17 -0800)]
Nice skeleton of parser.

14 months agoAlmost there on parsing.
Simon Forman [Thu, 2 Feb 2023 00:57:46 +0000 (16:57 -0800)]
Almost there on parsing.

14 months agotrim_leading_blanks
Simon Forman [Thu, 2 Feb 2023 00:40:14 +0000 (16:40 -0800)]
trim_leading_blanks

14 months agoLet's parse.
Simon Forman [Thu, 2 Feb 2023 00:02:19 +0000 (16:02 -0800)]
Let's parse.

14 months agoDon't version the binary.
Simon Forman [Wed, 1 Feb 2023 23:26:07 +0000 (15:26 -0800)]
Don't version the binary.

14 months agoI think I'm doing this right?
Simon Forman [Wed, 1 Feb 2023 23:25:21 +0000 (15:25 -0800)]
I think I'm doing this right?

14 months agominor style glitch
Simon Forman [Wed, 1 Feb 2023 22:56:11 +0000 (14:56 -0800)]
minor style glitch

14 months agoMinor cleanup.
Simon Forman [Wed, 1 Feb 2023 22:55:21 +0000 (14:55 -0800)]
Minor cleanup.

14 months agoSome notebooks.
Simon Forman [Wed, 1 Feb 2023 22:54:07 +0000 (14:54 -0800)]
Some notebooks.

14 months agoMessing around with C.
Simon Forman [Wed, 1 Feb 2023 22:23:54 +0000 (14:23 -0800)]
Messing around with C.

18 months agoReadline support would be nice.
Simon Forman [Tue, 18 Oct 2022 00:51:12 +0000 (17:51 -0700)]
Readline support would be nice.