Skip to content

LanguageFactory: declaration order, concept relations, elements of other languages - #15

Merged
ftomassetti merged 2 commits into
mainfrom
feature/language-factory-improvements
Sep 26, 2026
Merged

ftomassetti merged 2 commits into
mainfrom
feature/language-factory-improvements

Conversation

@ftomassetti

@ftomassetti ftomassetti commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

LanguageFactory makes language definitions much shorter, but it couldn't express several things real languages need. This PR fills those gaps, driven by porting the starlasu-specs languages to the factory.

Changes

Declaration order. build() used to create all primitive types, then all enumerations, then all classifiers. Now the elements of the language are created in the order they are declared. Within a classifier, properties, references and containments are each created in declaration order.

Concept and annotation relations.

  • concept(...) accepts extends, implements, abstract and partition.
  • annotation(...) accepts extends and implements.
  • set_extends on a concept factory used to be silently ignored; it now works. tests/generation/test_language_generation.py was expecting the output of that bug, so its expected code now includes my_other_concept.set_extended_concept(my_concept).

Elements of other languages. Types (of properties, references, containments), extended/implemented classifiers and annotates used to be looked up by name in the language being built. So containment("issues", other_language.get_concept_by_name("Issue")) or containment("ast", LionCoreBuiltins.get_node()) failed. Now factories are resolved through a map from factory to built element, and elements that are already built are used as they are. A factory belonging to a different LanguageFactory raises a ValueError explaining to pass the built element instead.

Dependencies. LanguageFactory(..., dependencies=[...]) adds them to the built language.

Internals. ClassifierFactory.populate() receives the map of built elements. Nothing outside definition.py calls it.

ftomassetti and others added 2 commits September 26, 2026 21:13
- Build elements, and the features of each classifier, in declaration
  order instead of grouping them by kind.
- Concepts accept extends, implements, abstract and partition (extends
  on a concept factory used to be ignored); annotations accept extends
  and implements.
- Types, extended and implemented classifiers can be elements of other
  languages: factories are resolved to the elements built from them
  instead of being looked up by name in the language being built.
- LanguageFactory accepts the dependencies of the language.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only the order within each kind of feature matters, not the order
across kinds: go back to one list per kind, each kept in declaration
order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ftomassetti
ftomassetti merged commit 01bb654 into main Sep 26, 2026
5 checks passed
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