Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Typesystem for own DSL
Typesystem for own DSL [message #1283279] Thu, 03 April 2014 04:31 Go to next message
Eclipse UserFriend
Hello everyone,

I am looking for a comfortable way to implement or integrate a typesystem for my DSL. After some research I found the following page:

http://code.google.com/a/eclipselabs.org/p/xtext-typesystem/

But I'm not really sure if it is possible to integrate this framework in my DSL without changing the whole grammer. My metamodel is about 80 metaclasses big and the grammer contains ~500 lines of code.

Maybe someone has any experiences with this framework and can give me a hint how to begin.

Regards,

Alex

[Updated on: Thu, 03 April 2014 05:16] by Moderator

Re: Typesystem for own DSL [message #1283314 is a reply to message #1283279] Thu, 03 April 2014 05:23 Go to previous messageGo to next message
Eclipse UserFriend
Hi Alexander,

Maybe should also have a look at http://xsemantics.sourceforge.net/
because it's actively maintained (instead of the other one).

Best regards,
Joerg
Re: Typesystem for own DSL [message #1283335 is a reply to message #1283314] Thu, 03 April 2014 05:52 Go to previous messageGo to next message
Eclipse UserFriend
Thank you!
I will have a closer look at this framework.

~Alex
Re: Typesystem for own DSL [message #1284294 is a reply to message #1283335] Fri, 04 April 2014 06:01 Go to previous messageGo to next message
Eclipse UserFriend
On 03/04/2014 11:52, Alexander R wrote:
> Thank you!
> I will have a closer look at this framework.
>
> ~Alex

Hi Alex, I'm the author of Xsemantics. Any feedback is welcome :)

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book
Re: Typesystem for own DSL [message #1290910 is a reply to message #1284294] Thu, 10 April 2014 10:51 Go to previous messageGo to next message
Eclipse UserFriend
Hello,
I think I will try out both of the Frameworks and will use the one which better suits my problem-setting.

Regards,
Alex
Re: Typesystem for own DSL [message #1298583 is a reply to message #1290910] Wed, 16 April 2014 07:13 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

I'm not sure if both frameworks (XTS, Xsemantics ) may work in the following situation:

I want to import the Types.ecore metamodell (http://www.eclipse.org/uml2/4.0.0/Types) in my grammar, so my primitive types may match the uml-types.
Then I want to define the typesystem (with all constraints, with the help of one of the framework).

May this scenario work with Xsemantics oder XTS?

Thanks,
Alex
Re: Typesystem for own DSL [message #1298893 is a reply to message #1298583] Wed, 16 April 2014 11:30 Go to previous messageGo to next message
Eclipse UserFriend
I think, it can work with both of these frameworks, as the type system only defines type checking rules and not the way you provide the types.

Joerg
Re: Typesystem for own DSL [message #1310880 is a reply to message #1298893] Wed, 23 April 2014 09:01 Go to previous messageGo to next message
Eclipse UserFriend
Hello,

now I'm trying to implement my typesystem with the XTS-Framework and have some problems with the documentation. I want to implement some popup-actions like it is mentioned in the documetation ( here the pdf: http://xtext-typesystem.eclipselabs.org.codespot.com/files/XTextTypesystem-2.0.pdf) page 6, 7.
But it doesen't work, because the code is not migrated to Xtext 2.5. Maybe someone may tell me, if it possible to migrate the following method to the current version of xtext:

private String getDescription(final int offset,  
    final XtextResource resource) { 
  IParseResult parseResult = resource.getParseResult(); 
  CompositeNode rootNode = parseResult.getRootNode(); 
  AbstractNode currentNode = 
    ParseTreeUtil.getLastCompleteNodeByOffset(rootNode, offset); 
  EObject semanticObject = NodeUtil.getNearestSemanticObject(currentNode); 
  StringBuffer bf = new StringBuffer(); 
  bf.append( "QName: "+qfnp.getQualifiedName(semanticObject )+"\n" ); 
  bf.append( "Metaclass: "+semanticObject.eClass().getName()+"\n" ); 
  TypeCalculationTrace trace = new TypeCalculationTrace(); 
  EObject type = ts.typeof(semanticObject, trace); 
  if ( type != null ) { 
    bf.append("Runtime Type: "+ts.typeString(type)); 
  } else { 
    bf.append("Runtime Type: <no type>"); 
  } 
  bf.append("\n\nTrace: "); 
  for (String s: trace.toStringArray()) { 
    bf.append("\n  "+s); 
  } 
  return bf.toString(); 
} 


Or is it maybe even better to implement this method as an specialization of the DefaultEObjectHoverProvider?

~Alex
Re: Typesystem for own DSL [message #1312856 is a reply to message #1310880] Thu, 24 April 2014 10:47 Go to previous message
Eclipse UserFriend
Hello,

I implemented an own solution for the getDescription()-operation. To achieve the same behavior I just implemented an own hover (see here: http://christiandietrich.wordpress.com/2011/07/16/hover-support-in-xtext-2-0-tutorial/). The hover action calculates me the same information as the (old) method mentioned before.

Here my solution:
@Inject
	private ITypesystem ts;

	@Inject
	private IQualifiedNameProvider qfnp;

	@Override
	public String getDocumentation(EObject o) {

		if (o instanceof MyTypes) {

			HashMap<String, String> info = new HashMap<String, String>();

			String traceString = "", finalString = "<ul>";
			info.put("QName: ", qfnp.getFullyQualifiedName(o).getLastSegment());
			info.put("Metaclass: ", o.eClass().getName());

			TypeCalculationTrace trace = new TypeCalculationTrace();
			EObject type = ts.typeof(o, trace);

			if (type != null) {

				info.put("Runtime Type: ", ts.typeString(type));
			} else {

				info.put("Runtime Type: ", "<no type>");
			}

			// trace calculation
			for (String s : trace.toStringArray()) {
				traceString += s;
			}
			// add the trace string
			info.put("nTrace: ", traceString);

			for (String key : info.keySet()) {
				finalString += "<li>" + key + " " + info.get(key) + "</li>";
			}
			finalString += "</ul>";

			return finalString;
		}
		return null;
	}


~ Alex
Previous Topic:Headless testing for xtext
Next Topic:Resolve Proxies during linking phase
Goto Forum:
  


Current Time: Thu Jul 03 14:06:36 EDT 2025

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

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

Back to the top