Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler redesign #74

Merged
merged 13 commits into from
Nov 25, 2022
Merged

Compiler redesign #74

merged 13 commits into from
Nov 25, 2022

Conversation

timothee-haudebourg
Copy link
Collaborator

@timothee-haudebourg timothee-haudebourg commented Nov 16, 2022

This PR aims at redesigning the compiler model to overcome its current limitations.

Current limitations

  • Declaring multiple values on a functional properties will raise an error, even if the values are logically the same;
  • Because of the above, it is impossible to write a unification stage that merges equivalent (blank) nodes, leading to a lot of spurious errors with union/intersection types/layouts (False type mismatch error using union types #73).
  • Some declarations are dependent on other declarations that must have been given to the compiler before, otherwise it will raise an error. For instance, the class of a resource must be declared before a property of this class can be declared on the resource.
  • Different facets of the same resource (for instance if the resource is both a type and a layout) are completely separated in the final compiled model. This means that properties shared between the traits are copied. This also adds some annoying queries to the model during code generation.
  • Because of the above, keeping track of the class hierarchy is also nearly impossible.
  • The model is weirdly different from OWL, which makes conversion from/to RDF slightly inaccurate.
  • Because of the above, it is (again) impossible to write a unification stage that merges equivalent (blank) nodes, leading to a lot of spurious errors with union/intersection types/layouts.

Goal

  • Relax the constraints on the intermediate model (e.g. declaring multiple values on a functional property will not immediately raise an error).
  • Get closer to OWL. This will allow us to very simply write a conversion from/to RDF. This is essential to define the unification stage.
  • Do not separate traits in the final compiled model. This actually simplifies the compilation a lot and give more freedom to the code generators. This also lays the ground for a full implementation of class hierarchy.

Related issues

This should fix or greatly simplify the following issues:

Todo

  • [core] Merge RDF traits in the Node type.
  • [core] Get closer to OWL.
  • [build] Relax all the constraints.
  • [build] Remove now unnecessary allocation stage.
  • [build] Move the intersection algo away from the parser.
  • [build] Define an iterator over the properties of a node, and define the RDF export feature from it.
  • [build] Define the (early) unification stage using the RDF export feature.
  • [syntax] Update the parser.
  • [modules] Update the code generators.
  • Test.

@timothee-haudebourg timothee-haudebourg self-assigned this Nov 16, 2022
Timothée Haudebourg and others added 11 commits November 17, 2022 17:47
Now I need to rewrite the build precedure.
Layout intersection is missing, along with unification.
The enum layout intersection is still missing,
then we can add the intersection compute stage in the build procedure.
Adds enum-enum layout intersection.
Adds a first stage in the compiler computing layouts intersections.
This is not yet connected to the rest of the intersection procedure
though.
This is the first step to the unification algo impl.
Yet to be tested.
- Simplify composite layouts.
- Remove unused nodes.
@timothee-haudebourg timothee-haudebourg marked this pull request as ready for review November 25, 2022 10:52
@timothee-haudebourg timothee-haudebourg merged commit 8c1c5a4 into main Nov 25, 2022
@timothee-haudebourg timothee-haudebourg deleted the compiler-redesing branch November 25, 2022 11:23
timothee-haudebourg added a commit to spruceid/spec.rebase.xyz that referenced this pull request Dec 5, 2022
Some layout definitions are useless now that
spruceid/treeldr/pull/74 has been merged.
Remove them.
This was referenced Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant