Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using static System.String;
- using static System.Char;
- using static System.Int32;
- using static Analyzer.KindsofErrors;
- namespace Analyzer
- {
- class Graph
- {
- private enum State
- {
- E, S, S1, S2, S3, S4, S5, S6, S7, S8, F, F0, F00,
- D, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11,
- G, /*B1, B2, B3, B4, B5, B6, B7, B8, FL1, FL2, FL3, FL4, C1, C2, C3, C4, C5, C6, C7, C8,*/
- G1, B11, B22, B33, B44, B55, B66, B77, B88, FL11, FL22, FL33, FL44, C11, C22, C33, C44, C55, C66, C77, C88,
- };
- /// <summary>
- ///
- /// </summary>
- /// <param name="str">Строка, подаваемая на вход</param>
- /// <param name="error">Ошибка</param>
- public void Analyz(string str, out KindsofErrors error, out VariableAndConstList list)
- {
- error = new KindsofErrors();
- list = new VariableAndConstList();
- int i = 0; //текущая позиция в строке
- char ch; //текущий символ строки
- int length = str.Length;
- State state = State.S;
- int maxlen = 8;
- int delta = 1;
- string id = ""; int minint = -32769; int maxint = 32768;
- string type = "";
- string int_numb_char = "";
- string int_numb_left = "";
- string int_numb_right = "";
- bool array = false;
- while ((state != State.F) && (state != State.E) && (i < length))
- {
- ch = str[i]; i++;
- switch (state)
- {
- case State.S:
- {
- if (ch == ' ')
- state = State.S;
- else if (ch == 'd')
- state = State.S1;
- else
- {
- error = new KindsofErrors(Error.DD, i - 1);
- state = State.E;
- }
- break;
- }
- case State.S1:
- {
- if (ch == 'c')
- state = State.S2;
- else if (ch == 'e')
- state = State.S4;
- else
- {
- error = new KindsofErrors(Error.DD, i - 2);
- state = State.E;
- }
- break;
- }
- case State.S2:
- {
- if (ch == 'l')
- state = State.S3;
- else
- {
- error = new KindsofErrors(Error.DC, i - 3);
- state = State.E;
- }
- break;
- }
- case State.S3:
- {
- if (ch == ' ')
- state = State.D;
- else
- {
- error = new KindsofErrors(Error.Space, i - 3);
- state = State.E;
- }
- break;
- }
- case State.S4:
- {
- if (ch == 'c')
- state = State.S5;
- else
- {
- error = new KindsofErrors(Error.DE, i - 4);
- state = State.E;
- }
- break;
- }
- case State.S5:
- {
- if (ch == 'l')
- state = State.S6;
- else
- {
- error = new KindsofErrors(Error.DE, i - 5);
- state = State.E;
- }
- break;
- }
- case State.S6:
- {
- if (ch == 'a')
- state = State.S7;
- else
- {
- error = new KindsofErrors(Error.DE, i - 6);
- state = State.E;
- }
- break;
- }
- case State.S7:
- {
- if (ch == 'r')
- state = State.S8;
- else
- {
- error = new KindsofErrors(Error.DE, i - 7);
- state = State.E;
- }
- break;
- }
- case State.S8:
- {
- if (ch == 'e')
- state = State.S3;
- else
- {
- error = new KindsofErrors(Error.DE, i - 8);
- state = State.E;
- }
- break;
- }
- case State.D:
- {
- if (ch == ' ')
- state = State.D;
- else if (((ch >= 'a') && (ch <= 'z')) || (ch == '_'))
- {
- state = State.D1;
- id = id + ch;
- }
- else if (ch == '(')
- state = State.D2;
- else
- {
- error = new KindsofErrors(Error.IDOrOpeningBracket, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D1:
- {
- //char.IsLetterOrDigit
- if (((ch >= 'a') && (ch <= 'z')) || (ch == '_') || ((ch >= '0') && (ch <= '9')))
- {
- if (id.Length < maxlen)
- {
- id = id + ch;
- state = State.D1;
- }
- else
- {
- error = new KindsofErrors(Error.IDLength, i - 1);
- state = State.E;
- }
- }
- else if (ch == '(')
- {
- if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
- {
- error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
- state = State.E;
- }
- else
- {
- list.AddLastID(id);
- state = State.L1;
- }
- id = "";
- }
- else if (ch == ',')
- {
- if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
- {
- error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
- state = State.E;
- }
- else
- {
- list.AddLastID(id);
- state = State.D;
- }
- id = "";
- }
- else if (ch == ';')
- {
- if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
- {
- error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
- state = State.E;
- }
- else
- {
- list.AddLastID(id);
- state = State.F;
- }
- id = "";
- }
- else if (ch == ' ')
- {
- if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
- {
- error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
- state = State.E;
- }
- else
- {
- list.AddLastID(id);
- state = State.G;
- }
- id = "";
- }
- else
- { //Как учесть ошибки в идентификаторе?
- error = new KindsofErrors(Error.OpeningBracketOrEndOfLine, i - 1);
- state = State.E;
- }
- break;
- }
- case State.G:
- {
- if (ch == ' ')
- state = State.G;
- else if (ch == '(')
- state = State.L1;
- else if (ch == ';')
- state = State.F;
- else if (ch == 'b')
- state = State.B11;
- else if (ch == 'f')
- state = State.FL11;
- else if (ch == 'c')
- state = State.C11;
- else
- {
- error = new KindsofErrors(Error.OpeningBracketOrTypesOfDataOrEndOfLine, i - 1);
- state = State.E;
- }
- break;
- }
- case State.L1:
- {
- if (ch == ' ')
- state = State.L1;
- else if ((ch >= '0') && (ch <= '9'))
- {
- int_numb_left = int_numb_left + ch;
- state = State.L3;
- }
- else if (ch == '-')
- {
- int_numb_left = int_numb_left + ch;
- state = State.L2;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- break;
- }
- case State.L2:
- {
- if ((ch >= '0') && (ch <= '9'))
- {
- state = State.L3;
- int_numb_left = int_numb_left + ch;
- }
- else
- {
- error = new KindsofErrors(Error.IntegerWithoutMinus, i - 1);
- state = State.E;
- }
- break;
- }
- case State.L3:
- {
- if ((ch >= '0') && (ch <= '9'))
- {
- state = State.L3;
- int_numb_left = int_numb_left + ch;
- }
- else if (ch == ' ')
- {
- TryParse(int_numb_left, out int int_numb_left1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
- {
- delta = int_numb_left1 * delta;
- state = State.L4;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- //int_numb_left = "";
- }
- else if (ch == ',')
- {
- TryParse(int_numb_left, out int int_numb_left1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
- {
- delta = int_numb_left1 * delta;
- state = State.L1;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_left = "";
- }
- else if (ch == ')')
- {
- TryParse(int_numb_left, out int int_numb_left1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
- {
- delta = int_numb_left1 * delta;
- state = State.L5;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_left = "";
- }
- else if (ch == ':')
- {
- TryParse(int_numb_left, out int int_numb_left1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
- {
- delta = int_numb_left1 * delta;
- state = State.L6;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- //int_numb_left = ""; СЧИТАЛАСЬ ЛЕВАЯ КОНСТАНТА
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.CloseBracketOrCommaOrRightConstant, i - 1); //Ожидалась закрывающая скобка, запятая или правая константа размерности dim
- state = State.E;
- }
- break;
- }
- case State.L4:
- {
- if (ch == ' ')
- state = State.L4;
- else if (ch == ')')
- state = State.L5;
- else if (ch == ',')
- state = State.L1;
- else if (ch == ':')
- state = State.L6;
- else
- {
- error = new KindsofErrors(Error.CloseBracketOrTwoPoints, i - 1);
- state = State.E;
- }
- break;
- }
- case State.L5:
- {
- if (ch == ' ')
- {
- int_numb_left = ""; int_numb_right = "";
- state = State.L11;
- }
- else if (ch == ',')
- {
- int_numb_left = ""; int_numb_right = "";
- state = State.D;
- }
- else if (ch == ';')
- state = State.F;
- else
- {
- error = new KindsofErrors(Error.CommaOrEndLine, i - 1);
- state = State.E;
- }
- break;
- }
- case State.L6:
- {
- if (ch == ' ')
- state = State.L6;
- else if ((ch >= '0') && (ch <= '9'))
- {
- state = State.L7;
- int_numb_right = int_numb_right + ch;
- }
- else if (ch == '-')
- {
- state = State.L8;
- int_numb_right = int_numb_right + ch;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- break;
- }
- case State.L7:
- {
- if ((ch >= '0') && (ch <= '9'))
- {
- state = State.L7;
- int_numb_right = int_numb_right + ch;
- }
- else if (ch == ' ')
- {
- TryParse(int_numb_right, out int int_numb_right1); TryParse(int_numb_left, out int int_numb_left1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if ((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint))
- {
- if (int_numb_left1 < int_numb_right1)
- {
- delta = int_numb_left1 * delta;
- state = State.L9;
- }
- else
- {
- error = new KindsofErrors(Error.IsMoreThan, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_left = "";
- int_numb_right = "";
- }
- else if (ch == ',')
- {
- TryParse(int_numb_right, out int int_numb_right1); TryParse(int_numb_left, out int int_numb_left1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if ((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint))
- {
- if ((int_numb_right1 > minint) && (int_numb_right1 < maxint))
- {
- delta = int_numb_left1 * delta;
- state = State.L1;
- }
- else
- {
- error = new KindsofErrors(Error.IsMoreThan, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_left = "";
- int_numb_right = "";
- }
- else if (ch == ')')
- {
- TryParse(int_numb_right, out int int_numb_right1); TryParse(int_numb_left, out int int_numb_left1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if ((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint))
- {
- if (((int_numb_left1 < int_numb_right1)))
- {
- delta = int_numb_left1 * delta;
- state = State.L10;
- }
- else
- {
- error = new KindsofErrors(Error.IsMoreThan, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_left = "";
- int_numb_right = "";
- }
- else
- {
- error = new KindsofErrors(Error.CloseBracketOrCommaOrRightConstant, i - 1); //Ожидалась закрывающая скобка, запятая или правая константа размерности dim
- state = State.E;
- }
- break;
- }
- case State.L8:
- {
- if ((ch >= '0') && (ch <= '9'))
- {
- state = State.L7;
- int_numb_right = int_numb_right + ch;
- }
- else
- {
- error = new KindsofErrors(Error.IntegerWithoutMinus, i - 1);
- state = State.E;
- }
- break;
- }
- case State.L9:
- {
- if (ch == ' ')
- state = State.L9;
- else if (ch == ')')
- state = State.L10;
- else if (ch == ',')
- state = State.L1;
- else
- {
- error = new KindsofErrors(Error.CloseBracketOrComma, i - 1);
- state = State.E;
- }
- break;
- }
- case State.L10:
- {
- if (ch == ' ')
- state = State.L11;
- else if (ch == ',')
- state = State.D;
- else
- {
- error = new KindsofErrors(Error.IntegerWithoutMinusOrSpace, i - 1);
- state = State.E;
- }
- break;
- }
- case State.L11:
- {
- if (ch == ' ')
- state = State.L11;
- else if (ch == 'b')
- state = State.B11;
- else if (ch == 'f')
- state = State.FL11;
- else if (ch == 'c')
- state = State.C11;
- else if (ch == ',')
- state = State.D;
- else
- {
- error = new KindsofErrors(Error.TypesOfDataOrSpaceOrComma, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D2:
- {
- if (ch == ' ')
- state = State.D2;
- else if (((ch >= 'a') && (ch <= 'z')) || (ch == '_'))
- {
- id = id + ch;
- state = State.D3;
- }
- else
- {
- error = new KindsofErrors(Error.ID, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D3:
- {
- if (((ch >= 'a') && (ch <= 'z')) || (ch == '_') || ((ch >= '0') && (ch <= '9')))
- if (id.Length < maxlen)
- {
- id = id + ch;
- state = State.D3;
- }
- else
- {
- error = new KindsofErrors(Error.IDLength, i - 1);
- state = State.E;
- }
- else if (ch == '(')
- {
- if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
- {
- error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
- state = State.E;
- }
- else
- {
- list.AddLastID(id);
- state = State.D5;
- }
- id = "";
- }
- else if (ch == ')')
- {
- if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
- {
- error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
- state = State.E;
- }
- else
- {
- list.AddLastID(id);
- state = State.G1;
- }
- id = "";
- }
- else if (ch == ',')
- {
- if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
- {
- error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
- state = State.E;
- }
- else
- {
- list.AddLastID(id);
- state = State.D2;
- }
- id = "";
- }
- else if (ch == ' ')
- {
- if ((Compare(id, "dcl") == 0) || (Compare(id, "declare") == 0) || (Compare(id, "bin") == 0) || (Compare(id, "fixed") == 0) || (Compare(id, "float") == 0) || (Compare(id, "char") == 0))
- {
- error = new KindsofErrors(Error.Keyword, i - id.Length - 1);
- state = State.E;
- }
- else
- {
- list.AddLastID(id);
- state = State.D4;
- }
- id = "";
- }
- else
- {
- error = new KindsofErrors(Error.BracketOrComma, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D4:
- {
- if (ch == ' ')
- state = State.D4;
- else if (ch == ',')
- state = State.D2;
- else if (ch == '(')
- state = State.D5;
- else if (ch == ')')
- state = State.G1;
- else
- {
- error = new KindsofErrors(Error.OpenBracketOrComma, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D5:
- {
- if (ch == ' ')
- state = State.D5;
- else if ((ch >= '0') && (ch <= '9'))
- {
- state = State.D7;
- int_numb_left = int_numb_left + ch;
- }
- else if (ch == '-')
- {
- state = State.D6;
- int_numb_left = int_numb_left + ch;
- }
- else //Вставить проверку на максдлину числа(в диапазоне от -30к до 30к)
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D6:
- {
- if ((ch >= '0') && (ch <= '9'))
- {
- state = State.D7;
- int_numb_left = int_numb_left + ch;
- }
- else
- {
- error = new KindsofErrors(Error.IntegerWithoutMinus, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D7:
- {
- if ((ch >= '0') && (ch <= '9'))
- {
- state = State.D7;
- int_numb_left = int_numb_left + ch;
- }
- else if (ch == ' ')
- {
- TryParse(int_numb_left, out int int_numb_left1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
- {
- delta = int_numb_left1 * delta;
- state = State.D8;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- //int_numb_left = "";
- }
- else if (ch == ',')
- {
- TryParse(int_numb_left, out int int_numb_left1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
- {
- delta = int_numb_left1 * delta;
- state = State.D5;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_left = "";
- }
- else if (ch == ':')
- {
- TryParse(int_numb_left, out int int_numb_left1);
- if ((int_numb_left1 > minint) && (int_numb_left1 < maxint))
- {
- delta = int_numb_left1 * delta;
- state = State.D9;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- //int_numb_left = "";
- }
- else
- {
- error = new KindsofErrors(Error.CommaOrRightConstant, i - 1); //Ожидалась запятая или правая константа размерности dim
- state = State.E;
- }
- break;
- }
- case State.D8:
- {
- if (ch == ' ')
- state = State.D8;
- else if (ch == ',')
- state = State.D5;
- else if (ch == ':')
- state = State.D9;
- else
- {
- error = new KindsofErrors(Error.CommaOrTwoPoints, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D9:
- {
- if (ch == ' ')
- state = State.D9;
- else if ((ch >= '0') && (ch <= '9'))
- {
- state = State.D11;
- int_numb_right = int_numb_right + ch;
- }
- else if (ch == '-')
- {
- state = State.D10;
- int_numb_right = int_numb_right + ch;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D10:
- {
- if ((ch >= '0') && (ch <= '9'))
- {
- int_numb_right = int_numb_right + ch;
- state = State.D11;
- }
- else
- {
- error = new KindsofErrors(Error.IntegerWithoutMinus, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D11:
- {
- if ((ch >= '0') && (ch <= '9'))
- {
- int_numb_right = int_numb_right + ch;
- state = State.D11;
- }
- else if (ch == ' ')
- {
- TryParse(int_numb_left, out int int_numb_left1); TryParse(int_numb_right, out int int_numb_right1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if (((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint)))
- {
- if (int_numb_left1 < int_numb_right1)
- {
- delta = (int_numb_right1 - int_numb_left1 + 1) * delta;
- state = State.D12;
- }
- else
- {
- error = new KindsofErrors(Error.IsMoreThan, i - 1);
- state = State.E;
- }
- }
- else{
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else{
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_right = "";
- int_numb_left = "";
- }
- else if (ch == ')')
- {
- TryParse(int_numb_left, out int int_numb_left1); TryParse(int_numb_right, out int int_numb_right1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if (((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint)))
- {
- if (int_numb_left1 < int_numb_right1)
- {
- delta = (int_numb_right1 - int_numb_left1 + 1) * delta;
- state = State.D13;
- }
- else
- {
- error = new KindsofErrors(Error.IsMoreThan, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_right = "";
- int_numb_left = "";
- }
- else if (ch == ',')
- {
- TryParse(int_numb_left, out int int_numb_left1); TryParse(int_numb_right, out int int_numb_right1);
- if (((int_numb_left == "0") && (int_numb_left1 == 0)) || ((int_numb_left != "0") && (int_numb_left1 != 0)))
- {
- if (((int_numb_right1 > minint) && (int_numb_right1 < maxint) && (int_numb_left1 > minint) && (int_numb_left1 < maxint)))
- {
- if ((int_numb_left1 < int_numb_right1))
- {
- delta = (int_numb_right1 - int_numb_left1 + 1) * delta;
- state = State.D5;
- }
- else
- {
- error = new KindsofErrors(Error.IsMoreThan, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_right = "";
- int_numb_left = "";
- }
- else
- {
- error = new KindsofErrors(Error.CloseBracketOrComma, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D12:
- {
- if (ch == ' ')
- state = State.D12;
- else if (ch == ')')
- state = State.D13;
- else if (ch == ',')
- state = State.D5;
- else
- {
- error = new KindsofErrors(Error.CloseBracketOrComma, i - 1);
- state = State.E;
- }
- break;
- }
- case State.D13:
- {
- if (ch == ' ')
- state = State.D13;
- else if (ch == ')')
- state = State.G1;
- else if (ch == ',')
- state = State.D2;
- else
- {
- error = new KindsofErrors(Error.CloseBracketOrComma, i - 1);
- state = State.E;
- }
- break;
- }
- case State.G1:
- {
- if (ch == ' ')
- state = State.G1;
- else if (ch == 'b')
- {
- type = type + ch;
- state = State.B11;
- }
- else if (ch == 'f')
- {
- type = type + ch;
- state = State.FL11;
- }
- else if (ch == 'c')
- {
- type = type + ch;
- state = State.C11;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfData, i - 1);
- state = State.E;
- }
- break;
- }
- case State.FL11:
- {
- if (ch == 'l')
- {
- type = type + ch;
- state = State.FL22;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataFloat, i - 2);
- state = State.E;
- }
- break;
- }
- case State.FL22:
- {
- if (ch == 'o')
- {
- type = type + ch;
- state = State.FL33;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataFloat, i - 3);
- state = State.E;
- }
- break;
- }
- case State.FL33:
- {
- if (ch == 'a')
- {
- type = type + ch;
- state = State.FL44;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataFloat, i - 4);
- state = State.E;
- }
- break;
- }
- case State.FL44:
- {
- if (ch == 't')
- {
- type = type + ch;
- state = State.F00;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataFloat, i - 5);
- state = State.E;
- }
- break;
- }
- case State.B11:
- {
- if (ch == 'i')
- {
- type = type + ch;
- state = State.B22;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 1);
- state = State.E;
- }
- break;
- }
- case State.B22:
- {
- if (ch == 'n')
- {
- type = type + ch;
- state = State.B33;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 2);
- state = State.E;
- }
- break;
- }
- case State.B33:
- {
- if (ch == ' ')
- {
- type = type + ch;
- state = State.B44;
- }
- else
- {
- error = new KindsofErrors(Error.Space, i - 1);
- state = State.E;
- }
- break;
- }
- case State.B44:
- {
- if (ch == ' ')
- state = State.B44;
- else if (ch == 'f')
- {
- type = type + ch;
- state = State.B55;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 1);
- state = State.E;
- }
- break;
- }
- case State.B55:
- {
- if (ch == 'i')
- {
- type = type + ch;
- state = State.B66;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 2);
- state = State.E;
- }
- break;
- }
- case State.B66:
- {
- if (ch == 'x')
- {
- type = type + ch;
- state = State.B77;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 3);
- state = State.E;
- }
- break;
- }
- case State.B77:
- {
- if (ch == 'e')
- {
- type = type + ch;
- state = State.B88;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 4);
- state = State.E;
- }
- break;
- }
- case State.B88:
- {
- if (ch == 'd')
- {
- type = type + ch;
- state = State.F00;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataBinFixed, i - 5);
- state = State.E;
- }
- break;
- }
- case State.C11:
- {
- if (ch == 'h')
- {
- type = type + ch;
- state = State.C22;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataChar, i - 1);
- state = State.E;
- }
- break;
- }
- case State.C22:
- {
- if (ch == 'a')
- {
- type = type + ch;
- state = State.C33;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataChar, i - 2);
- state = State.E;
- }
- break;
- }
- case State.C33:
- {
- if (ch == 'r')
- {
- type = type + ch;
- state = State.C44;
- }
- else
- {
- error = new KindsofErrors(Error.TypesOfDataChar, i - 3);
- state = State.E;
- }
- break;
- }
- case State.C44:
- {
- if (ch == ' ')
- state = State.C44;
- else if (ch == '(')
- state = State.C55;
- else
- {
- error = new KindsofErrors(Error.TypesOfDataChar, i - 1);
- state = State.E;
- }
- break;
- }
- case State.C55:
- {
- if (ch == ' ')
- state = State.C55;
- else if ((ch >= '0') && (ch <= '9'))
- {
- int_numb_char = int_numb_char + ch;
- state = State.C77;
- }
- else if (ch == '-')
- {
- int_numb_char = int_numb_char + ch;
- state = State.C66;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- break;
- }
- case State.C66:
- {
- if ((ch >= '0') && (ch <= '9'))
- {
- int_numb_char = int_numb_char + ch;
- state = State.C77;
- }
- else
- {
- error = new KindsofErrors(Error.IntegerWithoutMinus, i - 1);
- state = State.E;
- }
- break;
- }
- case State.C77:
- {
- if ((ch >= '0') && (ch <= '9'))
- {
- int_numb_char = int_numb_char + ch;
- state = State.C77;
- }
- else if (ch == ' ')
- {
- TryParse(int_numb_char, out int int_numb_char1);
- if (((int_numb_char == "0") && (int_numb_char1 == 0)) || ((int_numb_char != "0") && (int_numb_char1 != 0)))
- {
- if ((int_numb_char1 > minint) && (int_numb_char1 < maxint))
- {
- state = State.C88;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_char = "";
- }
- else if (ch == ')')
- {
- TryParse(int_numb_char, out int int_numb_char1);
- if (((int_numb_char == "0") && (int_numb_char1 == 0)) || ((int_numb_char != "0") && (int_numb_char1 != 0)))
- {
- if ((int_numb_char1 > minint) && (int_numb_char1 < maxint))
- {
- state = State.F00;
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- }
- else
- {
- error = new KindsofErrors(Error.Integer, i - 1);
- state = State.E;
- }
- int_numb_char = "";
- }
- else
- {
- error = new KindsofErrors(Error.CloseBracket, i - 1); //Ожидалась )
- state = State.E;
- }
- break;
- }
- case State.C88:
- {
- if (ch == ')')
- state = State.F00;
- else
- {
- error = new KindsofErrors(Error.CloseBracket, i - 1); //Ожидалась )
- state = State.E;
- }
- break;
- }
- case State.F00:
- {
- if (ch == ' ')
- {
- list.AddType(type, delta);
- type = "";
- delta = 1;
- state = State.F00;
- }
- else if (ch == ';')
- {
- list.AddType(type, delta);
- type = "";
- delta = 1;
- state = State.F;
- }
- else if (ch == ',')
- {
- list.AddType(type, delta);
- type = "";
- delta = 1;
- state = State.D;
- }
- else
- {
- error = new KindsofErrors(Error.CommaOrEndLine, i - 1);
- state = State.E;
- }
- break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement