Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » importURI strange problems(importURI, quotes)
icon9.gif  importURI strange problems [message #876435] Thu, 24 May 2012 15:35 Go to next message
Vil Lpz is currently offline Vil LpzFriend
Messages: 24
Registered: April 2012
Junior Member
Hey.

I have long time with this and not understand the error ...

This works:

Grammar:
grammar pruebas.MyDsl 



ScxmlStateType  hidden(WS):

	'<state'
	
		( 'id=' name = ID
		& ('src=' importURI = LocalUrl)?
		& ('initial=' initial1 = [ScxmlStateType | ID])? ) //state
		
	scxmlStateMix = ScxmlStateMix	
;	 

ScxmlStateMix:
	('/>') |
	('>'	
	
		( state += ScxmlStateType* 
		& transition += ScxmlTransitionType* )

		
	'</state>')	
;

ScxmlTransitionType:
	{ScxmlTransitionType}
	'<transition'
	
		 ('target=' target = [ScxmlStateType | ID])? // state
	'/>'
					
;


LocalUrl:
	('../')? ID (('/' | '../') ID )* ('.' ID)?
;

LocalUrlDataType:
 	QUOTE_V1 LocalUrl QUOTE_V1
 	//| QUOTE_V2 LocalUrl QUOTE_V2	
;

terminal QUOTE_V1:
	'"'
;

terminal QUOTE_V2:
	'\''
;


terminal ID: 
	('a'..'z'|'A'..'Z'|'_'|'-') ('a'..'z'|'A'..'Z'|'_'|'-'|'0'..'9')*
;

terminal WS: 
	(' '|'\t'|'\r'|'\n')+
;



I can reference states in another files which indicated by state src attribute...

x.test
<state id=x1 [b]src=y.test[/b]>  

	<state id=x2>
		<transition target=y2 />   
	</state>  
  
</state>  


y.test
<state	id=y1>   
 
	<state id=y2>
		<transition target=y1 />
	</state> 
	   	    
</state>   


But if instead of
'src=' importURI = LocalUrl

Put's
'src=' importURI = LocalUrlDataType

That is, the same thing with quotes. It does not work. And I do not understand why.

Someone can help me?

Thank you.

A greeting.

[Updated on: Thu, 24 May 2012 15:36]

Report message to a moderator

Re: importURI strange problems [message #876490 is a reply to message #876435] Thu, 24 May 2012 17:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13667
Registered: July 2009
Senior Member
Hi did you provide a value converter rule for the quoted URL as Xtext
does for strings?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: importURI strange problems [message #876829 is a reply to message #876490] Fri, 25 May 2012 10:52 Go to previous message
Vil Lpz is currently offline Vil LpzFriend
Messages: 24
Registered: April 2012
Junior Member
THANKS!

I have a few time with XText and I donĀ“t known I had to do this ...

This is my solution, for if it could be useful to someone in the future. I was inspired by solution provided by pettergraff blog.

MyDslRuntimeModule
public class MyDslRuntimeModule extends pruebas.AbstractMyDslRuntimeModule {

    @Override
    public Class<? extends IValueConverterService> bindIValueConverterService() {
        return LocalUrlDataTypeValueConverter.class;
    }	
	
}


LocalUrlDataTypeValueConverter
public class LocalUrlDataTypeValueConverter extends DefaultTerminalConverters {
	
    @ValueConverter(rule = "LocalUrlDataType")
    public IValueConverter<String> LocalUrlDataType() {
    	
        return new IValueConverter<String>() {
        	
        	@Override
            public String toValue(String string, INode node) {
        		if (string == null)
        			return null;
        		try {
        			return Strings.convertFromJavaString(string.substring(1, string.length() - 1), true);
        		} catch (IllegalArgumentException e) {
        			throw new ValueConverterException(e.getMessage(), node, e);
        		}
            }

            public String toString(String value) {
                return value;
            }
            
        };
        
    }
    
}


Thank you very much.

a greeting
Previous Topic:Type Checking with JvmTypeParameter and JvmArgumentTypeReference
Next Topic:[Xtend 2.3 M6] Function1 cannot be used as parameter
Goto Forum:
  


Current Time: Thu Dec 03 08:44:22 GMT 2020

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

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

Back to the top