Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/22 21:34:43 (2 years ago)
Author:
gkronber
Message:

#3145: fixed a bug in the infix formatter introduced in my earlier commit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs

    r18172 r18203  
    3939        if (token == "+" || token == "-" || token == "OR" || token == "XOR") {
    4040          var parenthesisRequired = false;
    41           if (node.Parent != null && node.Parent.SubtreeCount > 1) {
     41          if (node.Parent != null && IsOperator(node.Parent.Symbol)) {
    4242            var parentOp = GetToken(node.Parent.Symbol);
    4343            if (parentOp != "+" && parentOp != "-" && parentOp != "OR" && parentOp != "XOR")
     
    154154        }
    155155      }
     156    }
     157
     158    private static bool IsOperator(ISymbol sy) {
     159      return sy is Addition ||
     160        sy is Subtraction ||
     161        sy is Multiplication ||
     162        sy is Division ||
     163        sy is And ||
     164        sy is Or ||
     165        sy is Xor;
    156166    }
    157167
Note: See TracChangeset for help on using the changeset viewer.