xtext

Xtext global auto-generation

限于喜欢 提交于 2019-12-11 19:14:12
问题 In Xtext, how does one auto-generate a single file containing information from multiple model files. Consider the following simple Xtext grammar. grammar org.example.people.People with org.eclipse.xtext.common.Terminals generate people "http://www.example.org/people/People" People: people+=Person*; Person: 'person' name=ID ';'; In the launched workspace I create a project with two files, friends.people // friends person Alice; person Bob; and enemies.people // enemies person Malice; person

how to add a separator in in xtext list?

[亡魂溺海] 提交于 2019-12-11 18:33:54
问题 I have the following grammar fragment: FixtureGroup: name = ID ':' fixtures += [Fixture]* ';'; And in the instance I can type for the above rule the following: FrontLeft: FrontLeft1 FrontLeft2; However, what I like to type is a plus in between: FrontLeft: FrontLeft1 + FrontLeft2; How should I change the grammar to accomplish this? 回答1: the ususal pattern is ':' (fixtures += [Fixture] ('+' fixtures += [Fixture])*)? 来源: https://stackoverflow.com/questions/55929123/how-to-add-a-separator-in-in

Grammatically restricted JVMModelInferrer inheritence with Xtext and XBase

一世执手 提交于 2019-12-11 17:07:15
问题 The following canonical XBase entities grammar (from "Implementing Domain-Specific Languages with Xtext and Xtend" Bettini) permits entities to extend any Java class. As the commented line indicates, I would like to grammatically force entities to only inherit from entities. grammar org.example.xbase.entities.Entities with org.eclipse.xtext.xbase.Xbase generate entities "http://www.example.org/xbase/entities/Entities" Model: importSection=XImportSection? entities+=Entity*; Entity: 'entity'

How to add cascading content assist in Xtext document

佐手、 提交于 2019-12-11 16:03:33
问题 I want to add cascading content assist while creating an array of pre-defined values. When I'm creating the array, it should first give me the assist to add only '{'. After that it should suggest me the list of pre-defined values and a '}'. If I choose a value, it should suggest me to add a comma, then repeat the above step. It should keep suggesting me these until I add a closing brace. Currently I'm able to provide content-assist for only one element in the array. An example of desired

xtext - Couldn't resolve reference to

倖福魔咒の 提交于 2019-12-11 16:01:39
问题 I have the following grammar: Model: prog+=Program*; Program: g=Greeting de+=DataEntry* s+=Statement*; Greeting: 'Hello' t=ProgPara '!'; ProgPara: 'PROGRAM' pname=Progname ';'; Progname : name=ID; DataEntry: a=INT v=Varname ';'; Varname : name = ID; Statement: (c=CopyStmt|m=MoveStmt) ';'; CopyStmt: 'COPY' 'TO' qname=[IndexVarname|ID] ; IndexVarname : (Indexname|Varname); Indexname : '(' name = ID ')'; MoveStmt: 'MOVE' 'TO' p=[PrVarName|ID]; PrVarName : (Varname|Progname); But it throws error

Match string in XText regardless of upper/lower case

落花浮王杯 提交于 2019-12-11 13:33:31
问题 I want to create a rule in XText that matches to a string, but does not care in what case the string is. For example, I want it to match against both "DUCK", "DucK" and "duck". Is there a more simple way of doing it than covering all cases, like: Rule: 'Duck'|'DucK'|'DuCK'|... and so on ; 回答1: There is a flag that you can configure in the mwe2 workflow. Replace the XtextAntlrGeneratorFragment by the org.eclipse.xtext.generator.parser.antlr.ex.rt.AntlrGeneratorFragment and pass options = {

How to turn off global scope in XText 2.9?

≡放荡痞女 提交于 2019-12-11 12:59:19
问题 someone knows how to turn off the global scope in XText 2.9? I want to turn off the global scope in order to only can access the elements of the files that I import. For example: file1.mydsl: element A(C){ ; } subelement C{ ; } file2.mydsl: element B(C){ ; } This should return an error in file2.mydsl because I haven't imported "file1.mydsl". I should add the line - import "file1.mydsl" - to avoid the error. How can I do that in Xtext 2.9? I have a working code that does what I want but the

Xtext - how to reference an element of an element

回眸只為那壹抹淺笑 提交于 2019-12-11 11:30:03
问题 Using the simple entity example https://eclipse.org/Xtext/documentation/102_domainmodelwalkthrough.html How can I add something like the following: Map: 'map' entityA=[Entity] '.' featureA=[Feature] '=>' entityZ=[Entity] '.' featureZ=[Feature] ; So that I can write: entity A { name:String } entity B { name:String } map A.name => B.name So that I get content assist when writing A. scoped to the features of A only? thanks 回答1: you usually do such things by adapting the concept of "scoping". the

rule has non-LL(*) decision due to recursive rule invocations

风流意气都作罢 提交于 2019-12-11 08:14:42
问题 I have an error (like said in the title) with one rule that i dont know how resolve. i have written the following rule : FunctionArguments returns FunctionArgs::IFunctionArguments : FunctionArgumentsNormal | FunctionArgumentsForIter ; FunctionArgumentsNormal returns FunctionArgs::IFunctionArguments : {FunctionArgs::FunctionArguments} args+=Expression (',' args+=Expression)* | {FunctionArgs::FunctionArguments} argNames+=NamedArguments (',' argNames+=NamedArguments)* ; FunctionArgumentsForIter

How to embed XBase expressions in an Xtext DSL

大城市里の小女人 提交于 2019-12-11 04:49:21
问题 I am writing a simple little DSL for specifying constraints on messages, and Have been trying without success for a while to embed XBase expressions into the language. The Grammar looks like this: grammar org.xtext.businessrules.BusinessRules with org.eclipse.xtext.xbase.Xbase //import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes generate businessRules "http://www.xtext.org/businessrules/BusinessRules" Start: rules+