Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How should I write an Xtext rule that refers to itself?
How should I write an Xtext rule that refers to itself? [message #1828679] Tue, 16 June 2020 13:25 Go to next message
Vinicius Costa e Silva is currently offline Vinicius Costa e SilvaFriend
Messages: 1
Registered: June 2020
Junior Member
Hello! I'm a beginner with Xtext and I've been tasked with writing a DSL that accepts rules in the following format (that I call events):

instance: def(parameter);
gen: key = def(parameter);

I've written a simple grammar that accepts events like this:

	event=ID (":" | "=") method = ID"("object=ID")"  ";"

This rule accepts both instance: def(parameter); or key = def(parameter); . But I'm unable to write a rule for this event type that refers back to itself, so I could write something like:

gen: key = def(parameter);

The way I imagine it, I would need to assign an eventType back to the method field, kind like a recursion.

Any tips on how could I accomplish that?
Re: How should I write an Xtext rule that refers to itself? [message #1828746 is a reply to message #1828679] Thu, 18 June 2020 04:56 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6985
Registered: July 2009
Senior Member

The standard example is expressions. See the Xtext Arithmetics example.


Ed Willink
Previous Topic:Code signature error: could not load SWT library in OS X Catalina
Next Topic:cross-reference linking and xbase
Goto Forum:

Current Time: Tue Jan 19 05:55:48 GMT 2021

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

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

Back to the top