Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Grammar for nested units(How to write grammar for nested units)
Grammar for nested units [message #1791643] Tue, 03 July 2018 09:45
Virag Purnam is currently offline Virag PurnamFriend
Messages: 142
Registered: June 2014
Senior Member
Hello,

I need to write grammar for nested units.
I am writing an example below.

Grammar:
grammar org.xtext.example.mydsl1.AnimalDsl with org.eclipse.xtext.common.Terminals

generate animalDsl "http://www.xtext.org/example/mydsl1/AnimalDsl"

Model:
	animals+=Animals*;
	
Animals:
	{Animals}(name = Name animal+= Animal* end+=End*);

Animal:
	(name = Name e=End?);

Name:
	name=ID;

End:
	'END' pName=[Name|ID];


Model:
Pet
   Dog
     Cat
       Mouse
       END Mouse
     End Cat 
   END Dog   
   Duck
   END Duck
END Pet


Problem is "Duck", does not come in "Pet". In Outline view also, it shows at the same level as "Pet".
It should come under Pet as Pet is ending after Duck.

Could you please help with this.


Thanks and regards,
Virag Purnam
Previous Topic:Xtext Gradle Plugin and Xtext Builder
Next Topic:Grammar for nested units
Goto Forum:
  


Current Time: Sun May 05 18:29:58 GMT 2024

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

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

Back to the top