Skip to main content



      Home
Home » Modeling » TMF (Xtext) » [TCS] postfix operators
[TCS] postfix operators [message #22561] Fri, 31 October 2008 07:57 Go to next message
Eclipse UserFriend
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 10:01 Go to previous message
Eclipse UserFriend
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 May 08 17:04:04 EDT 2025

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

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

Back to the top