Commit Graph

187 Commits

Author SHA1 Message Date
5ab4694c66 I don't know what I was doing here but I probably won't return to this branch anyway 2023-10-14 15:19:27 +02:00
Brian Picciano
92f93ff076 Implement Decoder
The sytax has ultimately remained unchanged, except for the new ability
to have tuples as edge values, changing the tuple value separator to
`,`, and allowing for the eliding of trailing `;` and `,`.
2022-12-27 17:15:24 +01:00
Brian Picciano
e06b20b604 Fold graph::Graph into gg::Graph, add TokenKind::End to lexer 2022-12-27 00:01:42 +01:00
Brian Picciano
6b5f2d7e82 Developed gg.bnf 2022-12-26 22:36:34 +01:00
Brian Picciano
20e050438c Finish up lexer, add tests for it 2022-12-26 17:54:08 +01:00
Brian Picciano
2919bcaa77 Implemented lexer 2022-12-24 23:33:32 +01:00
Brian Picciano
0248a11285 Initial implementation of the Graph type in rust, construction functions only 2022-12-24 14:15:31 +01:00
Brian Picciano
2be865181d Complete refactor vm to not be as stupid
This commit is the result of many days of picking vm apart and putting
it back together again. The result is an implementation which separates
compile and runtime into separate steps, and which functions (more)
correctly in the face of recursion.

Pretty much all aspects of vm have been modified or deleted, so it's not
even really worth it to describe specific changes. Just pretend this is
the original implementaiton and the old one was never done.
2022-03-31 09:27:52 -06:00
Brian Picciano
ebf57591a8 Got basic demo working, ran go fmt 2021-12-30 15:29:38 -07:00
Brian Picciano
6257495fe4 Implement all builtins required to get fib working
Getting `recur` to work required adding an Operation argument to a bunch
of places in a really hacky way. I don't like it at all, but I'm also
kind of out of mental energy to figure it out properly. The fibonacci
demo in the README _works_, at least, though I don't think it's actually
tail recursive.
2021-12-30 15:10:25 -07:00
Brian Picciano
3a2423a937 Refactor vm to use MapReduce and Thunks
The new code is much simpler, and is able to handle more cases than
before, such as the `if` operation.
2021-12-30 14:21:58 -07:00
Brian Picciano
223b7f93a5 Implement graph.MapReduce 2021-12-30 13:59:31 -07:00
Brian Picciano
2a96e9a593 Reverse order of args in ValueOut, TupleOut, and AddValueIn
The order of these methods now matches the order of edge/value in every
other context.
2021-12-30 11:38:36 -07:00
Brian Picciano
9c48232ac1 Allow Graph edge and vertex values to be different types
Lots of type aliases in use with `gg` to make this not be a verbose
clusterfuck.
2021-12-30 09:56:20 -07:00
Brian Picciano
c4dd673bf4 Refactor Graph internals to deduplicate OpenEdges
This change required OpenEdges to be passed around as pointers, which in
turn required me to audit how value copying is being done everywhere and
simplify it in a few places. I think I covered all the bases.

The new internals of Graph allow the graph's actual structure to be
reflected within the graph itself. For example, if the OpenEdges of two
ValueIns are equivalent then the same OpenEdge pointer is shared for the
two internally. This applies recursively, so if two OpenEdge tuples
share an inner OpenEdge, they will share the same pointer.

This change is a preliminary requirement for creating a graph mapping
operation. Without OpenEdge deduplication the map operation would end up
operating on the same OpenEdge multiple times, which would be incorrect.
2021-12-29 13:57:14 -07:00
Brian Picciano
181c392219 Cleanup internals of graph a bit
There's no need for the `vertex` type anymore, `OpenEdge` can just hold
its values directly.
2021-12-29 12:55:45 -07:00
Brian Picciano
f5f0f6e436 Ditch gim... for now
It was an interesting idea, but now that an actual text-based syntax is
worked out and definitely going to be used gim is just making tests
fail for no gain. It can be resurrected from the git history in the
future, if needed.
2021-12-29 12:51:16 -07:00
Brian Picciano
e7991adfaa Make graph generic
The base graph implementation has been moved into its own package,
`graph`, and been made fully generic, ie the value on each vertex/edge
is a parameterized type. This will allow us to use the graph for both
syntax parsing (gg) and runtime evaluation (vm), with each use-case
being able to use slightly different Value types.
2021-12-29 12:32:53 -07:00
Brian Picciano
6040abc836 Implementation of a super basic vm
The vm does what it needs to do (evaluate the result of passing an input
to an operatio, where the input and the operation themselves may have
sub-inputs/operations to evaluate), with many caveats/misgivings.
2021-12-29 10:43:08 -07:00
Brian Picciano
ec3218e2d0 Allow for traversing OpenEdges
Three new methods, EdgeValue, FromValue, and FromTuple, have been added
to OpenEdge in order to allow future users of the gg package to traverse
the graph.
2021-12-28 10:05:40 -07:00
Brian Picciano
c5aa582226 Improve semantics of tokens and values obtained from them.
Now gg.Values can carry the token used to parse them, which will be
useful later when generating errors.
2021-12-28 09:49:02 -07:00
Brian Picciano
33e59a3836 Implement Decoder
The decoder basically works, though there's some quirks in the design
I'll need to marinate one. For example, you can't have a tuple as an
edge value. This is probably fine?

