public UnaryExpression(string Operator, Expression Right, OperatorPosition OperatorPosition = OperatorPosition.Left) : base(Right) { this.Operator = Operator; this.Right = Right; this.OperatorPosition = OperatorPosition; }
public Operator(string symbol, OperatorPosition position, int precedence, Instruction instruction) { this.symbol = symbol; this.position = position; this.precedence = precedence; this.instruction = instruction; }
private UnaryOperator(string symbolFront, string symbolBack, string symbolHat, OperatorPosition position, int yScaleFactor = 1) { SymbolFront = symbolFront; SymbolBack = symbolBack; SymbolHat = symbolHat; Position = position; YScaleFactor = yScaleFactor; }
public static UnaryOperator GetPostfixOperator(string symbol, OperatorPosition position) { if (position == OperatorPosition.Above || position == OperatorPosition.Surrounding) { throw new System.Exception(nameof(position)); } var newOperator = new UnaryOperator(null, symbol, null, position); return(newOperator); }
private static int SortFirstOperators(OperatorPosition x, OperatorPosition y) { if (x.position == y.position) { return(0); } if (x.position > y.position) { return(1); } return(-1); }
Operator Add(Instruction instruction, string symbol, OperatorPosition position, int precidence) { var newOperator = new Operator(symbol, position, precidence, instruction); if (position != OperatorPosition.Infix) { newOperator.spaceAfter = false; newOperator.spaceBefore = false; } this.Add(instruction, newOperator); return(newOperator); }
/// <summary> /// Initializes a new instance of the OperatorConfig class. /// </summary> public OperatorConfig(string id, string caption, OperatorPosition position, string info, string confirmData, string iconClass, MarcoConfigItem content) { TkDebug.AssertArgumentNullOrEmpty(id, "id", null); TkDebug.AssertArgumentNullOrEmpty(caption, "caption", null); Id = id; Caption = new MultiLanguageText(caption); Position = position; Info = info; if (!string.IsNullOrEmpty(confirmData)) { ConfirmData = new MultiLanguageText(confirmData); } IconClass = iconClass; Content = content; }
/// <summary> /// Converts the input equation string into a SIL_Equation recursive datastructure /// </summary> /// <param name="equation">basic input eqaution, must NOT contain any brackets!</param> /// <returns>Converted equation class which can be calculated</returns> static ISILObject ProcessEquation(string functionspace, string equationString, List <ISILObject> equations) { //always returns equation if (!SIL_Math.IsEquation(equationString)) { return(Retrieve_SIL_Object(functionspace, equationString, equations)); } char[] separators = { '/', '*', '+', '-', '&', '|', '<', '>', '=' }; string leftVar = "", rightVar = "", equationSubstring = ""; int leftIndex = 0, rightIndex = 0; SILEquation equation = new SILEquation(); equationString = equationString.Trim(); //multiplication and division needs to be taken care of first! List <OperatorPosition> firstPos = new List <OperatorPosition>(); for (int i = 0; i < separators.Length; i++) { int pos = equationString.IndexOf(separators[i]); if (pos >= 0) { OperatorPosition op = new OperatorPosition(); op.position = pos; op.c = separators[i]; firstPos.Add(op); } if (i == 1 && firstPos.Count > 0) { break; } } firstPos.Sort(SortFirstOperators); equation.Operation = ConvertToOperator(firstPos[0].c); //now find the two terms this operation applies to and build new SIL_Equation class //find left variable for (int i = firstPos[0].position - 1; i >= 0; i--) { leftIndex = i; if (SIL_Math.IsOperator(equationString[i])) { if (i == 1) { leftIndex--; //allow negative numbers } break; } leftVar += equationString[i]; } leftVar = leftVar.Trim(); if (leftVar.Length == 0) { leftVar = "0"; } else { leftVar = Reverse(leftVar); //reverse the string b/c I read it from right to left } equation.Argument1 = Retrieve_SIL_Object(functionspace, leftVar, equations); //find right variable for (int i = firstPos[0].position + 1; i < equationString.Length; i++) { if (SIL_Math.IsOperator(equationString[i])) { break; } rightIndex = i; rightVar += equationString[i]; } rightIndex++; rightVar = rightVar.Trim(); if (rightVar.Length == 0) { rightVar = "0"; } equation.Argument2 = Retrieve_SIL_Object(functionspace, rightVar, equations); equationSubstring = equationString.Substring(leftIndex, rightIndex - leftIndex); string leftPart = leftIndex > 0 ? equationString.Substring(0, leftIndex + 1) : ""; int rightLength = equationString.Length - rightIndex; string rightPart = rightLength > 0 ? equationString.Substring(rightIndex, rightLength) : ""; equationString = leftPart + "{" + equations.Count.ToString() + "}" + rightPart; equations.Add(equation); return(ProcessEquation(functionspace, equationString, equations)); }
public OperationAttribute(Operator op, OperatorPosition position = OperatorPosition.Infix) { Op = op; Position = position; }
public OpAttribute(string commonName, string operatorRepresentation, OperatorPosition position = OperatorPosition.Infix) { CommonName = commonName; OperatorRepresentation = operatorRepresentation; Position = position; }
private BinaryOperator(string symbol, OperatorPosition position) { Symbol = symbol; Position = position; }
public OperatorConfig(string id, string caption, OperatorPosition position, string info, MarcoConfigItem content) : this(id, caption, position, info, null, null, content) { }