Mistři v programování na #hovnokod

C/C++ #1003

Parser, ne?

	ifstream infile (argv[1]); ofstream outfile (argv[2]); bool shall = true; char c;
	while (infile.good()) {
		if (shall) infile.get(c);
		else shall = true;
		if (c == '<') {
			infile.get(c);
			if (c == 'c') {
				infile.get(c);
				if (c == 'o') {
					infile.get(c);
					if (c == 'd') {
						// <cod
						outfile << "<co" << c << flush;
						while (c != '<') {
							infile.get(c);
							outfile << c << flush;
						}
					} else {
						outfile << "<co" << c << flush;
					}
				} else {
					outfile << "<c" << c << flush;
				}
			} else if (c == 'p') {
				infile.get(c);
				if (c == 'r') {
					infile.get(c);
					if (c == 'e') {
						// <pre
						outfile << "<pr" << c << flush;
						while (c != '<') {
							infile.get(c);
							outfile << c << flush;
						}
					} else {
						outfile << "<pr" << c << flush;
					}
				} else {
					outfile << "<p" << c << flush;
				}
			} else {
				outfile << "<" << c << flush;
			}
		} else if (c == ' ') {
			infile.get(c);
			if (c == '-') {
				outfile << " –" << flush;
			} else if (c == '"') {
				outfile << " „" << flush;
			} else {
				outfile << " " << flush;
				shall = false;
			}
		} else if (c == '>') {
			infile.get(c);
			if (c == '"') {
				outfile << ">„" << flush;
			} else {
				outfile << ">" << flush;
				shall = false;
			}
		} else if (c == '(') {
			infile.get(c);
			if (c == '"') {
				outfile << "(„" << flush;
			} else {
				outfile << "(" << flush;
				shall = false;
			}
		} else if (c == '"') {
			outfile << "“" << flush;
		} else {
			outfile << c << flush; // Just flush it
		}
	}
	infile.close();
	outfile.close();
	return 0;

hroncok,