Skip to content

Commit e842bd1

Browse files
committed
添加 支持Round(double) 公式
1 parent 0a1fb8e commit e842bd1

21 files changed

+24898
-17507
lines changed

csharp/ToolGood.Algorithm2/Internals/ConditionCacheInfo.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ private ProgContext Parse(string exp)
5959
var lexer = new mathLexer(stream);
6060
var tokens = new CommonTokenStream(lexer);
6161
var parser = new mathParser(tokens);
62-
var antlrErrorListener = new AntlrErrorListener();
63-
parser.RemoveErrorListeners();
64-
parser.AddErrorListener(antlrErrorListener);
62+
//var antlrErrorListener = new AntlrErrorListener();
63+
//parser.RemoveErrorListeners();
64+
//parser.AddErrorListener(antlrErrorListener);
6565

6666
var context = parser.prog();
67-
if (antlrErrorListener.IsError) {
68-
LastError = antlrErrorListener.ErrorMsg;
69-
return null;
70-
}
67+
//if (antlrErrorListener.IsError) {
68+
// LastError = antlrErrorListener.ErrorMsg;
69+
// return null;
70+
//}
7171
return context;
7272
} catch (Exception ex) {
7373
LastError = ex.Message + "\r\n" + ex.StackTrace;

csharp/ToolGood.Algorithm2/Internals/DiyNameVisitor.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,6 @@ public object VisitEXPONDIST_fun(mathParser.EXPONDIST_funContext context)
294294
return VisitChildren(context);
295295
}
296296

297-
public object VisitExpr2_fun(mathParser.Expr2_funContext context)
298-
{
299-
return VisitChildren(context);
300-
}
301-
302297
public object VisitEXP_fun(mathParser.EXP_funContext context)
303298
{
304299
return VisitChildren(context);

csharp/ToolGood.Algorithm2/Internals/MathSplitVisitor.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,6 @@ public ConditionTree VisitEXPONDIST_fun(mathParser.EXPONDIST_funContext context)
308308
return Visit_fun(context);
309309
}
310310

311-
public ConditionTree VisitExpr2_fun(mathParser.Expr2_funContext context)
312-
{
313-
return Visit_fun(context);
314-
}
315-
316311
public ConditionTree VisitEXP_fun(mathParser.EXP_funContext context)
317312
{
318313
return Visit_fun(context);

csharp/ToolGood.Algorithm2/Internals/MathVisitor.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,8 +1035,10 @@ public Operand VisitROUND_fun(mathParser.ROUND_funContext context)
10351035
foreach (var item in context.expr()) { var aa = this.Visit(item).ToNumber($"Function ROUND parameter {index++} is error!"); if (aa.IsError) { return aa; } args.Add(aa); }
10361036

10371037
var firstValue = args[0];
1038+
if (args.Count==1) {
1039+
return Operand.Create((double)Math.Round((decimal)firstValue.NumberValue,0, MidpointRounding.AwayFromZero));
1040+
}
10381041
var secondValue = args[1];
1039-
10401042
return Operand.Create((double)Math.Round((decimal)firstValue.NumberValue, secondValue.IntValue, MidpointRounding.AwayFromZero));
10411043
}
10421044
public Operand VisitROUNDDOWN_fun(mathParser.ROUNDDOWN_funContext context)
@@ -3882,10 +3884,6 @@ public Operand VisitGetJsonValue_fun(mathParser.GetJsonValue_funContext context)
38823884
return Operand.Error(" Operator is error!");
38833885
}
38843886

3885-
public Operand VisitExpr2_fun(mathParser.Expr2_funContext context)
3886-
{
3887-
return VisitChildren(context);
3888-
}
38893887

38903888
public Operand VisitDiyFunction_fun(mathParser.DiyFunction_funContext context)
38913889
{

csharp/ToolGood.Algorithm2/math/mathLexer.cs

Lines changed: 2079 additions & 1900 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)