Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [TCS] postfix operators
[TCS] postfix operators [message #22561] Fri, 31 October 2008 11:57 Go to next message
T Kruse is currently offline T KruseFriend
Messages: 73
Registered: July 2009
Member
Hi,

TCS has a notation for postfix operators, but the result looks weird for
arity = 2. Is this maybe only intended for unary operators?

Like for any binary operator "+", in theory one could have it infix, as in
3+2, or prefix, as in +(3,4), or postfix as in (3,4)+
but I guess none of these are covered by TCS, right?
Re: [TCS] postfix operators [message #22691 is a reply to message #22561] Mon, 03 November 2008 15:01 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hi Thibault,

"Postfix" has indeed only been used for unary operators so far.
Because it is possible to represent "(3, 4)+" without using
operatorTemplates, you may directly encode the postfix notation using
standard templates.

For instance:

- Metamodel excerpt:

abstract class Expression {}

class BinaryOpExp extends Expression {
reference leftOperand container : Expression;
attribute operator : Operator;
reference rightOperand container : Expression;
}

enumeration Operator {
literal plus;
literal minus;
literal and;
literal or;
-- ...
}


- TCS excerpt:

template BinaryOpExp
: "(" leftOperand "," rightOperand ")" operator
;

enumerationTemplate Operator
: #plus = "+",
#minus = "-",
#and = "and",
#or = "or"
;


Of course, it would also be possible to implement support for postfix
operatorTemplates in TCS.



Best regards,

Frédéric Jouault

T Kruse a écrit :
> Hi,
>
> TCS has a notation for postfix operators, but the result looks weird for
> arity = 2. Is this maybe only intended for unary operators?
>
> Like for any binary operator "+", in theory one could have it infix, as
> in 3+2, or prefix, as in +(3,4), or postfix as in (3,4)+
> but I guess none of these are covered by TCS, right?
>
Previous Topic:Suche "Textual Modeling Tools"
Next Topic:[Announce] TMF XTEXT 0.7.0M2 is available
Goto Forum:
  


Current Time: Thu Dec 26 16:28:08 GMT 2024

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

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

Back to the top