Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Replacing XText expressions with external Java (or other language) code? (Or other ways to test the performance of XText and DSL?)
Replacing XText expressions with external Java (or other language) code? [message #1697415] Wed, 03 June 2015 17:38 Go to next message
Jiaju Shen is currently offline Jiaju ShenFriend
Messages: 5
Registered: June 2015
Junior Member
Hi I am a XText newbie.

When I was designing DSL for my project, I was wondering the performance of XText and DSL interface, especially when the grammar gets complicated and number of selections in autocomplete gets higher.

Let's take this scenario as an example:

Model: greetings+=Greeting*;

Greeting: 
        'String1' | 'String2' | 'String3' |'String4'             //How to replace this chunk with 1000 similar strings?
;


But if I want to test the performance I would like to put thousands of "StringX" in order to see the result.
I am wondering if there is a way to see how the program works by replacing XText expressions with some smarter tools (like putting 1000 random generated strings by Java)?
Re: Replacing XText expressions with external Java (or other language) code? [message #1697417 is a reply to message #1697415] Wed, 03 June 2015 18:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

generally it is a bad idea to tie everything into grammar.
what about using validation and/or a libary approach?

e.g:

Greeting:
value=ID
;

+ Adaption of Validator and ProposalProvider


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 03 June 2015 18:27]

Report message to a moderator

Re: Replacing XText expressions with external Java (or other language) code? [message #1697508 is a reply to message #1697417] Thu, 04 June 2015 13:24 Go to previous messageGo to next message
Jiaju Shen is currently offline Jiaju ShenFriend
Messages: 5
Registered: June 2015
Junior Member
What ways can I use in terms of validation and/or a libary approach?
I agree in my case, the need to implement complicated rules makes writing grammar cumbersome.
When you mentioned validation or library, what tools can I use? Are there any tutorials?
Re: Replacing XText expressions with external Java (or other language) code? [message #1697510 is a reply to message #1697508] Thu, 04 June 2015 13:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi have look at xtext docs and tutorial. It covers validation. Even the hello world example has a validation rule you simply need to uncomment.

With libary approach i mean.

In one part ofthe dsl you define the stuff that is available in another part you use it.
Since your initial question is hypotetical so i cannot tell if libary approch suits you usecase or not.
Model: defs+=Def*|use+=Use*;

Def: "def" name=ID;
Use: defRef=[Def];

Use would replace your greeting.
You ship/put next to
a file that contains defs for String1 to String1000
And can use themin your model file


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Replacing XText expressions with external Java (or other language) code? [message #1697514 is a reply to message #1697508] Thu, 04 June 2015 14:15 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FCompleteOCLTutorial.html&cp=40_3_1_9&anchor=CompleteOCLTutorial-XtextComplements

demonstrates how OCL can be used to add validation to Xtext.

Regards

Ed Willink


On 04/06/2015 14:24, Jiaju Shen wrote:
> What ways can I use in terms of validation and/or a libary approach?
> I agree in my case, the need to implement complicated rules makes
> writing grammar cumbersome.
> When you mentioned validation or library, what tools can I use? Are
> there any tutorials?
>
Previous Topic:Bad version number in .class file
Next Topic:Hide Toggle Mark Occurences
Goto Forum:
  


Current Time: Wed Apr 24 15:33:46 GMT 2024

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

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

Back to the top