Unable to parse variable names with numbers correctly
Closed this issue · 3 comments
rainmakerho commented
The version I use:
AngouriMath 1.3
Unexpected behaviour or bug:
I try to parse the expression "X1+X2+H2Ca2", output was "X, H and Ca" .
I expect the output should be "X1, X2 and H2Ca2".
Thanks.
Entity expr = "X1+X2+H2Ca2";
foreach (var v in expr.Vars)
{
Console.WriteLine(v.Name);
}
Output
X
H
Ca
Expect Output
X1
X2
H2Ca2
Happypig375 commented
Use Settings.ExplicitParsingOnly
AngouriMath/Sources/AngouriMath/AngouriMath/Convenience/MathS.cs
Lines 5262 to 5292 in 1ae631f
rainmakerho commented
I add Settings.ExplicitParsingOnly.Set(true)
will cause There should be an operator between [@0,0:0='X',<123>,1:0] and [@1,1:1='1',<120>,1:1]
error.
using (var _ = Settings.ExplicitParsingOnly.Set(true))
{
Entity expr = "X1+X2+H2Ca2";
foreach (var v in expr.Vars)
{
Console.WriteLine(v.Name);
}
}
AngouriMath.Core.Exceptions.MissingOperatorParseException
HResult=0x80131500
Message=There should be an operator between [@0,0:0='X',<123>,1:0] and [@1,1:1='1',<120>,1:1]
Source=AngouriMath
StackTrace:
於 AngouriMath.Core.Parser.<>c.<Parse>b__4_3(MissingOperator missingOperator)
於 HonkSharp.Functional.Either`3.Switch[TOut](Func`2 case1, Func`2 case2, Func`2 case3)
於 AngouriMath.Core.Parser.<>c.<Parse>b__4_1(Failure`1 failure)
於 HonkSharp.Functional.Either`2.Switch[TOut](Func`2 case1, Func`2 case2)
於 AngouriMath.Core.Parser.Parse(String source)
於 HonkSharp.Fluency.ControlExtensions.LazyEval`2.get_Value()
於 System.Runtime.CompilerServices.ConditionalWeakTable`2.GetValue(TKey key, CreateValueCallback createValueCallback)
於 AngouriMath.Entity.op_Implicit(String expr)
WhiteBlackGoose commented
Yes because you need to use underscore x_1
instead of x1