Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Problems with keywords and JvmType
Problems with keywords and JvmType [message #1015152] Wed, 27 February 2013 15:29 Go to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
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 #1015202 is a reply to message #1015152] Wed, 27 February 2013 17:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hi,

if i use ref=JvmParameterizedTypeReference escaping works fine for me.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problems with keywords and JvmType [message #1015302 is a reply to message #1015152] Thu, 28 February 2013 07:05 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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.

Regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 27.02.13 16:29, schrieb Aaron Digulla:
> 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 #1015373 is a reply to message #1015302] Thu, 28 February 2013 11:46 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
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
Re: Problems with keywords and JvmType [message #1015388 is a reply to message #1015202] Thu, 28 February 2013 13:12 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Christian Dietrich wrote on Wed, 27 February 2013 18:47
hi,

if i use ref=JvmParameterizedTypeReference escaping works fine for me.


:-/ Doesn't work for me. I'm using the code in the grammar:

    "validator" name=ID ":" clsName=[ jvmTypes::JvmParameterizedTypeReference | QualifiedName ] ";";

QualifiedName:
	ID ("." ID)*;


Which version of Xtext?
Re: Problems with keywords and JvmType [message #1015414 is a reply to message #1015388] Thu, 28 February 2013 14:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
I tested it with 231 (using xbase as super grammar)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problems with keywords and JvmType [message #1015422 is a reply to message #1015414] Thu, 28 February 2013 14:33 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Christian Dietrich wrote on Thu, 28 February 2013 15:07
I tested it with 231 (using xbase as super grammar)


I'm using 2.3.0 and this header:

grammar com.pany.workflow.dsl.WfDsl
	with org.eclipse.xtext.xbase.Xtype
	hidden(WS, SL_COMMENT) 

import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes
import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase


Maybe it's a bug that was fixed in 2.3.1 :-/
Re: Problems with keywords and JvmType [message #1015479 is a reply to message #1015422] Thu, 28 February 2013 16:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Still the question why don't you use the stuff from the super grammar
(at least the qualified name rule)

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Problems with keywords and JvmType [message #1015557 is a reply to message #1015373] Fri, 01 March 2013 08:59 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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
Previous Topic:AFter F3 Open Declaration How does one go back to the previous location
Next Topic:Xtext Grammar
Goto Forum:
  


Current Time: Tue Apr 16 13:56:10 GMT 2024

Powered by FUDForum. Page generated in 0.48586 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top