OSDN Git Service

joypy/Thun.git
10 months agoName Boolean ops.
sforman [Sun, 30 Jul 2023 22:41:58 +0000 (15:41 -0700)]
Name Boolean ops.

So they don't overshadow the defs for the short-circuiting combinators.

10 months agoError type (not just a string.)
sforman [Sun, 30 Jul 2023 21:59:09 +0000 (14:59 -0700)]
Error type (not just a string.)

This is mostly for fun, but I bet it comes in handy, eh?

At the very least, it's a nice catalog of the possible errors that the
basic Joy system might encounter.

10 months agotype alias JoyFunction
sforman [Sun, 30 Jul 2023 21:27:27 +0000 (14:27 -0700)]
type alias JoyFunction

10 months agoFormat.
sforman [Sun, 30 Jul 2023 14:47:26 +0000 (07:47 -0700)]
Format.

10 months agoinscribe, definitions.
sforman [Sun, 30 Jul 2023 14:45:06 +0000 (07:45 -0700)]
inscribe, definitions.

10 months agoInitialize dict with defs.
sforman [Sun, 30 Jul 2023 00:10:45 +0000 (17:10 -0700)]
Initialize dict with defs.

Just sqr for now, but it shows that it works.

I would like to return Results from add_def but it makes using foldl
slightly tricky,  not a lot, just slightly, and my brainpower is low at
the mo'.

10 months agoLook up words in the dictionary.
sforman [Sat, 29 Jul 2023 19:35:47 +0000 (12:35 -0700)]
Look up words in the dictionary.

If they are not built-in, which means you can't "shadow" built-ins with
"inscribe", which may or may not turn out to be what we want?

10 months agoThread the dictionary through the call stack.
sforman [Sat, 29 Jul 2023 19:30:22 +0000 (12:30 -0700)]
Thread the dictionary through the call stack.

10 months agoEmpty string is not an unknown word.
sforman [Sat, 29 Jul 2023 19:11:43 +0000 (12:11 -0700)]
Empty string is not an unknown word.

10 months agoGotta keep a Dict around.
sforman [Sat, 29 Jul 2023 19:09:08 +0000 (12:09 -0700)]
Gotta keep a Dict around.

10 months agoLogical ops.
sforman [Sat, 29 Jul 2023 18:37:07 +0000 (11:37 -0700)]
Logical ops.

10 months agoLeft- and Right-shift.
sforman [Sat, 29 Jul 2023 18:32:22 +0000 (11:32 -0700)]
Left- and Right-shift.

10 months agoComparison ops.
sforman [Sat, 29 Jul 2023 18:07:50 +0000 (11:07 -0700)]
Comparison ops.

10 months agoloop
sforman [Sat, 29 Jul 2023 17:44:51 +0000 (10:44 -0700)]
loop

10 months agobranch
sforman [Sat, 29 Jul 2023 17:38:12 +0000 (10:38 -0700)]
branch

10 months agodip
sforman [Sat, 29 Jul 2023 17:28:31 +0000 (10:28 -0700)]
dip

10 months agoi
sforman [Sat, 29 Jul 2023 17:23:06 +0000 (10:23 -0700)]
i

10 months agotruthy
sforman [Sat, 29 Jul 2023 17:19:39 +0000 (10:19 -0700)]
truthy

I have to check into this: the Python version has "bool" and no
"truthy".

10 months agoswap
sforman [Sat, 29 Jul 2023 17:09:40 +0000 (10:09 -0700)]
swap

10 months agostack, swaack
sforman [Sat, 29 Jul 2023 17:00:16 +0000 (10:00 -0700)]
stack, swaack

10 months agopop
sforman [Sat, 29 Jul 2023 16:55:28 +0000 (09:55 -0700)]
pop

10 months agofirst, rest
sforman [Sat, 29 Jul 2023 16:53:00 +0000 (09:53 -0700)]
first, rest

10 months agodup
sforman [Sat, 29 Jul 2023 16:22:26 +0000 (09:22 -0700)]
dup

10 months agocons
sforman [Sat, 29 Jul 2023 16:17:27 +0000 (09:17 -0700)]
cons

