Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char FirstChar (bool* end_of_file, bool* is_command, bool* incorrect_line){
- char x;
- x = getchar();
- if (!((x>='A' && x<='Z') || (x>='a' && x<='z')) && (x == '(' || (x>='0' && x<='9') || x == '-')) (*is_command) = false;
- else if ((x>='A' && x<='Z') || (x>='a' && x<='z')) (*is_command) = true;
- else (*incorrect_line) = true;
- return x;
- }
- void NextLine (bool* end_of_file, bool* is_command, StackNode** head){
- char x = 'a';
- int i = 1, key = 0;
- bool help = false, incorrect_line = false;
- char* array = (char*) malloc(sizeof(char)*MAX_COMMAND_CHARS);
- if (array == NULL) return;
- array[0] = (int)FirstChar(end_of_file, is_command, &incorrect_line);
- // na wszelki wypadek ustawiam zeby w ifach nie bylo cyrkow
- array[1] = 'H';
- while (x == '\n') x = getchar();
- while (x != '\n' && x != EOF && !help && !incorrect_line) {
- x = getchar();
- array[i] = x;
- ++i;
- if (array[0] == 'D' && array[1] == 'E' && array[2] == 'G' && array[3] == '_' && array[4] == 'B' && array[5] == 'Y'){
- help = true;
- }
- else if (array[0] == 'A' && array[1] == 'T'){
- help = true;
- }
- }
- if (help) scanf ("%d", &key);
- array[i-1] = '\0';
- if (incorrect_line) return;
- if ((*is_command)) InterpretingCommand(array, head, key);
- else if (CheckIfPolyIsCorrect(array)) {
- int index = 0;
- CheckLine(array, i-1);
- Poly new = NewPoly (array, &index);
- Push (head, new);
- }
- if (x == EOF) (*end_of_file) = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement