Advertisement
Guest User

Untitled

a guest
May 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. char FirstChar (bool* end_of_file, bool* is_command, bool* incorrect_line){
  2. char x;
  3. x = getchar();
  4. if (!((x>='A' && x<='Z') || (x>='a' && x<='z')) && (x == '(' || (x>='0' && x<='9') || x == '-')) (*is_command) = false;
  5. else if ((x>='A' && x<='Z') || (x>='a' && x<='z')) (*is_command) = true;
  6. else (*incorrect_line) = true;
  7. return x;
  8. }
  9. void NextLine (bool* end_of_file, bool* is_command, StackNode** head){
  10. char x = 'a';
  11. int i = 1, key = 0;
  12. bool help = false, incorrect_line = false;
  13. char* array = (char*) malloc(sizeof(char)*MAX_COMMAND_CHARS);
  14. if (array == NULL) return;
  15. array[0] = (int)FirstChar(end_of_file, is_command, &incorrect_line);
  16. // na wszelki wypadek ustawiam zeby w ifach nie bylo cyrkow
  17. array[1] = 'H';
  18. while (x == '\n') x = getchar();
  19. while (x != '\n' && x != EOF && !help && !incorrect_line) {
  20. x = getchar();
  21. array[i] = x;
  22. ++i;
  23. if (array[0] == 'D' && array[1] == 'E' && array[2] == 'G' && array[3] == '_' && array[4] == 'B' && array[5] == 'Y'){
  24. help = true;
  25. }
  26. else if (array[0] == 'A' && array[1] == 'T'){
  27. help = true;
  28. }
  29. }
  30. if (help) scanf ("%d", &key);
  31. array[i-1] = '\0';
  32. if (incorrect_line) return;
  33. if ((*is_command)) InterpretingCommand(array, head, key);
  34. else if (CheckIfPolyIsCorrect(array)) {
  35. int index = 0;
  36. CheckLine(array, i-1);
  37. Poly new = NewPoly (array, &index);
  38. Push (head, new);
  39. }
  40. if (x == EOF) (*end_of_file) = true;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement