xtext

How to use xtext inferred JVM model outside of xtext project?

橙三吉。 提交于 2019-12-13 03:36:30
问题 In the Inferring a JVM Model section of the Xtext documentation (http://www.eclipse.org/Xtext/documentation.html#_17) it starts by saying: "In many cases, you will want your DSLs concepts to be usable as Java elements. E.g. an Entity will become a Java class and should be usable as such". In the example above, how can I use the generated Entity class outside of xbase, i.e. in real Java code in a different project to the xtext one? What I am essentially asking is if the Java classes created my

Defining Primitives within xtext Grammar

女生的网名这么多〃 提交于 2019-12-12 20:26:02
问题 I would like to create an incredibly simple DSL using xtext, with the following features: It will have two primitive types: Number and String Users can define their own classes, which are composed of field declarations A field declaration associates a name with a type, where a type can be a class or a primitive The following is my attempt at a DSL, the class definition and references work fine, but I cannot figure out how to have primitive types. The 'String' and 'Number' literals are not

xtext custom scoping: parameters of function

杀马特。学长 韩版系。学妹 提交于 2019-12-12 17:51:48
问题 I am trying to custom scoping, such that if I have something like function in my language that get parameters, I want that those parameters will be visible only until there is semicolon, and out of this scope, I want it to not be visible. I tried redefine the method getScope() in the file MyDslScopeProvider.xtend In getScope I did something like this: if (EclassName=="TypedParam" && EFeatureName=="type" && contextType == "TypedParam"){ return Scopes.scopeFor(Collections.singleton(context)

Unparse AST < O(exp(n))?

落爺英雄遲暮 提交于 2019-12-12 08:23:50
问题 Abstract problem description: The way I see it, unparsing means to create a token stream from an AST, which when parsed again produces an equal AST. So parse(unparse(AST)) = AST holds. This is the equal to finding a valid parse tree which would produce the same AST. The language is described by a context free S-attributed grammar using a eBNF variant. So the unparser has to find a valid 'path' through the traversed nodes in which all grammar constraints hold. This bascially means to find a

IResourceScopeCache for Avoid expensive scope calculation

霸气de小男生 提交于 2019-12-12 04:23:49
问题 I have the same problem that described is this link I want to use IResourceScopeCache in my getScope function I implemented, but I don't know how to do it. Didn't found anything that helped me. I have this file: MyDslScopeProvider.xtend that I override getScope() there. How can I use the cache there? override def IScope getScope(EObject context, EReference reference) { if (reference == SpectraPackage.Literals.TEMPORAL_PRIMARY_EXPR__POINTER) { val contextDecl = EcoreUtil2.getContainerOfType

Xtext - Validating for duplicate names

假装没事ソ 提交于 2019-12-12 00:58:33
问题 I have the following grammer, but I want to do some validation on this. I want to make an error if there are duplicate names in the "players" list. Grammer: Football: 'Club' name=STRING playerList=PlayerList footballObjects+=FootballObject ; FootballObject: Player | Coach ; PlayerList: players+=[Player] ( players+=[Player] )* ; Player: 'Player' name=ID ; I tried the following: @Check def checkGreetingStartsWithCapital(Football model) { val names = newHashSet for (g : model.playersList.players

Xtext: Calling the Generator from a Context Menu

好久不见. 提交于 2019-12-12 00:39:01
问题 Following https://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/ and using EclipseResourceFileSystemAccess2 instead of EclipseResourceFileSystemAccess when the line final EclipseResourceFileSystemAccess2 fsa = fileAccessProvider.get(); give an exception. The only information I have is // Compiled from InvocationTargetException.java (version 1.8 : 52.0, super bit) public class java.lang.reflect.InvocationTargetException extends java.lang

Add eObject to the parse tree programaticaly

烂漫一生 提交于 2019-12-11 22:23:23
问题 Here is a snapshot of my grammar: Sort: name=ID ; Variable name=ID ':' type=[Sort] My requirement is to have a predefined Sort let's call it Loc . There is no need for the user to define this sort, thus when a Variable is defined with a Loc type, Xtext should automatically reference it to my predefined Sort. How can I initiate the program so that at the beginning a Sort instance is generated? I already used the Factory method 'CreateSort' in my validator class, but no use. any idea? 回答1: Your

In Xtext, how to tweak certain function calls

走远了吗. 提交于 2019-12-11 19:45:20
问题 I am using Xtext 2.15 to generate a language that, among other things, processes asynchronous calls in a way they look synchronous. For instance, the following code in my language: int a = 1; int b = 2; boolean sleepSuccess = doSleep(2000); // sleep two seconds int c = 3; int d = 4; would generate the following Java code: int a = 1; int b = 2; doSleep(2000, new DoSleepCallback() { public void onTrigger(boolean rc) { boolean sleepSuccess = rc; int c = 3; int d = 4; } }); To achieve it, I

Xtext: define 2 DSL's in one project

无人久伴 提交于 2019-12-11 19:28:15
问题 How do you define two DSL's in one Eclipse project? The first DSL is used as input syntax where the user specify a design. The design needs to be converted into a different language. The different language is defined by the second DSL. For the transformation I intend to use Epsilon Transformation Language (ETL). 回答1: having two dsl in one project is not neccessary for your usecase. if you want to do it anyway you can add multiple language sections to the workflow like language =