private static MovesString ParseMExpressions(List <Move> acc, string mExpression) { if (mExpression[0] == ']') { return(new MovesString(acc, mExpression)); } if (mExpression[0] == ';') { return(ParseMExpressions(acc, mExpression.Substring(1))); } CharString charString1 = ReadPropertyName(mExpression); string mExpression1 = RemoveSemicolon(charString1.str); MoveString moveString1 = ParseMExpression(mExpression1); acc.Add(moveString1.move); return(ParseMExpressions(acc, moveString1.str)); }
private static MoveString ParseMExpression(string mExpression) { string mExpression1 = RemoveMExpressionPrefix(mExpression); string mExpression2 = RemoveOpeningSquareBracket(mExpression1); CharString charString1 = ReadPropertyName(mExpression2); string mExpression4 = RemoveSemicolon(charString1.str); IntString charString2 = ReadProperty(mExpression4); string mExpression6 = RemoveSemicolon(charString2.str); CharString charString3 = ReadPropertyName(mExpression6); string mExpression8 = RemoveSemicolon(charString3.str); IntString charString4 = ReadProperty(mExpression8); string mExpression10 = RemoveSemicolon(charString4.str); CharString charString5 = ReadPropertyName(mExpression10); string mExpression12 = RemoveSemicolon(charString5.str); IntString charString6 = ReadProperty(mExpression12); string rest = RemoveClosingSquareBracket(charString6.str); int x, y, v; char trueV; if (charString1.c == 'x') { x = charString2.i; } else if (charString3.c == 'x') { x = charString4.i; } else { x = charString6.i; } if (charString1.c == 'y') { y = charString2.i; } else if (charString3.c == 'y') { y = charString4.i; } else { y = charString6.i; } if (charString1.c == 'v') { v = charString2.i; } else if (charString3.c == 'v') { v = charString4.i; } else { v = charString6.i; } trueV = (v == 3) ? 'x' : 'o'; return(new MoveString(new Move(x, y, trueV), rest)); }