Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross references(I want to decide whether to cross-reference or not in a rule based on the content)
Cross references [message #1862849] Tue, 02 January 2024 09:48 Go to next message
David Sun is currently offline David SunFriend
Messages: 45
Registered: July 2020
Member
I defined a DSL A using xtext. This DSL is used to define user-defined types, such as struct types and array types.

STRUCT STUDENT
{
NAME:STRING,
AGE:INT
}

I've defined another DSL B. When a variable is defined in DSL B, the type of the variable can be a user-defined type (for example, a user-defined struct type) or a primitive type (for example, INT, STRING).

VAR ANDY:STUDENT;//The user-defined type STUDENT is used
VAR ROOMNUM:INT;//The primitive type INT is used


The rule I need to implement now is that in the DSL B grammar file, it is possible to define a rule that if the variable's data type is from a user-defined type, then it is cross-referenced, and if the variable's type is primitive, then no cross-reference is used.

Can you give me some advice?
Thanks a lot!
Re: Cross references [message #1862851 is a reply to message #1862849] Tue, 02 January 2024 11:54 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
i did not understand what you want to achieve.
you can introduced reserved keywords for the primitive stuff and then use

TypeThing: PrimitiveType | ReferencedType;
PrimitiveType: "string"|"int";
ReferencedType: type=[Type];
but am not sure if that is truely what you mean


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Tue, 02 January 2024 11:54]

Report message to a moderator

Previous Topic:Reference from xxxx will not be updated as the language has not registered an IReferenceUpdater
Next Topic:How to include some multiline comments in the model instance ?
Goto Forum:
  


Current Time: Thu Dec 05 19:42:17 GMT 2024

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

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

Back to the top