@@ -11,19 +11,27 @@ import Expr
1111 * (`UnaryArithmeticOperation`) or a binary arithmetic operation
1212 * (`BinaryArithmeticOperation`).
1313 */
14- class ArithmeticOperation extends Operation , @arith_op_expr {
14+ class ArithmeticOperation extends Operation , @arith_operation {
1515 override string getOperator ( ) { none ( ) }
1616}
1717
1818/**
19- * A unary arithmetic operation. Either a unary minus operation
20- * (`UnaryMinusExpr`), a unary plus operation (`UnaryPlusExpr`),
19+ * A binary arithmetic operation. Either a binary arithmetic expression (`BinaryArithmeticExpr`) or
20+ * an arithmetic assignment expression (`AssignArithmeticExpr`).
21+ */
22+ class BinaryArithmeticOperation extends ArithmeticOperation , BinaryOperation , @bin_arith_operation {
23+ override string getOperator ( ) { none ( ) }
24+ }
25+
26+ /**
27+ * A unary arithmetic operation. Either a unary minus expression
28+ * (`UnaryMinusExpr`), a unary plus expression (`UnaryPlusExpr`),
2129 * or a mutator operation (`MutatorOperation`).
2230 */
23- class UnaryArithmeticOperation extends ArithmeticOperation , UnaryOperation , @un_arith_op_expr { }
31+ class UnaryArithmeticOperation extends ArithmeticOperation , UnaryOperation , @un_arith_operation { }
2432
2533/**
26- * A unary minus operation , for example `-x`.
34+ * A unary minus expression , for example `-x`.
2735 */
2836class UnaryMinusExpr extends UnaryArithmeticOperation , @minus_expr {
2937 override string getOperator ( ) { result = "-" }
@@ -32,7 +40,7 @@ class UnaryMinusExpr extends UnaryArithmeticOperation, @minus_expr {
3240}
3341
3442/**
35- * A unary plus operation , for example `+x`.
43+ * A unary plus expression , for example `+x`.
3644 */
3745class UnaryPlusExpr extends UnaryArithmeticOperation , @plus_expr {
3846 override string getOperator ( ) { result = "+" }
@@ -44,40 +52,40 @@ class UnaryPlusExpr extends UnaryArithmeticOperation, @plus_expr {
4452 * A mutator operation. Either an increment operation (`IncrementOperation`)
4553 * or a decrement operation (`DecrementOperation`).
4654 */
47- class MutatorOperation extends UnaryArithmeticOperation , @mut_op_expr { }
55+ class MutatorOperation extends UnaryArithmeticOperation , @mut_operation { }
4856
4957/**
50- * An increment operation. Either a postfix increment operation
51- * (`PostIncrExpr`) or a prefix increment operation (`PreIncrExpr`).
58+ * An increment operation. Either a postfix increment expression
59+ * (`PostIncrExpr`) or a prefix increment expression (`PreIncrExpr`).
5260 */
53- class IncrementOperation extends MutatorOperation , @incr_op_expr {
61+ class IncrementOperation extends MutatorOperation , @incr_operation {
5462 override string getOperator ( ) { result = "++" }
5563}
5664
5765/**
58- * A decrement operation. Either a postfix decrement operation
59- * (`PostDecrExpr`) or a prefix decrement operation (`PreDecrExpr`).
66+ * A decrement operation. Either a postfix decrement expression
67+ * (`PostDecrExpr`) or a prefix decrement expression (`PreDecrExpr`).
6068 */
61- class DecrementOperation extends MutatorOperation , @decr_op_expr {
69+ class DecrementOperation extends MutatorOperation , @decr_operation {
6270 override string getOperator ( ) { result = "--" }
6371}
6472
6573/**
66- * A prefix increment operation , for example `++x`.
74+ * A prefix increment expression , for example `++x`.
6775 */
6876class PreIncrExpr extends IncrementOperation , @pre_incr_expr {
6977 override string getAPrimaryQlClass ( ) { result = "PreIncrExpr" }
7078}
7179
7280/**
73- * A prefix decrement operation , for example `--x`.
81+ * A prefix decrement expression , for example `--x`.
7482 */
7583class PreDecrExpr extends DecrementOperation , @pre_decr_expr {
7684 override string getAPrimaryQlClass ( ) { result = "PreDecrExpr" }
7785}
7886
7987/**
80- * A postfix increment operation , for example `x++`.
88+ * A postfix increment expression , for example `x++`.
8189 */
8290class PostIncrExpr extends IncrementOperation , @post_incr_expr {
8391 override string toString ( ) { result = "..." + this .getOperator ( ) }
@@ -86,7 +94,7 @@ class PostIncrExpr extends IncrementOperation, @post_incr_expr {
8694}
8795
8896/**
89- * A postfix decrement operation , for example `x--`.
97+ * A postfix decrement expression , for example `x--`.
9098 */
9199class PostDecrExpr extends DecrementOperation , @post_decr_expr {
92100 override string toString ( ) { result = "..." + this .getOperator ( ) }
@@ -95,55 +103,84 @@ class PostDecrExpr extends DecrementOperation, @post_decr_expr {
95103}
96104
97105/**
98- * A binary arithmetic operation. Either an addition operation
99- * (`AddExpr`), a subtraction operation (`SubExpr`), a multiplication
100- * operation (`MulExpr`), a division operation (`DivExpr`), or a
101- * remainder operation (`RemExpr`).
106+ * An addition operation, either `x + y` or `x += y`.
102107 */
103- class BinaryArithmeticOperation extends ArithmeticOperation , BinaryOperation , @bin_arith_op_expr {
104- override string getOperator ( ) { none ( ) }
108+ class AddOperation extends BinaryArithmeticOperation , @add_operation { }
109+
110+ /**
111+ * A subtraction operation, either `x - y` or `x -= y`.
112+ */
113+ class SubOperation extends BinaryArithmeticOperation , @sub_operation { }
114+
115+ /**
116+ * A multiplication operation, either `x * y` or `x *= y`.
117+ */
118+ class MulOperation extends BinaryArithmeticOperation , @mul_operation { }
119+
120+ /**
121+ * A division operation, either `x / y` or `x /= y`.
122+ */
123+ class DivOperation extends BinaryArithmeticOperation , @div_operation {
124+ /** Gets the numerator of this division operation. */
125+ Expr getNumerator ( ) { result = this .getLeftOperand ( ) }
126+
127+ /** Gets the denominator of this division operation. */
128+ Expr getDenominator ( ) { result = this .getRightOperand ( ) }
105129}
106130
107131/**
108- * An addition operation, for example `x + y`.
132+ * A remainder operation, either `x % y` or `x %= y`.
133+ */
134+ class RemOperation extends BinaryArithmeticOperation , @rem_operation { }
135+
136+ /**
137+ * A binary arithmetic expression. Either an addition expression
138+ * (`AddExpr`), a subtraction expression (`SubExpr`), a multiplication
139+ * expression (`MulExpr`), a division expression (`DivExpr`), or a
140+ * remainder expression (`RemExpr`).
141+ */
142+ class BinaryArithmeticExpr extends BinaryArithmeticOperation , @bin_arith_expr { }
143+
144+ /**
145+ * An addition expression, for example `x + y`.
109146 */
110- class AddExpr extends BinaryArithmeticOperation , AddOperation , @add_expr {
147+ class AddExpr extends BinaryArithmeticExpr , AddOperation , @add_expr {
111148 override string getOperator ( ) { result = "+" }
112149
113150 override string getAPrimaryQlClass ( ) { result = "AddExpr" }
114151}
115152
116153/**
117- * A subtraction operation , for example `x - y`.
154+ * A subtraction expression , for example `x - y`.
118155 */
119- class SubExpr extends BinaryArithmeticOperation , SubOperation , @sub_expr {
156+ class SubExpr extends BinaryArithmeticExpr , SubOperation , @sub_expr {
120157 override string getOperator ( ) { result = "-" }
121158
122159 override string getAPrimaryQlClass ( ) { result = "SubExpr" }
123160}
124161
125162/**
126- * A multiplication operation , for example `x * y`.
163+ * A multiplication expression , for example `x * y`.
127164 */
128- class MulExpr extends BinaryArithmeticOperation , MulOperation , @mul_expr {
165+ class MulExpr extends BinaryArithmeticExpr , MulOperation , @mul_expr {
129166 override string getOperator ( ) { result = "*" }
130167
131168 override string getAPrimaryQlClass ( ) { result = "MulExpr" }
132169}
133170
134171/**
135- * A division operation , for example `x / y`.
172+ * A division expression , for example `x / y`.
136173 */
137- class DivExpr extends BinaryArithmeticOperation , DivOperation , @div_expr {
174+ class DivExpr extends BinaryArithmeticExpr , DivOperation , @div_expr {
138175 override string getOperator ( ) { result = "/" }
139176
140177 override string getAPrimaryQlClass ( ) { result = "DivExpr" }
141178}
142179
143180/**
144- * A remainder operation , for example `x % y`.
181+ * A remainder expression , for example `x % y`.
145182 */
146- class RemExpr extends BinaryArithmeticOperation , RemOperation , @rem_expr {
183+ class RemExpr extends BinaryArithmeticExpr , RemOperation , @rem_expr {
147184 override string getOperator ( ) { result = "%" }
148185
149186 override string getAPrimaryQlClass ( ) { result = "RemExpr" }
0 commit comments