Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Regex and Xtext(to dump to create a new terminal definittion)
Regex and Xtext [message #704432] Thu, 28 July 2011 16:08 Go to next message
joba is currently offline jobaFriend
Messages: 2
Registered: August 2010
Junior Member
I try to define a new terminal similar to ID.

This new ID should look like

urn:<DOMAIN-NAME>:<OBJECT-NAME>

DOMAIN-NAME should be a fixed String
OBJECT-NAME should be the same like ID

Could any body help me ??

Re: Regex and Xtext [message #704480 is a reply to message #704432] Thu, 28 July 2011 17:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13613
Registered: July 2009
Senior Member
Hi,

i'd do this with a Datatype rule

e.g.

NewId: "urn" ":" STRING ":" ID;

~Christian


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: Regex and Xtext [message #704827 is a reply to message #704480] Fri, 29 July 2011 05:41 Go to previous messageGo to next message
joba is currently offline jobaFriend
Messages: 2
Registered: August 2010
Junior Member
This is not what i need.


Here is my definition:

Model:
objects+=BASE_OBJECTS*;

BASE_OBJECTS:
(USER | GROUP | RESOURCE)
;


USER:
"user" name=URN
;

USERS:
{USERS}
"users ""{"
(users+=[USER])+
"}"
;


GROUP:
"group" name=URN
;

GROUPS:
{GROUPS}
"groups" "{"
(groups+=[GROUP])+
"}"
;

RESOURCE:
"resource" name=URN
"{"
(users=USERS)?
(groups=GROUPS)?
"}"
;

URN: "urn" ":" "nfon.net" ":" ID;


If i try to use with this data:

user urn:nfon.net:joerg

group urn:nfon.net:test2

resource urn:nfon.net:dummy {
users {
urn:nfon.net:joerg
}
groups {
urn:nfon.net:test
}
}

i get several problems:

1. If i try to enter a URN for user/group i donĀ“t get any suggestions for autocomplete.
2. with the solution "URN: "urn" ":" "nfon.net" ":" ID;" it accept WS between the Elements. It is not a "unique" name
3. if i try to use a reference to user or group i get an error in the GUI.
4. if i try to get autocompletion for references inside users/group i get nothing

Maybe i have to implement/extend some classes. Could give me a hint which classes ???

What I want to do is to have a URN which works exactly like the ID. In other words: to overwrite the definition for ID

any clues ???
Re: Regex and Xtext [message #704840 is a reply to message #704827] Fri, 29 July 2011 06:05 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

You try to reference user etc via an ID ([USER] is short for [USER|ID]). You need to reference them via URN, ie. use [USER|URN] or write a custom scope provider, that makes them visible via a simple ID-name.

You should stick to naming conventions to make the grammar more readable. Terminal rules all uppercase, Parser rules first letter upper case (Group instead of GROUP).

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Previous Topic:Not resolving proxies after reloading model
Next Topic:Xtend help
Goto Forum:
  


Current Time: Mon Sep 28 07:09:51 GMT 2020

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

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

Back to the top