Skip to content

Commit a78d0b6

Browse files
authored
Merge CatExpression and AddExpression (#3679)
The existence of CatExpression makes the expression grammar non-trivially left recursive and is not representative of how it is actually parsed, so merge it with AddExpression.
1 parent 86339d4 commit a78d0b6

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

spec/expression.dd

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -850,16 +850,20 @@ $(GNAME ShiftExpression):
850850
-------------
851851
)
852852

853-
$(H2 $(LNAME2 add_expressions, Add Expressions))
853+
$(H2 $(LNAME2 additive_expressions, Additive Expressions))
854854

855855
$(GRAMMAR
856856
$(GNAME AddExpression):
857857
$(GLINK MulExpression)
858858
$(GSELF AddExpression) $(D +) $(GLINK MulExpression)
859859
$(GSELF AddExpression) $(D -) $(GLINK MulExpression)
860-
$(GLINK CatExpression)
860+
$(GSELF AddExpression) $(D ~) $(GLINK MulExpression)
861861
)
862862

863+
$(H3 $(LNAME2 add_expressions, Add Expressions))
864+
$(P In the cases of the Additive operations $(D +) and $(D -):
865+
)
866+
863867
$(P If the operands are of integral types, they undergo the $(USUAL_ARITHMETIC_CONVERSIONS),
864868
and then are brought to a common type using the
865869
$(USUAL_ARITHMETIC_CONVERSIONS).
@@ -882,10 +886,9 @@ $(GNAME AddExpression):
882886
$(P Add expressions for floating point operands are not associative.
883887
)
884888

885-
$(H3 $(LNAME2 pointer_arithmetic, Pointer Arithmetic))
889+
$(H4 $(LNAME2 pointer_arithmetic, Pointer Arithmetic))
886890

887-
$(P If the operator is $(D +) or $(D -), and
888-
the first operand is a pointer, and the second is an integral type,
891+
$(P If the first operand is a pointer, and the second is an integral type,
889892
the resulting type is the type of the first operand, and the resulting
890893
value is the pointer plus (or minus) the second operand multiplied by
891894
the size of the type pointed to by the first operand.
@@ -935,12 +938,9 @@ assert(d == 2);
935938
)
936939

937940

938-
$(H2 $(LNAME2 cat_expressions, Cat Expressions))
939-
940-
$(GRAMMAR
941-
$(GNAME CatExpression):
942-
$(GLINK AddExpression) $(D ~) $(GLINK MulExpression)
943-
)
941+
$(H3 $(LNAME2 cat_expressions, Cat Expressions))
942+
$(P In the case of the Additive operation $(D ~):
943+
)
944944

945945
$(P A $(I CatExpression) concatenates a container's data with other data, producing
946946
a new container.)

0 commit comments

Comments
 (0)