Skip to main content



      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 05:45
Eclipse UserFriend
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: Tue Jun 17 08:05:08 EDT 2025

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

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

Back to the top