Skip to content

Commit

Permalink
Linked to my new StackExchange question in the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
FlatAssembler committed Sep 28, 2024
1 parent 9c3e0d6 commit eb4950e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ TreeNode::applyBinaryOperators(std::vector<TreeNode> input,
for (int i = 0; i < int(input.size()); i++)
loop_body(i);
else if (associativity == Associativity::right)
for (int i = input.size() - 1; i >= 0; i--)
for (int i = input.size() - 1; i >= 0;
i--) // I received some comments on Internet forums that the "scan
// backwards" method of parsing right-associative operators (as I
// am doing here, as well as down below when parsing `?:`) is
// considered to be an anti-pattern. So, I have opened a
// StackExchange question about that:
// https://langdev.stackexchange.com/q/4071/330
loop_body(i);
else {
std::cerr << "Line " << input.at(0).lineNumber << ", Column "
Expand Down

0 comments on commit eb4950e

Please sign in to comment.