-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChecker.cs
More file actions
66 lines (60 loc) · 2.04 KB
/
Checker.cs
File metadata and controls
66 lines (60 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using MathParser.DataTypes;
namespace MathParser
{
internal static class Checker
{
/// <summary>
/// Checks the correct matrix syntax.
/// </summary>
/// <returns>The syntax.</returns>
/// <param name="matrixString">Matrix string.</param>
/// <param name="FlagStart">Flag start.</param>
/// <param name="FlagEnd">Flag end.</param>
/// <param name="FlagElementSeperation">Flag element seperation.</param>
/// <param name="FlagRowSeperation">Flag row seperation.</param>
public static bool MatrixSyntax(string matrixString, string FlagStart, string FlagEnd, string FlagElementSeperation, string FlagRowSeperation)
{
string givenExpression = matrixString.Trim();
bool MatrixAlright = true;
if (givenExpression.Contains(FlagStart) && givenExpression.Contains(FlagEnd))
{
if (givenExpression.StartsWith(FlagStart) && givenExpression.EndsWith(FlagEnd))
{
int lenghtS = givenExpression.Replace(FlagStart, "").Length;
int lenghtE = givenExpression.Replace(FlagEnd, "").Length;
if ((lenghtE == givenExpression.Length - 1) && (lenghtE == givenExpression.Length - 1))
{ MatrixAlright = true ;}
else {
MatrixAlright = false;
}
}
else {
MatrixAlright = false;
}
}
else {
MatrixAlright = false;
}
return MatrixAlright;
} // end matrix syntac checker
public static List<string> KeyWords;
public static string OperatorList;
public static Dictionary<string, MathParserExpression> Constants = new Dictionary<string, MathParserExpression>();
public static Dictionary<string, MathParserExpression> History = new Dictionary<string, MathParserExpression> ();
public static List<string> LeftRightFunctionKeywords = new List<string>();
public static bool ifContainOperation(string Exp, string theBasicOperators)
{
string dumy = Exp;
foreach (char op in theBasicOperators) {
dumy = dumy.Replace(new String(op,1),"");
}
if (dumy.Length != Exp.Length) {
return true;
} else {
return false;
}
}
}
}