Problems with keywords and JvmType [message #1015152] |
Wed, 27 February 2013 10:29  |
Eclipse User |
|
|
|
I have a workflow DSL and I wanted to add validation to it. Here is an example of the code:
workflow FOO {
validation alwaysValid : com.pany.project.workflow.AlwaysValidComparator;
}
For this input, I get the error:
ERROR:mismatched input 'workflow' expecting RULE_ID (test.wf line : 3)
This is because of the package "workflow" which Xtext/ANTLR think is the keyword "workflow".
So I tried to escape the symbol:
workflow FOO {
validation alwaysValid : com.pany.project.^workflow.AlwaysValidComparator;
}
which gives me:
ERROR:Couldn't resolve reference to JvmType 'com.pany.project.^workflow.AlwaysValidValidator'. (test.wf line : 3)
Suggestions?
|
|
|
|
|
|
|
|
|
|
Re: Problems with keywords and JvmType [message #1015557 is a reply to message #1015373] |
Fri, 01 March 2013 03:59  |
Eclipse User |
|
|
|
Am 28.02.13 12:46, schrieb Aaron Digulla:
> Sebastian Zarnekow wrote on Thu, 28 February 2013 08:05
>> Hi Aaron,
>>
>> you have to register a value converter for your FQN rule or add
>> 'workflow' as a contextual keyword for IDs, if that does not cause any
>> other trouble.
>
>
> I hear you but I don't understand the details.
>
> Is the "FQN converter" somehow related to IQualifiedNameProvider? If so,
> would it be enough to just strip the `^` characters for this type of
> EObject?
>
> As for "contextual keyword for IDs", i couldn't Google anything. I
> understand the concept of contextual keywords in parsers but how do I
> implement this in Xtext. Do you have an example?
>
> Regards,
>
> A. Digulla
Hi Aaron,
the docs describe the aspect value conversion and scoping.
http://www.eclipse.org/Xtext/documentation.html#valueconverter
http://www.eclipse.org/Xtext/documentation.html#scoping
Value converters are responsible for transforming a parsed text snippet
into a usable information in your model, e.g. modelInstance.getName()
should not include the ^ character thus a value converter has to strip
that off. The IQualifiedNameProvider yields the name that is used to
globally identify an instance, e.g. it may concatenate the name of
containers with the name of the model instance itself: the qualified
name of a Java class is the name of the package concatenated with the
name of all outer classes and finally the simple name of the class itself.
This post may help on the keyword/id issue:
http://www.eclipse.org/forums/index.php/mv/tree/200409/
I hope this helps,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
|
|
|
Powered by
FUDForum. Page generated in 0.29284 seconds