Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <fstream>
- using namespace std;
- const vector<string> statements{ "FOR", "GOTO" };
- const vector<string> separators{ "(", ")" };
- const vector<string> keywords{ "END", "GOSUB", "IF", "LET", "NEXT", "REM", "RETURN", "STEP", "TO" };
- const vector<string> operators{ "<>", ">=", "<=", "=", "+", "-", "*", "/", "<", ">", "^", "$" };
- void delS() {
- fstream filei("Text.txt", fstream::in);
- fstream fileo("Text1.txt", fstream::out);
- char ch;
- string line = "";
- while (filei >> noskipws >> ch) {
- if (ch != '\n') {
- if (ch != ' ') {
- line += ch;
- //cout << ch;
- }
- }
- else {
- line += "\n";
- fileo << line;
- line = "";
- //cout << endl;
- }
- }
- line += "\n";
- fileo << line;
- line = "";
- }
- void lexA() {
- fstream filei("Text1.txt", fstream::in);
- char ch;
- string line = "";
- while (filei >> line) {
- bool isStart = 1;
- string buffer = "";
- int i = 0;
- while (ch = line[i]) {
- if (isdigit(ch) && isStart == 1) {
- buffer += ch;
- }
- else if (buffer != "") {
- isStart = 0;
- cout << buffer << endl;
- buffer = "";
- }
- if (buffer != "" && i == line.size() - 1) {
- isStart = 0;
- cout << buffer << endl;
- buffer = "";
- }
- i++;
- }
- }
- }
- int main() {
- setlocale(LC_ALL, "ru");
- delS();
- lexA();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement