Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Help with Actions
Help with Actions [message #756726] Mon, 14 November 2011 20:18 Go to next message
Lucy Sakhnenko is currently offline Lucy SakhnenkoFriend
Messages: 41
Registered: March 2011

I'm having a little trouble with my grammar. Here I show a sample of my code.

	'expression' expression=Expression

	Multiplication (({Plus.left=current} '+' | {Minus.left=current} '-') right=Multiplication)*

	Power (({Multi.left=current} '*'  | {Div.left=current} '/')  right=Power)*

	PrimaryExpression (({Power.left=current} '^') right=PrimaryExpression)*

	(  FieldReference | MethodInvocation)
	| Something

MethodInvocation : 


	st='some rule'

I need to be able to place a sign "+" or "-" as prefix for FieldReference and MethodInvocation. I cannot write something like "sign=('+' | '-')" inside any of those rules because I use them in different parts of the grammar where the sign would make no sense. For example, with the recursive dot :


Also, I cannot place the sing before ( FieldReference | MethodInvocation) in the PrimaryExpression rule because I get "An unassigned rule call is not allowed, when the 'current' was already created".

How would you do this?

Re: Help with Actions [message #756822 is a reply to message #756726] Tue, 15 November 2011 09:50 Go to previous message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
First some links which might be helpful:

In essence, your sign (+|-) is a prefix operator with a FieldReference or MethodInvocation as operand and which is probably non-associative.

For the dot operator, you might want to look into:

(And sorry about the shameless plugs Wink)

Previous Topic:Xtext 2: problem with workflow
Next Topic:problems with the tutorial "Five simple steps to your JVM language"
Goto Forum:

Current Time: Sat Apr 17 12:28:40 GMT 2021

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

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

Back to the top