|
|
|
|
|
Re: xText Grammer Scoping for SQL SELECT statement [message #552332 is a reply to message #552321] |
Wed, 11 August 2010 18:31 |
|
Hello Dennis,
without having a complete grammar giving more advice than to hint to the docs is hard to give.
Maybe this sentence How would I implement scoping for the table Customer was a bit misunderstanding since you define scoping for metaclasses which indicates that customer is a metaclass but i think its an instance of the metaclass TableDefinition.
Never the less having a simple grammar like this one
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
elements+=Element*
mappings+=Mapping*
;
Element:
"element" name=ID "{"
attributes+=Attribute*
"}"
;
Attribute:
"attr" name=ID
;
Mapping:
"mapping" from=MappingPart "->" to=MappingPart
;
MappingPart:
element=[Element] "." attribute=[Attribute]
;
and a very very small ScopeProvider like this
public class MyDslScopeProvider extends AbstractDeclarativeScopeProvider {
public IScope scope_MappingPart_attribute(MappingPart mappingPart, EReference ref) {
return Scopes.scopeFor(mappingPart.getElement().getAttributes());
}
}
scoping works for a sample model like this
element A {
attr a1
attr a2
}
element B {
attr b1
attr b2
}
mapping A.a1 -> B.b2
Regards
Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Wed, 11 August 2010 18:35] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Re: xText Grammer Scoping for SQL SELECT statement [message #552601 is a reply to message #552598] |
Thu, 12 August 2010 18:30 |
|
Hi,
right, i missed to tell that you have to use SimpleNameProvider in this case
public class MyDslRuntimeModule extends org.xtext.example.mydsl.AbstractMyDslRuntimeModule {
@Override
public Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
return SimpleNameProvider.class;
}
}
or you change the grammar like this and don't have to implement any scoping at all.
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
elements+=Element*
mappings+=Mapping*
;
Element:
"element" name=ID "{"
attributes+=Attribute*
"}"
;
Attribute:
"attr" name=ID
;
Mapping:
"mapping" from=MappingPart "->" to=MappingPart
;
MappingPart:
attribute=[Attribute|FQN]
;
FQN: ID ("." ID)*;
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05518 seconds