Cannot be resolved [message #1763493] |
Tue, 16 May 2017 17:11 |
Ruchika Kumar Messages: 50 Registered: January 2017 |
Member |
|
|
I have written below grammar. In my example model, I want to refer to join J3 after startPoint1 but it always gives me "cannot be resolved" error.
Grammar below:
grammar org.xtext.project.turn.Turn with org.eclipse.xtext.xbase.Xbase
generate turn "http://www.xtext.org/project/turn/Turn"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
URNspec:
'URNModel' name=QualifiedName
(ucmspec=UCMspec)?;
URNmodelElement: Dependency | UCMmap | Responsibility;
IntentionalElement:
type=IntentionalElementType name=QualifiedName '{'
longName=STRING
('importance' (importance=ImportanceType | importanceQuantitative=QUALITATIVEVALUE))?
'}';
Dependency: 'dependsOn' dest=[IntentionalElement | QualifiedName] ('{'
'}')?;
enum IntentionalElementType: Softgoal | Goal | Task | Resource | Belief | Indicator;
enum ImportanceType: High | Medium | Low | None;
QUALITATIVEVALUE returns ecore::EInt: ('-'|'+')? INT;
UCMspec:{UCMspec} 'UCM''{'
ucmMaps+=UCMmap*
'}';
UCMmap: 'map' name=QualifiedName '{'
paths+=Path*
'}';
Path: 'start' name = QualifiedName
pathBody = PathBody;
PathBody: PathWithRegularEnd | PathWithReferencedEnd;
PathWithRegularEnd:{PathWithRegularEnd}
('->'pathNodes+=PathNode)* '->'
pathEnd=RegularEnd ;
PathWithReferencedEnd:{PathWithReferencedEnd}
('->'pathNodes+=PathNode )* '->'
referencedEnd=[ReferencedEnd | QualifiedName] ;
RegularEnd: EndPoint ;
EndPoint:
'end' name = QualifiedName ';';
PathNode: Responsibility | OrJoin ;
ReferencedEnd: OrJoin ;
Responsibility: 'X' name = QualifiedName ;
OrJoin: 'join' name = QualifiedName;
..................................................................................................................................................
Simple example model :
URNModel Example
UCM{
map TL {
start startPoint1 -> J3
start startPoint3 -> X check -> join J3 -> end fail;
}
}
I don't understand why it does not recognize J3.
[Updated on: Tue, 16 May 2017 17:22] Report message to a moderator
|
|
|
Re: Cannot be resolved [message #1763497 is a reply to message #1763493] |
Tue, 16 May 2017 17:47 |
|
Because `J3`is a child of `startPoint3`, the qualified name used in scoping is `startPoint3.J3`.
If you want to make your example work, you need to either change the structure of the created AST (so that `join J3`is not a child of an element with a name), or you implement the `IQualifiedNameProvider`to return the simple name.
hth,
Sven
|
|
|
Re: Cannot be resolved [message #1763498 is a reply to message #1763493] |
Tue, 16 May 2017 17:48 |
|
Hi,
where is J3 defined? is it the one defined in point3? if yes you need to adapt the naming behaviour
MyQNP.xtend (new)
import com.google.inject.Inject
import org.eclipse.xtext.naming.DefaultDeclarativeQualifiedNameProvider
import org.eclipse.xtext.naming.IQualifiedNameConverter
import org.eclipse.xtext.naming.QualifiedName
import org.xtext.example.mydsl1.myDsl.OrJoin
class MyQNP extends DefaultDeclarativeQualifiedNameProvider {
@Inject IQualifiedNameConverter qnc
def QualifiedName qualifiedName(OrJoin join) {
return qnc.toQualifiedName(join.name)
}
}
MyDslRuntimeModule.xtend (existing)
class MyDslRuntimeModule extends AbstractMyDslRuntimeModule {
override bindIQualifiedNameProvider() {
MyQNP
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Cannot be resolved [message #1763589 is a reply to message #1763588] |
Wed, 17 May 2017 16:47 |
|
start startPoint -> .trigger getPIN is verboten in the grammar you posted
maybe you have a different grammar now.
but if you want to reference a reference you need something like
def QualifiedName qualifiedName(TimerInPath t) {
val name = NodeModelUtils.findNodesForFeature(t, MyDslPackage.Literals.TIMER_IN_PATH__REF_TIMER_END).head.text.trim
System.err.println(name)
return qnc.toQualifiedName(name)
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05293 seconds