Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Empty rule
Empty rule [message #1010122] Sat, 16 February 2013 16:03 Go to next message
Pooyan Behnamghader is currently offline Pooyan BehnamghaderFriend
Messages: 7
Registered: July 2012
Junior Member
Hi.

How can I define grammars with empty rules in Xtext?
For example:



grammar ir.ut.ece.MathExpComp_1 with org.eclipse.xtext.common.Terminals

generate mathExpComp_1 "http://www.ut.ir/ece/MathExpComp_1"
/*

 */
E:
	T Ep
;


E1P:
	'+' T Ep
;

Ep:
	''
;
T:
	F Tp
;
T1p:
	'*' F Tp
;
Tp: // Empty rule
	''
;
F:
	value=INT
;


Bests,
Pooyan
Re: Empty rule [message #1010126 is a reply to message #1010122] Sat, 16 February 2013 16:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
HI,

you/have to assign things in xtext.and you can use cardinalities.
You may have a look at
http://blog.efftinge.de/2010/08/parsing-expressions-with-xtext.html


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Empty rule [message #1010131 is a reply to message #1010126] Sat, 16 February 2013 16:32 Go to previous messageGo to next message
Pooyan Behnamghader is currently offline Pooyan BehnamghaderFriend
Messages: 7
Registered: July 2012
Junior Member
Dear Christian,
Hi.

I appreciate your time and your kind answer.
The mathematical expression was just to show the problem that I have been faced. I have some problem with inherited attributes in xtext grammar.
I am developing a DSL which it's grammar contains some empty parsing elements (epsilon rules).

Is it possible to write such grammars in Xtext?

Bests,
Pooyan
Re: Empty rule [message #1010133 is a reply to message #1010131] Sat, 16 February 2013 16:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
hi

can you post the real example?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Empty rule [message #1010233 is a reply to message #1010131] Sun, 17 February 2013 00:01 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 2013-16-02 17:32, Pooyan Behnamghader wrote:
> Dear Christian,
> Hi.
>
> I appreciate your time and your kind answer.
> The mathematical expression was just to show the problem that I have
> been faced. I have some problem with inherited attributes in xtext grammar.
> I am developing a DSL which it's grammar contains some empty parsing
> elements (epsilon rules).
>
> Is it possible to write such grammars in Xtext?
>

In some grammar languages you write something like

R : // empty
| something

In Xtext, this is done with cardinality - i.e:

R : something ?

Which means R contains an optional something (since it is optional,
"empty"/"nothing" is also valid at this position.

Does that answer your question?

Regards
- henrik
Previous Topic:Xtend2: extended type-based collection filters
Next Topic:Skipping validations of features from EMF Model
Goto Forum:
  


Current Time: Fri Mar 29 09:19:10 GMT 2024

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

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

Back to the top