How to create a Literal for something that isn't defined yet in your language?

I have a language "mylanguage" with a concept called "Class".

I have a solution along side that language which has a module for that language called [mylanguage].core. In that module I define a Class called "Sequence".

I have a SequenceLiteral defined in mylanguage.

The problem is when it comes time to define the typesystem inference aspect for SequenceLiteral I need to reference the definition of Sequence which isn't accessible from the Language.

Should I not be defining these core Classes in a module separate from the language?

Is there a way to do a circular reference and have the language depend on the core module (I tried and wasn't successful)?

Other?
12 comments
Comment actions Permalink
Why don´t you define sequenceliteral in the language you define sequence. Wouldn t it be logical correct to place it there?
0
Comment actions Permalink
I'm defining Sequence in a Solution, not a Language... It seems like all the BaseLanguage things have their concepts in a Language, and then the instances of those concepts in a Solution separate from the Language.
0
Comment actions Permalink
mh, i see. well then you will need some dynamic type for you sequences .. like "ClassifierType" for Classifier, e.g. ClassConcept.

If you will have a look at ClassifierType, you ll see that it has a reference to a Classifier, which is used in the typesystem to determine the concrete type.
0
Comment actions Permalink
I think you should consider putting is in your language if it is considered stable. You don't need to change it for different models/solutions.

When it is a variable part which you need to change for each project, then it should be in the solution.
0
Comment actions Permalink
There's no instance of Classifier that has a literal though, so I'm not sure it's a great example.

I don't mind at all putting it in my language. I have a few instances of Language concepts that should probably go in the Language. I'm mainly not sure where it should go in the organization of the thing. I finally realized I can put instances of my language elements in any of the aspects, but I'm not really sure where they should go? maybe under runtime?
0
Comment actions Permalink
Any suggestions on where to put these sorts of things w/in a Language? Should I just throw them under structure or something?
0
Comment actions Permalink
Hmm, when i have the case that i need like instance of a concept (like a constant)
I would create a new concept that extends the existing one and use the constructor(or nodefactory) to set all the values. Dont know if this could be a solution to you.
0
Comment actions Permalink
I'm not sure I follow you here, which is the existing one?
0
Comment actions Permalink
Sorry for my unclear text. It's quite late here (1 am)

I would create a new concept extending e.g. ClassConcept. Then you can describe your concept using the constructor (this.name = "...") and override the editor.

But actually I'm not really sure what you want to do and if this is the best solution.

If it is just Java. You could also write your java-classes externally and make the jar file available to your language and model.
0
Comment actions Permalink
My language doesn't fit in very well w/ baseLanguage so I'm not extending it, and I'm not sure it'd be necessary/a good idea for what I'm trying to do...

I just want to make a special literal for a specific instance of one of my concepts (an instance of Class called Sequence) that I know will be in the "core library" for my language. It's important to me that other than having a special literal it's treated just like any other Class. The only problem I have is that in the type inference rule for the literal I need to be able to reference the specific instance of my concept in order to say that's the type. I was following the convention that seems to be set elsewhere and providing my core library in a Solution that depends on my language, but then I can't reference things in my core library from w/in my language.

I think I just need to not put my core library in a separate solution and include it in my Language, but I'm just not sure the best spot to put it w/in the language?
0
Comment actions Permalink
Ok. I see.

So I was confused because you said Class and I was then thinking about BaseLang.

So this are the opportunity I see:
  • Create a concept Sequence extending Class (instead of an instance) and put it in your language and fill all the Sequence using the behaviour-constructor.
  • Create an instance Sequence in an extra Solution. (You can find the instance by using a lookup. e.g. model.nodesIncludingImported(GlobalScope.getInstance)<Class>.where(it-> it.name = "Sequence").
  • Create the +instance inside your language+. I don't know if this is possible and working good. Probably put it into structure.
0
Comment actions Permalink
Ahh, I see the confusion. In truth the concept is actually called "Concept", but I thought that would be too confusing so I went w/ "Class" for the purposes of this discussion (and will continue to do so) :p.

1. This seems like lying, and I imagine it would add special cases to everywhere that wants to deal with instances of Classes.

2. huh, interesting idea, hadn't thought of it, seems pretty ugly though...

3. Yeah this is what I was thinking of trying and wasn't sure where it should go (stubs? runtime? structure?) I'll just try throwing it in structure and see what happens.

Thanks!
0

Please sign in to leave a comment.