Merge remote branch 'master'
[prop.git] / tests / rwc.pcc
blobb0abdb2c49bf981ce4c965c45e762c1cee98ca1f
1 #include <AD/gc/gcobject.h>
2 #include <iostream.h>
4 datatype Operator
5   = OP (const char *)
6   ;
8 datatype Expr
9   = ID (const char *)
10   | INT (int)
11   | BINARY (Operator, Expr, Expr)
12   ;
14 rewrite class Foo (Expr)  // Error: should be (Expr,Operator)
16   public:
17     Foo() {}
20 rewrite Foo 
22    BINARY(OP("+"), INT(x), INT(y)) : INT(x+y)
23  | BINARY(OP("-"), INT(x), INT(y)) : INT(x-y)
26 int
27 main()
29   Foo f;
30   Expr ex = BINARY(OP("+"),INT(1),INT(2));
32   f(ex);
33   return 0;