-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
Update CTO grammar for Import Aliasing #853
Comments
I have prepared a rough design of grammar if we are going to follow the syntax in issue, also considering the metamodel changes, i.e. a separate concept for The grammar is close to the existing grammar for the AliasedIdentifier = name:$Identifier _ ('as' _ aliasedName:$Identifier _)?
{
const result = {
name,
aliasedName
};
return result;
}
commaSeparatedAliasedIdentifiers = head:$AliasedIdentifier _ tail:(',' _ @$AliasedIdentifier _ )*
{
return [head, ...tail];
}
ImportAliasTypes
= ImportToken __ ns:QualifiedNamespaceDeclaration ".{" _ types:commaSeparatedAliasedIdentifiers _ "}" __ u:FromUri? {
const result = {
$class: "concerto.metamodel@1.0.0.ImportAliasTypes",
namespace: ns,
types,
};
u && (result.uri = u);
return result;
} After parsing using the above, we will get a list of objects (object of type aliased imports) that contain the optional field This could be one approach to the grammar design. |
We have dropped the concept for the AliasedTypes in the metamodel and integrated it as an optional array in the ImportTypes concept. Thus, we have dropped the grammar rules for the ImportAliasTypes and parsed aliased types in the ImportTypes under the new field So, we now have the following structure. imports:[
{
'$class': 'concerto.metamodel@1.0.0.ImportTypes',
namespace: '',
types: [],
aliasedTypes: []
}
] In Technology-wt, @mttrbrts discussed the backward compatibility of the ast-generated; when we split the types based on which are aliased and which are not, we are changing the definition of the old array So the suggestion is to keep all the types (aliased or not) in the |
Specification
Imported terms can ONLY be aliased using curly braces, i.e. multiple import syntax
Correct
Import with version
Import with version with pre-release identifier
Import with version with pre-release identifier from an external source
Import without version (strict: false)
Incorrect
Aliased imports can be mixed with non-aliased imports
as
can be used as an identifierAST changes are backwards compatible
types
list will still have the list of names that are being imported, even though it's aliased (tentative, depending on not-doing this is breaking change or not)will produce
aliasedTypes
will not be present.will produce
Cannot alias to primitive types
Incorrect
Cannot alias to keywords (for Concerto v4)
Incorrect
The text was updated successfully, but these errors were encountered: