Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » GMT (Generative Modeling Technologies) » [TCS] Storing operators as enumeration values
[TCS] Storing operators as enumeration values [message #581864] Sat, 05 May 2007 13:43
Lorenzo Dalla Vecchia is currently offline Lorenzo Dalla VecchiaFriend
Messages: 58
Registered: July 2009
Member
Hello.

My project with TCS is going along very well, using SPL.tcs as reference.

I stumbled upon a minor problem with operation templates: as far as I know,
the storeOpTo option of an operatorTemplate specifies the attribute to save
the parsed operator to. I found that such attribute must be of KM3 type
String for the parser to work, however I originally planned to represent
operations in the KM3 models by means of an enumeration type, to keep the
model high-level.

KM3
---

enumeration Operation {
literal Addition
literal Subtraction
}

class OperationExpr extends Expr {
reference lExpr : Expr;
reference rExpr : Expr;
attribute operation : Operation;
}

TCS
---

operatorTemplate OperatorExpr(operators=opPlus opMinus, source=lExpr,
storeOpTo=operation);

With the above code, the ANTLR parser compiles correctly, but when parsing
an expression, the two Expr objects and an empty OperationExpr are flattened
out at the same level of the tree.

|- Expr
|- Expr
\- Operation {with operation attribute to default value, the first of the
enum}

Instead of:

\- Operation
|- Expr
\- Expr

The problem desappears if I set the type of the operation attribute back to
String.
Is there a way to do this with today's TCS?

Thanks.

--
Lorenzo
Previous Topic:Re: [ATL Transfromation] How to create a new class
Next Topic:[TCS] Storing operators as enumeration values
Goto Forum:
  


Current Time: Wed Apr 24 19:20:41 GMT 2024

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

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

Back to the top