Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <Windows.h>
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <iomanip>
- #include <cstdio>
- /*ЭТО НЕ ВАЖНО*/
- enum statement_type {
- BEGIN, VAR, ASSIGNMENT, NUMBER, ERR
- } previousstate, currentstate; //Предыдущее и Текущее состояние
- enum symb_type {
- SPACE, SEMICOLON, LETTER, LETTER16, NUMERIC, PLUS, MINUS, MULTIPLY, DIVIDE, LBRACKET, RBRACKET, OTHER
- } cursymbtype, temp_stype; //Вид текущего символа
- //функция с параметрами (тек.сост, вид тек.символа, лексема, счётчик лексем)
- //что внутри функции не важно, т.к. здесь облегчённый кусок программы, чтобы проще было отловить ошибку
- //вид символа не определяется, всегда передаётся параметр MINUS, просто чтобы функция выводила хоть что-то
- std::string LexOut (statement_type _state, symb_type _type, std::string str, unsigned ii) {...}
- /*ЭТО НЕ ВАЖНО*/
- int main() {
- setlocale(LC_ALL, "Rus");
- unsigned lexcounter = 0;
- std::string buffer = "";
- char cursymb;
- std::ifstream file;
- file.open("Source Lang File.txt", std::ios::in);
- while ((cursymb = file.get()) != EOF) {
- std::cout<<"\n__прочитали "<<cursymb<<" код символа: "<<(int)cursymb<<"\n";
- temp_stype = MINUS;
- buffer += cursymb;
- lexcounter++;
- std::cout << LexOut(previousstate, temp_stype, buffer, lexcounter);
- }
- file.close();
- system("pause"); return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement