@@ -8,20 +8,26 @@ namespace ToolGood.Algorithm.Internals.Visitors
88{
99 internal sealed class MathSplitVisitor2 : AbstractParseTreeVisitor < CalculateTree > , ImathVisitor < CalculateTree >
1010 {
11+ private bool hasBracket = false ;
12+
1113 public CalculateTree VisitProg ( mathParser . ProgContext context )
1214 {
15+ hasBracket = false ;
1316 return context . expr ( ) . Accept ( this ) ;
1417 }
1518
1619 public CalculateTree VisitBracket_fun ( mathParser . Bracket_funContext context )
1720 {
21+ hasBracket = true ;
1822 return context . expr ( ) . Accept ( this ) ;
1923 }
2024 public CalculateTree VisitMulDiv_fun ( mathParser . MulDiv_funContext context )
2125 {
2226 var tree = new CalculateTree {
23- Nodes = new List < CalculateTree > ( )
27+ Nodes = new List < CalculateTree > ( ) ,
28+ HasBracket = hasBracket ,
2429 } ;
30+ hasBracket = false ;
2531 var exprs = context . expr ( ) ;
2632 var t = context . op . Text ;
2733 if ( CharUtil . Equals ( t , '*' ) ) {
@@ -35,14 +41,16 @@ public CalculateTree VisitMulDiv_fun(mathParser.MulDiv_funContext context)
3541 tree . Nodes . Add ( exprs [ 1 ] . Accept ( this ) ) ;
3642 tree . Start = context . Start . StartIndex ;
3743 tree . End = context . Stop . StopIndex ;
38- tree . ConditionString = context . GetText ( ) ;
44+ tree . Text = context . GetText ( ) ;
3945 return tree ;
4046 }
4147 public CalculateTree VisitAddSub_fun ( mathParser . AddSub_funContext context )
4248 {
4349 var tree = new CalculateTree {
44- Nodes = new List < CalculateTree > ( )
50+ Nodes = new List < CalculateTree > ( ) ,
51+ HasBracket = hasBracket ,
4552 } ;
53+ hasBracket = false ;
4654 var exprs = context . expr ( ) ;
4755 var t = context . op . Text ;
4856 if ( CharUtil . Equals ( t , '+' ) ) {
@@ -56,7 +64,7 @@ public CalculateTree VisitAddSub_fun(mathParser.AddSub_funContext context)
5664 tree . Nodes . Add ( exprs [ 1 ] . Accept ( this ) ) ;
5765 tree . Start = context . Start . StartIndex ;
5866 tree . End = context . Stop . StopIndex ;
59- tree . ConditionString = context . GetText ( ) ;
67+ tree . Text = context . GetText ( ) ;
6068 return tree ;
6169 }
6270
@@ -66,7 +74,7 @@ public CalculateTree Visit_fun(ParserRuleContext context)
6674 var tree = new CalculateTree {
6775 Start = context . Start . StartIndex ,
6876 End = context . Stop . StopIndex ,
69- ConditionString = context . GetText ( )
77+ Text = context . GetText ( )
7078 } ;
7179 return tree ;
7280 }
@@ -885,7 +893,7 @@ public CalculateTree VisitPRODUCT_fun(mathParser.PRODUCT_funContext context)
885893 {
886894 return Visit_fun ( context ) ;
887895 }
888-
896+
889897 public CalculateTree VisitPROPER_fun ( mathParser . PROPER_funContext context )
890898 {
891899 return Visit_fun ( context ) ;
0 commit comments