| 
| [xText] Pulling up features into common super class [message #58352] | Tue, 14 July 2009 07:47 |  | 
| Eclipse User  |  |  |  |  | Originally posted by: c.krause.cwi.nl 
 Hi all,
 
 I want xText to generate a common superclass for two types and to pull
 up a feature into this superclass. More specifically, I have my grammar
 for arithmetical expressions:
 
 
 /* ----- N-ary Operations ----- */
 
 Addition returns Expression:
 Subtraction ( {Addition.operands += current} ('+' operands +=
 Subtraction)+)?;
 
 Multiplication returns Expression:
 Division ( {Multiplication.operands += current} ('*' operands +=
 Division)+)?;
 
 
 /* ----- Binary Operations ----- */
 
 Subtraction returns Expression:
 Multiplication ( {Subtraction.left = current} '-' right =
 Multiplication)?;
 
 Division returns Expression:
 Operation ( {Division.left = current} '/' right = Operation)?;
 
 
 Operation returns Expression:
 Literal | '(' Addition ')';
 
 
 
 ....and I would like to have the following type hierarchy generated:
 
 * Operation, Literal -> Expression
 * BinaryOperation, NaryOperation -> Operation
 * Addition, Multiplication -> NaryOperation
 * Subtraction, Division  -> BinaryOperation
 
 
 In all my attempts I ended up with a cyclic hierarchy. What I basically
 tried to do is to add a dummy rule:
 
 Operation:
 BinaryOperation | NaryOperation;
 
 I believe the problem is that in my current model Operation is not a type.
 
 If anybody has a hint, I'd appreciate any help. Anyway, I will try to
 get it working somehow..
 
 Cheers,
 Christian
 |  |  |  | 
Powered by 
FUDForum. Page generated in 0.03354 seconds