Commit Graph

29 Commits

Author SHA1 Message Date
e113e96f1f WIP 2023-10-21 17:42:31 +02: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
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
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
f530cb481a rename Junction to Tuple, update syntax, rename Null to ZeroGraph 2021-08-26 21:26:24 -06:00
Brian Picciano
b906697151 gg: rename Walk to Iter, and implement Disjoin 2018-06-07 02:21:44 +00:00
Brian Picciano
c16fc00bf7 notes for gim on graph drawing algo, and some TODOs 2018-06-02 08:45:03 +00:00
Brian Picciano
65933a004d gim: properly sort outgoing edges along the from box 2018-06-02 06:52:42 +00:00
Brian Picciano
905b182467 gim: make incoming edges separate along the drawn rectangle edge, instead of all overlapping onto the same point 2018-06-02 06:51:53 +00:00
Brian Picciano
bd650dfc08 implement json marshaling and unmarshaling (TODO needs tests) 2018-01-23 13:32:22 +00:00
Brian Picciano
e52befb7ed refacctor gg to use Value instead of Identifier, which will make serializing more straightforward, and reduces some complexity of the code besides 2018-01-21 15:39:25 +00:00
Brian Picciano
754b75407a integrate constraint engine into determining box positioning 2017-12-03 12:38:53 -07:00
Brian Picciano
79a171323d implement basic constraint engine in gim, which will be used to determine positioning of vertices 2017-11-25 14:33:00 -07:00
Brian Picciano
286c2fbb35 use gg.Str instead of gim.str 2017-11-24 11:05:58 -07:00
Brian Picciano
5ab1d4c7f0 implement gg.Graph.Walk 2017-11-05 09:57:57 -07:00
Brian Picciano
cae3116424 rename gg.HalfEdge to gg.OpenEdge 2017-11-05 09:11:05 -07:00
Brian Picciano
d700390b54 move gg into root, it's not really subject to the lang 2017-11-02 14:59:31 -06:00