- 24 Jan, 2021 3 commits
-
-
Eric Myhre authored
schema: so much boilerplate for feeding information to the Compiler that I wrote another supplementary code generator. (I'm getting very weary of golang.) This new bit of codegen makes the compiler.go file fairly readable again, though, so I'm satisfied with it. The Compiler API is now complete enough that I can start repairing other things to use it properly. The schemadmt.Schema.Compile() function and all of its helpers compile again now. So does *most* of the whole codegen system... with the notable exception of all the hardcoded typesystem spawning which used the old placeholder methods which have now been stricken. TypeSystem now maintains order. This allowed me to remove some sort operations from the code generator. This also means the next time any existing codegen is re-run, the output file will shift significantly. However, it shouldn't do so again in the future.
-
Eric Myhre authored
As with parent commit: this is a checkpoint. CI will not be passing.
-
Eric Myhre authored
This commit does not pass CI or even fully compile, and while I usually try to avoid those, A) I need a checkpoint!, and B) I think this one is interestingly illustrative, and I'll probably want to refer to this diff and the one that will follow it in the future as part of architecture design records (or even possibly experience reports about golang syntax). In this commit: we have three packages: - schema: full of interfaces (and only interfaces) - schema/compiler: creates values matching schema interfaces - schema/dmt: contains codegen'd types that parse schema documents. The dmt package feeds data to the compiler package, and the compiler package emits values matching the schema interface. This all works very nicely and avoids import cycles. (Avoiding import cycles has been nontrivial, here, unfortunately. The schema/schema2 package (which is still present in this commit, but will be removed shortly -- I've scraped most of it over into this new 'compiler' package already, just not a bunch of the validation rules stuff, yet) was a dream of making this all work by just having thin wrapper types around the dmt types. This didn't fly... because codegen'd nodes comply with `schema.TypedNode`, and complying with `schema.TypedNode` means they have a function which references `schema.Type`... and that means we really must depend on that interface and the package it's in. Ooof.) The big downer with this state, and why things are currently non-compiling at this checkpoint I've made here, is that we have to replicate a *lot* of methods into single-use interfaces in the schema package for this to work. This belies the meaning of "interface". The reason we'd do this -- the reason to split 'compiler' into its own package -- is most because I wanted to keep all the constructor mechanisms for schema values out of the direct path of the user's eye, because most users shouldn't be using the compiler directly at all. But... I'm shifting to thinking this attempt to segregate the compiler details isn't worth it. A whole separate package costs too much. Most concretely, it would make it impossible to make the `schema.Type` interface "closed" (e.g. by having an unexported method), and I think at that point we would be straying quite far from desired semantics.
-
- 25 Jun, 2019 1 commit
-
-
Eric Myhre authored
- `typed.Node` -> now lives in the `impl/typed` package, more like other nodes. - Most of the other essential parts of reasoning about types moved to `schema` package. ("typed.Type" seemed like a nasty stutter.) - `typed.Universe` renamed to `schema.TypeSystem`. - Current `Validate` method moved to `schema` package, but see new comments about potential future homes of that code, and its aspirational relationship to `typed.Node`. Conspicuously *not* yet refactored or moved in this comment: - The `typed/declaration` package -- though it will shortly be scrapped and later reappear as `schema/ast`. The dream is that it would be neatest of all if we could generate it by codegen; but we'll see. (This would seem to imply we'll have to make sufficient exported methods for creating the `schema.Type` values... while we also want to make those immutable. We'll... see.) - The `typed/gen` package is also untouched in this commit, but should similarly move shortly. The codegen really ought to be built against the `schema.Type` reified interfaces. Overall, this drops the sheer nesting depths of packages a fair bit, which seems likely to be a good smell.
-
- 15 Jan, 2019 2 commits
-
-
Eric Myhre authored
All of these struct definitions are horrifying similar in construction to the same-named definitions in the typesystem package: simply ever instance of a Type pointer is instead a TypeName string. Despite being unattractive, this is correct: since typesystem can have pointers and cycles, and typedeclaration can't, this is what we end up with. Signed-off-by: Eric Myhre <hash@exultant.us>
-
Eric Myhre authored
See previous commit for more discussion of the child packages to come, or the schema.md file in the docs dir, which describes similar. Several large todos in comments. Quite importantly: typed.Node is now an **interface**, not a concrete struct itself. The godoc comment should explain this nicely; long story short, this is going to be relevant when we get to codegen and other advanced form of native integration. Signed-off-by: Eric Myhre <hash@exultant.us>
-