From 838c59cfed67cf1e659c65fbfad9fe011585d8f0 Mon Sep 17 00:00:00 2001 From: bigsketti Date: Wed, 25 Sep 2024 09:08:18 -0400 Subject: [PATCH] Lexer now outputs to file --- headers/lexer.h | 42 +++++++++++++++++++++------------------- lexerOutput.txt | 9 +++++++++ profaneCompiler | Bin 43120 -> 43416 bytes src/lexer.cpp | 2 +- src/profaneCompiler.cpp | 12 ++++++++++++ 5 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 lexerOutput.txt diff --git a/headers/lexer.h b/headers/lexer.h index 09ac0b7..04bc7de 100644 --- a/headers/lexer.h +++ b/headers/lexer.h @@ -4,33 +4,35 @@ #include //list of keywords + +//types denoted by the index within the enum class +//this is so its easy to pass this info to the parser enum class Keywords { - identifier, - integer, - floatpnt, - string, - character, - boolean, - plus, - minus, - multiply, - divide, - l_Paren, - r_Paren, - l_Brace, - r_Brace, - l_Brack, - r_Brack, - semicolon, - end_of_file, - unknown + identifier, //type 0 + integer, //type 1 + floatpnt, //type 2 + string, //type 3 + character, //type 4 + boolean, //type 5 + plus, //type 6 + minus, //type 7 + multiply, //type 8 + divide, //type 9 + l_Paren, //type 10 + r_Paren, //type 11 + l_Brace, //type 12 + r_Brace, //type 13 + l_Brack, //type 14 + r_Brack, //type 15 + semicolon, //type 16 + end_of_file, //type 17 + unknown //type 18 }; struct Token { Keywords type; std::string value; - Token(Keywords type, std::string value) : type(type), value(value) {} }; diff --git a/lexerOutput.txt b/lexerOutput.txt new file mode 100644 index 0000000..fdfbd69 --- /dev/null +++ b/lexerOutput.txt @@ -0,0 +1,9 @@ +Type: 0, Value: int +Type: 0, Value: main +Type: 10, Value: ( +Type: 11, Value: ) +Type: 12, Value: { +Type: 0, Value: return +Type: 1, Value: 0 +Type: 16, Value: ; +Type: 13, Value: } diff --git a/profaneCompiler b/profaneCompiler index 0cb9e7c5c62a6f325f732b794760d3299a508aff..2f9047addf6adfc7dd305ff1347bf4ff3c9c535a 100755 GIT binary patch delta 10966 zcmb7K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g~rTJj$NY$LbXo3rHnEL(mV4LV+LcXv+{m5zC)DQ7W!nqV~8&nK6hP)8VbHUa2f=j zy_(LJMT#G(YO|KdcGjU!^oSw;=qL7kSxxOJrl3ey{D)a4VZD+4lj6szwSlZmWw?;o(_RyU0?BFy9`su)`-g)xdhqk7{R#V=EQ)BgRd z;+xLxe}E6isw&sRy0pLr$FN+D4d#JN8H$fqbI#n-@kBt6Kkv{E^5-P}Qj~rFrY6(h zly9pD=>n`x=y64i>2>}v9Zl#m^hkoW(lJGMjev10o&WvHN~oU|54J9T^BQ=mBZ zrYmN%Gz}Kp)SBfZ9H#@yzN^}Ktnoi@@u{Yr#{}WPd4u)WrJ01a8$V$3$s$~}RjniO z7z#qYI$!CCT<~&XO)657O{d@%#Wx-JD#e$o=`vDD*0Lf(Yq~9Uqa}+RF%zQAz?0Nq zWA4iI8!pw#__NC{Ws}&+EVGmYaI#_L_G+c`>6lX+%FJ^N%0wx5$qUMhA8j}-R(#X@ z@=C=wokm}?nsE`Oal9$U_~I_Wx_4DOZCa${YDe|htFCTsY0&w{_CghdCKv04~RJHRGlOX6hV zbh`bQ6uWhTEsmhB8`JFbvAb}>`F7UEv@q+~YoR~w*qEnPP|tT$>VMl;qZZBOcJ$o4 z$#&~be#k{z-_6#q=yV6H*Dv9*ihuy?aemGh9cKMFdzM3|JZoiij zU~Ma-sY_Y+0Bbj#K{Lzx!s3&%zV@=2rh9D&-6>167psl>QY-59ewuyR+h%Edje5P~ F{6A}7Bt!rJ diff --git a/src/lexer.cpp b/src/lexer.cpp index caaedb2..7644b12 100644 --- a/src/lexer.cpp +++ b/src/lexer.cpp @@ -49,7 +49,7 @@ Lexer::Lexer(const std::string &input) { Token Lexer::getNextToken() { while (currentChar != '\0') { - std::cout << currentChar << std::endl; + //std::cout << currentChar << std::endl; if (std::isspace(currentChar)) { skipWhiteSpace(); diff --git a/src/profaneCompiler.cpp b/src/profaneCompiler.cpp index 26be998..c03f47a 100644 --- a/src/profaneCompiler.cpp +++ b/src/profaneCompiler.cpp @@ -5,6 +5,10 @@ #include "/home/mason/code-shit/ProfaneC/headers/lexer.h" +//overloads the << operator to output token type as an integer +//followed by the token value +//the integers corrispond to the order defined in the Keywords enum class +//reference lexer.h for map of token types to indecies std::ostream& operator<<(std::ostream& os, const Token& token) { os << "Type: " << static_cast(token.type) << ", Value: " << token.value; return os; @@ -44,5 +48,13 @@ int main() { std::cout << tokenVec.at(i) << std::endl; } + std::ofstream file_out("/home/mason/code-shit/ProfaneC/lexerOutput.txt"); + + if (file_out.is_open()) { + for (int i = 0; i < tokenVec.size(); i++) { + file_out << tokenVec.at(i) << std::endl; + } + } + return 0; } \ No newline at end of file