10 months agoclear, concat
sforman [Sat, 29 Jul 2023 16:06:14 +0000 (09:06 -0700)]
clear, concat

10 months agoMinor cleanup.
sforman [Sat, 29 Jul 2023 15:57:58 +0000 (08:57 -0700)]
Minor cleanup.

10 months agoType alias JList
sforman [Sat, 29 Jul 2023 15:49:31 +0000 (08:49 -0700)]
Type alias JList

10 months agoRefactor pop_int.
sforman [Sat, 29 Jul 2023 14:51:31 +0000 (07:51 -0700)]
Refactor pop_int.

I don't like passing the stack through isnt_int but that let's you chain
with andThen.

There's probably a clever or idiomatic way to not do that and couple the
stack to the result without passing it through the type checker function
but I don't know what it is right now, and this works.

10 months agoBinary Math Ops
sforman [Sat, 29 Jul 2023 14:32:56 +0000 (07:32 -0700)]
Binary Math Ops

10 months agoI don't think andThen helps here?
sforman [Sat, 29 Jul 2023 14:19:08 +0000 (07:19 -0700)]
I don't think andThen helps here?

10 months agoI can add integers!
sforman [Sat, 29 Jul 2023 13:54:15 +0000 (06:54 -0700)]
I can add integers!

10 months agoParsing working.
sforman [Sat, 29 Jul 2023 04:51:34 +0000 (21:51 -0700)]
Parsing working.

Modeled on the OCaml code.

10 months agoA start on Joy types.
sforman [Fri, 28 Jul 2023 22:04:35 +0000 (15:04 -0700)]
A start on Joy types.

10 months agoIn Elm.
sforman [Fri, 28 Jul 2023 21:18:12 +0000 (14:18 -0700)]
In Elm.

10 months agoUse Python as SHELL in Makefile.
sforman [Thu, 27 Jul 2023 17:32:45 +0000 (10:32 -0700)]
Use Python as SHELL in Makefile.

It's a simple task, but I'm not up on my CLI tools, so I went with
Python instead of sh.  The split command doesn't have '-p' switch on
Ubuntu.  (I'm using Ubuntu on this laptop because it can correctly
configure the WiFi and the laptop has no ethernet port.)

10 months agominor cleanup
sforman [Thu, 27 Jul 2023 16:55:26 +0000 (09:55 -0700)]
minor cleanup

10 months agominor cleanup
sforman [Thu, 27 Jul 2023 16:55:02 +0000 (09:55 -0700)]
minor cleanup

10 months agoRename joy_to_ast to parser.
sforman [Thu, 27 Jul 2023 16:19:12 +0000 (09:19 -0700)]
Rename joy_to_ast to parser.

10 months agoWorking on the docs.
sforman [Thu, 27 Jul 2023 15:55:43 +0000 (08:55 -0700)]
Working on the docs.

The nbconvert tool has different behaviour now, so the HTML versions of
the notebooks look different.

10 months agoMinor work on the new site.
sforman [Thu, 27 Jul 2023 03:47:57 +0000 (20:47 -0700)]
Minor work on the new site.

I'm moving away from OSDN, there have been a few technical issues
recently.

10 months agoBold.
sforman [Wed, 26 Jul 2023 23:34:03 +0000 (16:34 -0700)]
Bold.

10 months agoMinor edits.
sforman [Wed, 26 Jul 2023 23:32:30 +0000 (16:32 -0700)]
Minor edits.

10 months agothe BinInt zero vanished?
sforman [Wed, 26 Jul 2023 05:01:55 +0000 (22:01 -0700)]
the BinInt zero vanished?

10 months agoMinor edits.
sforman [Wed, 26 Jul 2023 04:46:36 +0000 (21:46 -0700)]
Minor edits.

10 months agoWorking on README, put defs in joy.py
sforman [Wed, 26 Jul 2023 04:13:35 +0000 (21:13 -0700)]
Working on README, put defs in joy.py

I'm on an Ubuntu system right now and the split command doesn't have the
'-p' switch.  :(   I wasn't happy with that janky solution anyway.

10 months agominor edits
sforman [Wed, 26 Jul 2023 03:03:11 +0000 (20:03 -0700)]
minor edits

10 months agoMinor edits.
sforman [Tue, 25 Jul 2023 17:04:45 +0000 (10:04 -0700)]
Minor edits.

10 months agoMessing around with GNU Prolog.
sforman [Tue, 25 Jul 2023 15:51:27 +0000 (08:51 -0700)]
Messing around with GNU Prolog.

I have it broken up into three stages: a parser that reads a string from
stdin and emits (Prolog) AST to stdout; an interpreter of sorts that
reads AST from stdin, evaluates it, and then emits the AST of the stack
on stdout; and a printer that reads AST on stdin and prints Joy-ish code
to stdout.

I say Joy-ish because currently math is not evaluated and results of
math appear as expressions, not values.

This is because GNU Prolog doesn't have unbounded integers (it's numbers
are machine integers) so literals that are larger than the machine word
are converted into atoms!  To keep things simple, I made all ints into
atoms, but then you can't evaluate them: '1'+'2' is not '3' (it might be
'12' though.)

So I print them out at expressions:

    $ echo "1 2 3 4 [+ sub /] i" | ./joy_to_ast | ./thun | ./printer

    (1 div (2-(4+3)))

You could almost feed that to, say, Python to evaluate, eh? Or dc with
proper formatting?  (man dc; "Desk Calculator".)

Anyway, it's a start.  The Prolog interpreter is more for things like
type checking and inference, optimizing, compiling, etc.  Symbolic stuff
that's a PITA to express in other languages.  (The old type inference
code in Python was pages long, in Prolog it's just the thun/3 & thun/4
predicates themselves.  At least so far.  There are things we will want
to do eventually that might be a PITA to express in Prolog, eh?

10 months agoCompile on Ubuntu.
sforman [Mon, 24 Jul 2023 18:29:39 +0000 (11:29 -0700)]
Compile on Ubuntu.

10 months agoMake it compatible with Xerblin.
sforman [Mon, 24 Jul 2023 18:29:06 +0000 (11:29 -0700)]
Make it compatible with Xerblin.

10 months agoMinor edits.
sforman [Mon, 24 Jul 2023 18:28:45 +0000 (11:28 -0700)]
Minor edits.

14 months agoMinor cleanup.
Simon Forman [Wed, 22 Mar 2023 21:45:54 +0000 (14:45 -0700)]
Minor cleanup.

14 months agoi combinator.
Simon Forman [Wed, 22 Mar 2023 18:54:17 +0000 (11:54 -0700)]
i combinator.

On a lark I implemented it in recursive style, but I'm not going to keep
it that way.  I have to implement next_term() first and then I'll
uncomment i_joy_combinator().

14 months agoconcat
Simon Forman [Wed, 22 Mar 2023 15:41:09 +0000 (08:41 -0700)]
concat

14 months agocons
Simon Forman [Tue, 21 Mar 2023 19:34:28 +0000 (12:34 -0700)]
cons

14 months agominor cleanup
Simon Forman [Tue, 21 Mar 2023 16:38:50 +0000 (09:38 -0700)]
minor cleanup

14 months agofirst
Simon Forman [Tue, 21 Mar 2023 16:33:20 +0000 (09:33 -0700)]
first

14 months agorest
Simon Forman [Tue, 21 Mar 2023 16:27:00 +0000 (09:27 -0700)]
rest

14 months agorest CANNOT_TAKE_REST_OF_EMPTY_LIST
Simon Forman [Tue, 21 Mar 2023 16:19:12 +0000 (09:19 -0700)]
rest CANNOT_TAKE_REST_OF_EMPTY_LIST

14 months agoswap
Simon Forman [Mon, 20 Mar 2023 23:33:11 +0000 (16:33 -0700)]
swap

14 months agoCheck for error after cons'ing term.
Simon Forman [Sat, 18 Mar 2023 21:13:51 +0000 (14:13 -0700)]
Check for error after cons'ing term.

14 months agopop_any()
Simon Forman [Sat, 18 Mar 2023 19:48:59 +0000 (12:48 -0700)]
pop_any()

14 months agodup
Simon Forman [Sat, 18 Mar 2023 19:43:30 +0000 (12:43 -0700)]
dup

14 months agostack function.
Simon Forman [Sat, 18 Mar 2023 19:31:36 +0000 (12:31 -0700)]
stack function.

14 months agopop()
Simon Forman [Sat, 18 Mar 2023 18:50:18 +0000 (11:50 -0700)]
pop()

14 months agoMove pop_list().
Simon Forman [Sat, 18 Mar 2023 18:41:16 +0000 (11:41 -0700)]
Move pop_list().

14 months agoNo reason to pass expression to function.
Simon Forman [Sat, 18 Mar 2023 18:40:19 +0000 (11:40 -0700)]
No reason to pass expression to function.

14 months agopop_list()
Simon Forman [Sat, 18 Mar 2023 18:31:38 +0000 (11:31 -0700)]
pop_list()

Kind of a misnomer, you have to take the tail() of the stack yourself.
This function only returns the list from TOS.

14 months agoMinor cleanup.
Simon Forman [Sat, 18 Mar 2023 18:31:12 +0000 (11:31 -0700)]
Minor cleanup.

14 months agoSwaack and error macro.
Simon Forman [Sat, 18 Mar 2023 18:26:27 +0000 (11:26 -0700)]
Swaack and error macro.

14 months agoUse clear, set up for swaack.
Simon Forman [Sat, 18 Mar 2023 17:40:49 +0000 (10:40 -0700)]
Use clear, set up for swaack.

14 months agoClear.
Simon Forman [Fri, 17 Mar 2023 19:10:18 +0000 (12:10 -0700)]
Clear.

14 months agoDid i not commit this?
Simon Forman [Fri, 10 Mar 2023 22:11:54 +0000 (14:11 -0800)]
Did i not commit this?

15 months agoA start on the joy() interpeter.
Simon Forman [Mon, 6 Mar 2023 07:20:37 +0000 (23:20 -0800)]
A start on the joy() interpeter.

15 months agoMinor cleanup.
Simon Forman [Mon, 6 Mar 2023 07:04:56 +0000 (23:04 -0800)]
Minor cleanup.

15 months agoCatch unbalanced brackets.
Simon Forman [Mon, 6 Mar 2023 03:37:15 +0000 (19:37 -0800)]
Catch unbalanced brackets.

15 months agoMinor cleanup.
Simon Forman [Mon, 6 Mar 2023 03:26:34 +0000 (19:26 -0800)]
Minor cleanup.

15 months agoOnly allocate strings once.
Simon Forman [Mon, 6 Mar 2023 02:46:05 +0000 (18:46 -0800)]
Only allocate strings once.

That for loop in hash_fragment() is the gnarliest I've ever written.

15 months agoCombine tokenizer and parser.
Simon Forman [Mon, 6 Mar 2023 01:01:25 +0000 (17:01 -0800)]
Combine tokenizer and parser.

I'm pretty happy with this. It's iterative rather than recursive so you
won't blow out the call stack if you want to parse a million brackets
(intermediate results are stored on (another) little stack.)  It scans
the string and builds lists and sublists as it goes, without wasting
cons cells.

15 months agoThread error handling through tokenizer.
Simon Forman [Sun, 5 Mar 2023 23:20:22 +0000 (15:20 -0800)]
Thread error handling through tokenizer.

15 months agoIt turns out the error machinery was working...
Simon Forman [Sun, 5 Mar 2023 22:36:55 +0000 (14:36 -0800)]
It turns out the error machinery was working...

So I was memset'ing the hash table and string table /after/ setting up
the left- and right-bracket tokens! So then when I tried to print the
token list and ht_lookup() dutifully set the error code when it couldn't
find the strings in the hash table, the system properly quit printing
and halted.  D'oh!  That was a subtle one.  Obvious in hindsight.

15 months agoFold parser code into joy_types.c
Simon Forman [Sun, 5 Mar 2023 04:50:34 +0000 (20:50 -0800)]
Fold parser code into joy_types.c

Add some docs, minor cleanup.

15 months agoIt seems to be working.
Simon Forman [Sun, 5 Mar 2023 01:48:26 +0000 (17:48 -0800)]
It seems to be working.

It took all expletive-deleted day but I finally nailed it down.  In the
end the last bug was I was decrementing a stack pointer /after/ trying
to load the item at the (empty) top of the stack.  Classic.

I still need to make it not re-allocate strings that it has already
interned, but beyond that I think it's fine.

15 months agotokenate() and reverse_list_in_place()
Simon Forman [Sun, 5 Mar 2023 01:23:54 +0000 (17:23 -0800)]
tokenate() and reverse_list_in_place()

15 months agoUse symbols for tokens for brackets.
Simon Forman [Sat, 4 Mar 2023 23:48:55 +0000 (15:48 -0800)]
Use symbols for tokens for brackets.

Try a different tack on the parser.

15 months agoAlmost working parser.
Simon Forman [Sat, 4 Mar 2023 19:59:19 +0000 (11:59 -0800)]
Almost working parser.

15 months agoMinor cleanup.
Simon Forman [Sat, 4 Mar 2023 16:31:40 +0000 (08:31 -0800)]
Minor cleanup.

Some printing to see the machinery in action.

15 months agoJoy parser in NCC.
Simon Forman [Sat, 4 Mar 2023 16:25:32 +0000 (08:25 -0800)]
Joy parser in NCC.

15 months agoA start on error handling.
Simon Forman [Sat, 4 Mar 2023 03:23:15 +0000 (19:23 -0800)]
A start on error handling.

15 months agoDouble hashing w/ extra bits of hash.
Simon Forman [Fri, 3 Mar 2023 22:52:26 +0000 (14:52 -0800)]
Double hashing w/ extra bits of hash.

15 months agoA start on a hash table for symbols.
Simon Forman [Fri, 3 Mar 2023 20:05:40 +0000 (12:05 -0800)]
A start on a hash table for symbols.

15 months agoJoy in UVM NCC code.
Simon Forman [Fri, 3 Mar 2023 15:31:52 +0000 (07:31 -0800)]
Joy in UVM NCC code.

15 months agoA bunch of stuff.
Simon Forman [Fri, 3 Mar 2023 15:30:55 +0000 (07:30 -0800)]
A bunch of stuff.

15 months agoMinor cleanup.
Simon Forman [Tue, 28 Feb 2023 15:45:38 +0000 (07:45 -0800)]
Minor cleanup.

15 months agoUse defines to abstract font choice.
Simon Forman [Tue, 28 Feb 2023 15:14:33 +0000 (07:14 -0800)]
Use defines to abstract font choice.

Clunky but now you only have to change the font name four time in one
place rather than N times in N places, eh?

Writing C again for the first time in ages (this and the Joy
interpreter) the using the preprocessor is like stone-age
meta-programming, from the lens of lisp it's like, "you do what to your
source code?".

15 months agoA different font.
Simon Forman [Tue, 28 Feb 2023 14:53:31 +0000 (06:53 -0800)]
A different font.

It's easy enough to substitute a different font in the call to
Imagemagick's `convert` tool, but in the case of pixel fonts, it will
scale them, so you're not getting a proper bitmap of the pixels, you're
getting a kind of screenshot of the pixels.

I want to make a different machinery for bitmapped pixel fonts, and I
want to make a simple DEFINE-based way to pick them without having to
edit your source code,  e.g. #define font_data font_PublicPixel_22_data
yeah?

After that, simple affine transforms for fake 3D..

15 months agoWu-ish lines.
Simon Forman [Tue, 28 Feb 2023 03:27:32 +0000 (19:27 -0800)]
Wu-ish lines.

15 months agoMostly working Wu-ish algorithm.
Simon Forman [Tue, 28 Feb 2023 00:29:45 +0000 (16:29 -0800)]
Mostly working Wu-ish algorithm.

15 months agoMinor cleanup.
Simon Forman [Mon, 27 Feb 2023 05:46:05 +0000 (21:46 -0800)]
Minor cleanup.

15 months agoCicada bg, needs work.
Simon Forman [Mon, 27 Feb 2023 05:02:57 +0000 (21:02 -0800)]
Cicada bg, needs work.

Not as pretty as I'd hoped.

Putting a pin in Wu lines for tonight.  I'll lick it in the morning when
I'm fresh.