Skip to content

Commit 6683758

Browse files
committed
Update FormatTokens conditional, add Token override
1 parent de5e2ed commit 6683758

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

BooleanExpressionParser/Formatters/BasicFormatter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public string FormatTokens(IEnumerable<Token> tokens)
99
{
1010
var sb = new StringBuilder();
1111

12-
foreach (var token in tokens)
12+
foreach (Token token in tokens)
1313
{
1414
string s = token.ToString()!;
15-
if (token is not VariableToken && s.Length > 1) s = $"[[{s}]]";
15+
if (token is OperatorToken && s.Length > 1) s = $"[[{s}]]";
1616
sb.Append(s);
1717
}
1818

BooleanExpressionParser/Formatters/DisplayFormatter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public string FormatTokens(IEnumerable<Token> tokens)
3131
{
3232
var sb = new StringBuilder();
3333

34-
foreach (var token in tokens)
34+
foreach (Token token in tokens)
3535
{
3636
string s = token.ToString()!;
37-
if (token is not VariableToken && s.Length > 1) s = $"[[{s}]]";
37+
if (token is OperatorToken && s.Length > 1) s = $"[[{s}]]";
3838
sb.Append(s);
3939
}
4040

BooleanExpressionParser/Tokens/OperatorToken.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ protected OperatorToken(int precedence)
55
Precedence = precedence;
66
}
77

8-
public int Precedence { get; protected set; }
8+
public int Precedence { get; protected set; }
99
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
abstract class Token { }
1+
abstract class Token
2+
{
3+
public abstract override string ToString();
4+
}

0 commit comments

Comments
 (0)