#ifndef COMPILER_TYPES_H #define COMPILER_TYPES_H #include #include #include #include // Typy operacji, które nasz kompilator rozumie enum class OpType { ASSIGN, // a = 5 ADD, // a = b + c SUB, // a = b - c MUL, // a = b * c EQ, // a == b PRINT, // print(a) JMP_FALSE, // if (false) skocz... JMP, // else / pętla LABEL, // miejsce skoku CALL, // wywołanie funkcji RETURN, // return x NOP // pusta instrukcja }; // Pojedynczy rozkaz kompilatora (Intermediate Representation) struct Instruction { OpType type; std::string arg1; std::string arg2; std::string arg3; }; // Definicja funkcji struct Function { std::string name; std::string returnType; // "int", "void", "bool" std::vector args; // Nazwy argumentów (np. "a", "b") std::vector instructions; // Lista rozkazów w funkcji }; struct CompilerState { // Mapa wszystkich funkcji (klucz to nazwa) std::map functions; // Zmienne globalne (tylko nazwa -> wartość początkowa) std::map globals; // Stan parsera Function* currentFunction = nullptr; // Wskaźnik na aktualnie parsującą się funkcję int labelCounter = 0; // Do generowania unikalnych nazw etykiet (L1, L2...) std::stack loopStack; // Do break/continue (przyszłościowo) std::stack blockStack; }; #endif