Stringification of Graphs was added to aid in debugging the decoder, the
format it outputs is not the final one. Most likely the (future) encoder
will be used for that purpose.

The decoder is not implemented in the nicest way; it fully reads in the
LexerTokens first, and then processes. This made trying to wrap my head
around the problem a lot easier because it left fewer failure cases, but
it's not the most efficient thing to do.

Now that v0 is done it's pretty plain to see that the decoder could work
by only reading in the next N tokens that it needs at a time. But that
will be left for a future version.
2021-12-27 15:45:18 -07:00
Brian Picciano
82e74cb55f Improvements to gg.Graph
An empty `Value` is now valid.

It is now possibly to change the edgeVal of an OpenEdge. It feels like
this shouldn't be necessary, but it greatly simplifies the decoding
logic to have this.

A tuple which is created with just one input edge, and with no edge
value of its own, is now automatically simplified to just that input
edge.
2021-12-27 14:22:56 -07:00
Brian Picciano
e2ffc37ddc Don't treat newlines specially
For MVP newlines aren't going to be used as a syntax terminator, they're
just going to be whitespace. Otherwise the decoding logic gets way more
complicated.
2021-12-27 14:22:56 -07:00
Brian Picciano
1e30ad6959 Strip out most of the functionality of gg.Graph
`gg.Graph` has been reworked in its internal functionality, to more
closely match the capability of a purely stack-based implementation. The
current implementation is _very_ inefficient, however. Tests have been
deliberately left pretty sparse, as I expect the internals to continue
to change significantly.
2021-12-27 10:11:07 -07:00
Brian Picciano
e4bdeb8797 Implement lexer for new syntax 2021-12-26 14:49:43 -07:00
Brian Picciano
b1831a670f End comments with periods 2021-12-26 14:49:22 -07:00
Brian Picciano
066d5a8319 make into a module 2021-08-26 21:27:47 -06:00
Brian Picciano
f530cb481a rename Junction to Tuple, update syntax, rename Null to ZeroGraph 2021-08-26 21:26:24 -06:00
Brian Picciano
3f28c60ab8 Remove a bunch of old code, update the README 2021-08-26 21:25:39 -06:00
Brian Picciano
fed2c35868 back from the dead, some syntax thoughts 2020-10-05 21:17:12 -06:00
Brian Picciano
ad1e99585b graph: refactor Graph into being an interface 2018-10-04 17:33:19 -04:00
Brian Picciano
16f2b1bbde graph: make Edge into an interface 2018-10-04 15:24:17 -04:00
Brian Picciano
a5b3b7acd0 graph: fix TestVisitBreadth test to ensure edge is to a brand new value during a newRank action 2018-10-04 15:02:12 -04:00
Brian Picciano
0fe15409a8 graph: implement VisitBreadth/VisitDepth 2018-09-25 17:26:11 -04:00
Brian Picciano
b51935fcd1 graph: implement Join/Disjoin 2018-09-25 13:58:50 -04:00
Brian Picciano
20b2a80a3c graph: refactor to use Node type 2018-08-21 14:46:17 -04:00
Brian Picciano
9534ff5c13 graph: don't give values to edges, that can be accomplished by a transformation layer later 2018-08-18 14:06:43 -04:00
Brian Picciano
c1bdb46623 graph: implement SubGraph and Equal 2018-08-18 13:51:38 -04:00
Brian Picciano
91c0629377 graph: add edgeIndex's to Graph to speed up EdgeValues call 2018-08-17 11:08:26 -06:00
Brian Picciano
132a50039b graph: implemented smaller and simpler version of gg, which gg can then be built on top of 2018-08-14 16:28:11 -04:00
Brian Picciano
c277bab368 gim: move view code into its own package 2018-06-08 02:04:27 +00:00
Brian Picciano
0a6526d2c3 gim: add terminal.Buffer.DrawBufferCentered 2018-06-08 00:17:49 +00:00
Brian Picciano
0b36e4ec37 gim: make rounder a global in geo, kinda gross but simplifies a lot of things 2018-06-07 22:50:01 +00:00
Brian Picciano
ef48a2d708 gim: move line drawing code into terminal. drawing the line body is kind of busted, but whatever 2018-06-07 22:35:18 +00:00
Brian Picciano
a6d540f1fb gim: refactor positioning and drawing code to take advantage of terminal buffers more 2018-06-07 03:25:40 +00:00
Brian Picciano
b906697151 gg: rename Walk to Iter, and implement Disjoin 2018-06-07 02:21:44 +00:00
Brian Picciano
efa7319555 gim: give terminal.LineStyle Perp and Arrow fields 2018-06-06 06:30:39 +00:00
Brian Picciano
97be10b03e gim: modify terminal to use a buffer, which will allow for much more complex behavior later 2018-06-05 07:56:50 +00:00
Brian Picciano
018e84575f more notes for gim 2018-06-03 04:25:32 +00:00