Cross references [message #1862849] |
Tue, 02 January 2024 04:48  |
Eclipse User |
|
|
|
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 06:54  |
Eclipse User |
|
|
|
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
[Updated on: Tue, 02 January 2024 06:54] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04307 seconds