Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Content validation depending on file extension
Content validation depending on file extension [message #1861783] Fri, 03 November 2023 14:10 Go to next message
jo ber is currently offline jo berFriend
Messages: 94
Registered: August 2018
Member
Hi

I would like to have only one grammar supporting multiple file extensions say '.it', '.fr' and '.de' with the following grammar:

HelloModel:
   greetings+=Greeting*;

Greeting:
    ItalianGreeting | GermanGreeting | FrenchGreeting;

ItalianGreeting:
    'Buon' 'giorno' name=ID '!';

GermanGreeting:
    'Guten' 'Tag' name=ID '!';

FrenchGreeting:
    'Bonjour' name=ID '!';


The files with the extension '.it' supports only content with instances of 'ItalianGreeting', etc... How can I relate file extension, the validators and the content being saved in the resource?

Thank you and kind regards,

[Updated on: Fri, 03 November 2023 14:10]

Report message to a moderator

Re: Content validation depending on file extension [message #1861785 is a reply to message #1861783] Fri, 03 November 2023 14:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
You can ask any eObject for its eResource. That for its URI and uri has file extension

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Content validation depending on file extension [message #1861786 is a reply to message #1861785] Fri, 03 November 2023 15:26 Go to previous message
jo ber is currently offline jo berFriend
Messages: 94
Registered: August 2018
Member
of course... thank you
Previous Topic:How to customize the scope of a reference
Next Topic:Xtext 2.33.0.M3 is out
Goto Forum:
  


Current Time: Fri Dec 06 20:43:02 GMT 2024

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

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

Back to the top