Skip to content

Commit 74ea82a

Browse files
committed
修改
1 parent 0c0b8b6 commit 74ea82a

File tree

8 files changed

+5607
-5574
lines changed

8 files changed

+5607
-5574
lines changed

csharp/ToolGood.Algorithm2.Test/AlgorithmEngine/AlgorithmEngineTest.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,21 @@ public void Test()
105105
var value3 = engine.TryEvaluate("-7 < -2", false);
106106
Assert.AreEqual(value3, true);
107107

108+
var t1 = engine.TryEvaluate("-7 < -2 ?1 : 2", 0);
109+
Assert.AreEqual(t1, 1);
110+
t1 = engine.TryEvaluate("-7 < -2 ?1 : 2", 0);
111+
t1 = engine.TryEvaluate("-7 < -2 ?1 :2", 0);
112+
Assert.AreEqual(t1, 1);
113+
t1 = engine.TryEvaluate("-7 < -2 ? 1 : 2", 0);
114+
Assert.AreEqual(t1, 1);
115+
t1 = engine.TryEvaluate("-7 < -2 ?1 : 2", 0);
116+
Assert.AreEqual(t1, 1);
108117

109-
var t1 = engine.TryEvaluate("-7 < -2?1:2", 1);
118+
t1 = engine.TryEvaluate("-7 < -2 ?1 : 2", 0);
110119
Assert.AreEqual(t1, 1);
120+
121+
t1 = engine.TryEvaluate("(!(-7 < -2))?1:2", 0);
122+
Assert.AreEqual(t1, 2);
111123
}
112124

113125
[Test]

csharp/ToolGood.Algorithm2.Test/AlgorithmEngine/AlgorithmEngineTest_dateTime.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ public void DATEVALUE_Test()
1515
AlgorithmEngine engine = new AlgorithmEngine();
1616
var dt = engine.TryEvaluate("DATEVALUE('2016-01-01')", DateTime.MinValue);
1717
Assert.AreEqual(dt, new DateTime(2016, 1, 1));
18+
dt = engine.TryEvaluate("DATEVALUE('2016-01-01')", DateTime.MinValue);
19+
Assert.AreEqual(dt, new DateTime(2016, 1, 1));
20+
21+
1822
}
1923
[Test]
2024
public void TIMEVALUE_test()

csharp/ToolGood.Algorithm2.Test/AlgorithmEngine/AlgorithmEngineTest_flow.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ public void If_Test()
1818
t = engine.TryEvaluate("if(1=1,1)", 0);
1919
Assert.AreEqual(1, t);
2020

21+
t = engine.TryEvaluate("if(1=1,1)", 0);
22+
Assert.AreEqual(1, t);
23+
24+
2125
t = engine.TryEvaluate("if(3,1,2)", 0);
2226
Assert.AreEqual(1, t);
2327
t = engine.TryEvaluate("if('1',1,2)", 0);

csharp/ToolGood.Algorithm2/Internals/CaseChangingCharStream.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,27 @@ public int LA(int i)
6969
}
7070

7171
char o = (char)c;
72-
if (o == '(') {
73-
o = '(';
74-
} else if (o == ')') {
75-
o = ')';
76-
} else if (o == ',') {
77-
o = ',';
78-
} else if (o == '【') {
79-
o = '[';
80-
} else if (o == '】') {
81-
o = ']';
82-
} else if (o == '‘') {
72+
if (o == '‘') {
8373
o = '\'';
8474
} else if (o == '’') {
8575
o = '\'';
8676
} else if (o == '“') {
8777
o = '"';
8878
} else if (o == '”') {
8979
o = '"';
80+
} else if (o == '〔') {
81+
o = '(';
82+
} else if (o == '〕') {
83+
o = ')';
9084
}
9185

92-
return (int)char.ToUpperInvariant(o);
86+
if (c == 12288) {
87+
o = (char)32;
88+
} else if (c > 65280 && c < 65375) {
89+
o = (char)(c - 65248);
90+
}
9391

92+
return (int)char.ToUpperInvariant(o);
9493
}
9594

9695
public int Mark()

csharp/ToolGood.Algorithm2/math/mathLexer.cs

Lines changed: 1743 additions & 1756 deletions
Large diffs are not rendered by default.

csharp/ToolGood.Algorithm2/math/mathParser.2.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3526,7 +3526,7 @@ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor)
35263526
}
35273527
public partial class STRING_funContext : ExprContext
35283528
{
3529-
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING() { return GetToken(32, 0); }
3529+
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING() { return GetToken(28, 0); }
35303530
public STRING_funContext(ExprContext context) { CopyFrom(context); }
35313531
[System.Diagnostics.DebuggerNonUserCode]
35323532
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor)
@@ -3538,8 +3538,8 @@ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor)
35383538
}
35393539
public partial class NUM_funContext : ExprContext
35403540
{
3541-
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NUM() { return GetToken(31, 0); }
3542-
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SUB() { return GetToken(27, 0); }
3541+
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NUM() { return GetToken(27, 0); }
3542+
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SUB() { return GetToken(26, 0); }
35433543
public NUM_funContext(ExprContext context) { CopyFrom(context); }
35443544
[System.Diagnostics.DebuggerNonUserCode]
35453545
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor)
@@ -3551,13 +3551,13 @@ public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor)
35513551
}
35523552
public partial class PARAMETER_funContext : ExprContext
35533553
{
3554-
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAMETER() { return GetToken(240, 0); }
3554+
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAMETER() { return GetToken(236, 0); }
35553555
[System.Diagnostics.DebuggerNonUserCode]
35563556
public ExprContext expr()
35573557
{
35583558
return GetRuleContext<ExprContext>(0);
35593559
}
3560-
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAMETER2() { return GetToken(241, 0); }
3560+
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAMETER2() { return GetToken(237, 0); }
35613561
public PARAMETER_funContext(ExprContext context) { CopyFrom(context); }
35623562
[System.Diagnostics.DebuggerNonUserCode]
35633563
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor)
@@ -3573,7 +3573,7 @@ public ExprContext[] expr()
35733573
{
35743574
return GetRuleContexts<ExprContext>();
35753575
}
3576-
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAMETER() { return GetToken(240, 0); }
3576+
[System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARAMETER() { return GetToken(236, 0); }
35773577
public DiyFunction_funContext(ExprContext context) { CopyFrom(context); }
35783578
[System.Diagnostics.DebuggerNonUserCode]
35793579
public override TResult Accept<TResult>(IParseTreeVisitor<TResult> visitor)

0 commit comments

Comments
 (0)