Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7. const vector<string> statements{ "FOR", "GOTO" };
  8. const vector<string> separators{ "(", ")" };
  9. const vector<string> keywords{ "END", "GOSUB", "IF", "LET", "NEXT", "REM", "RETURN", "STEP", "TO" };
  10. const vector<string> operators{ "<>", ">=", "<=", "=", "+", "-", "*", "/", "<", ">", "^", "$" };
  11.  
  12. void delS() {
  13. fstream filei("Text.txt", fstream::in);
  14. fstream fileo("Text1.txt", fstream::out);
  15. char ch;
  16. string line = "";
  17. while (filei >> noskipws >> ch) {
  18. if (ch != '\n') {
  19. if (ch != ' ') {
  20. line += ch;
  21. //cout << ch;
  22. }
  23. }
  24. else {
  25. line += "\n";
  26. fileo << line;
  27. line = "";
  28. //cout << endl;
  29. }
  30. }
  31. line += "\n";
  32. fileo << line;
  33. line = "";
  34. }
  35.  
  36. void lexA() {
  37. fstream filei("Text1.txt", fstream::in);
  38. char ch;
  39. string line = "";
  40. while (filei >> line) {
  41. bool isStart = 1;
  42. string buffer = "";
  43. int i = 0;
  44. while (ch = line[i]) {
  45. if (isdigit(ch) && isStart == 1) {
  46. buffer += ch;
  47. }
  48. else if (buffer != "") {
  49. isStart = 0;
  50. cout << buffer << endl;
  51. buffer = "";
  52. }
  53. if (buffer != "" && i == line.size() - 1) {
  54. isStart = 0;
  55. cout << buffer << endl;
  56. buffer = "";
  57. }
  58. i++;
  59. }
  60. }
  61.  
  62.  
  63.  
  64. }
  65.  
  66. int main() {
  67. setlocale(LC_ALL, "ru");
  68. delS();
  69. lexA();
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement