From 2de7b7b001bc034c15cf10f5b2a45aeabbc079a5 Mon Sep 17 00:00:00 2001 From: G <82985746+gmook9@users.noreply.github.com> Date: Tue, 2 Nov 2021 23:47:15 -0700 Subject: [PATCH] Add files via upload --- CMakeLists.txt | 6 ++ Stack.cpp | 18 ++++ Stack.hpp | 26 ++++++ Token.cpp | 93 ++++++++++++++++++++ Token.hpp | 47 ++++++++++ Tokenizer.cpp | 138 ++++++++++++++++++++++++++++++ Tokenizer.hpp | 32 +++++++ imagesForReadme/exampleInput.PNG | Bin 0 -> 10311 bytes imagesForReadme/exampleOutput.PNG | Bin 0 -> 8329 bytes main.cpp | 49 +++++++++++ sampleInput.html | 6 ++ 11 files changed, 415 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 Stack.cpp create mode 100644 Stack.hpp create mode 100644 Token.cpp create mode 100644 Token.hpp create mode 100644 Tokenizer.cpp create mode 100644 Tokenizer.hpp create mode 100644 imagesForReadme/exampleInput.PNG create mode 100644 imagesForReadme/exampleOutput.PNG create mode 100644 main.cpp create mode 100644 sampleInput.html diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f7ed4e8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.17) +project(Project1Phase1) + +set(CMAKE_CXX_STANDARD 17) + +add_executable(Project1Phase1 main.cpp Tokenizer.cpp Tokenizer.hpp Token.cpp Token.hpp Stack.cpp Stack.hpp) \ No newline at end of file diff --git a/Stack.cpp b/Stack.cpp new file mode 100644 index 0000000..2e45220 --- /dev/null +++ b/Stack.cpp @@ -0,0 +1,18 @@ +// +// Created by gmook on 2/6/2021. +// + +#include "Stack.hpp" + +void Stack::push(int n) { + stack.push_back(n); +} +int Stack::top() { + return stack.at(stack.size()-1); +} +void Stack::pop() { + stack.pop_back(); +} +bool Stack::empty() { + return stack.empty(); +} diff --git a/Stack.hpp b/Stack.hpp new file mode 100644 index 0000000..2d50cd8 --- /dev/null +++ b/Stack.hpp @@ -0,0 +1,26 @@ +// +// Created by gmook on 2/6/2021. +// + +#ifndef PROJECT1PHASE1_STACK_HPP +#define PROJECT1PHASE1_STACK_HPP + + +#include + +class Stack { +public: + + void push(int n); + int top(); + void pop(); + bool empty(); + +private: + std::vector stack; + +}; + + + +#endif //PROJECT1PHASE1_STACK_HPP diff --git a/Token.cpp b/Token.cpp new file mode 100644 index 0000000..a07a587 --- /dev/null +++ b/Token.cpp @@ -0,0 +1,93 @@ +// +// Template by Ali A. Kooshesh on 1/27/21. +// Additional Code by Garret Mook on 02/06/21. + + +#include +#include +#include "Token.hpp" + +Token::Token(int line, int pos): _isOpenTag{false}, + _isCloseTag{false}, + _isCloseAngleBracket{false}, + _isCloseStandAloneTag{false}, + _tagName{""}, + _eof{false}, + _lineNumber{line}, + _charPos{pos}, + _eol{false}, + _isSlash{false} {} + +bool &Token::isOpenTag() { return _isOpenTag; } +bool &Token::isCloseTag() { return _isCloseTag; } + +bool &Token::isCloseAngleBracket() { return _isCloseAngleBracket; } + +bool &Token::endOfFile() { return _eof; } +bool &Token::isCloseStandAloneTag() { return _isCloseStandAloneTag; } +bool &Token::isSlash() { return _isSlash; } + +std::string Token::tagName() { return _tagName; } + + +bool &Token::eol(){ + return _eol; + +} + +void Token::makeOpenTag(std::string name) { + _tagName = name; + isOpenTag() = true; +} +std::string Token::makeOpenTag() { + return _tagName; +} +void Token::makeCloseTag(std::string name) { + _tagName = name; + + isCloseTag() = true; +} +/* +void Token::print() { + std::cout << "[" << std::setw(2) << _lineNumber << ", " << std::setw(3) << _charPos << "] "; + + if(isOpenTag()) { + std::cout << "<" << tagName() << std::endl; + } else if(isCloseStandAloneTag()) { + std::cout << "/>" << std::endl; + } else if(isCloseAngleBracket()) { + std::cout << ">" << std::endl; + } else if(isCloseTag()) { + std::cout << "" << std::endl; + } else if(isCloseAngleBracket()) { + std::cout << "[" << std::setw(2) << _lineNumber << ", " << std::setw(3) << _charPos << "] "; + std::cout << ">" << std::endl; + } else if(isCloseTag()) { + std::cout << "[" << std::setw(2) << _lineNumber << ", " << std::setw(3) << _charPos << "] "; + std::cout << " + +class Token { +public: + Token(int, int); + bool &isOpenTag(); + bool &isCloseTag(); + + bool &isCloseAngleBracket(); + + bool &endOfFile(); + bool &isCloseStandAloneTag(); + + + std::string tagName(); + //Self Added + + void makeOpenTag(std::string); + void makeCloseTag(std::string); + //Self Added + std::string makeOpenTag(); + bool &isSlash(); + + void print(); + + + + bool &eol(); + +private: + bool _isOpenTag, _isCloseTag, _isCloseAngleBracket, + _eof, _isCloseStandAloneTag, _eol, _isSlash; + std::string _tagName; + int _lineNumber, _charPos; + + +}; + + +#endif //PROJECT1PHASE1_TOKEN_HPP diff --git a/Tokenizer.cpp b/Tokenizer.cpp new file mode 100644 index 0000000..844eda1 --- /dev/null +++ b/Tokenizer.cpp @@ -0,0 +1,138 @@ +// Template by Ali A. Kooshesh on 1/27/21. +// Additional Code by Garret Mook on 02/06/21. + +//READER/LEXICAL ANALYZER +//Implemenation Of Operations + +#include +#include "Tokenizer.hpp" +#include +#include +// +#include +#include +#include +#include + +//Initializer List +Tokenizer::Tokenizer(std::string name): lineNumber{1}, + charPosition{1}, + inputFileName{name} { + inputStream.open(inputFileName, std::ios::in); // open the input file. We will make sure that it is open in getToken. +} +//This defines what a Character of interest is to the reader. +bool Tokenizer::charOfInterest(char c) { + // is c the initial (or the sole) character of a token? + return c == '<' || c == '>' || c == '/'; +} + +Token Tokenizer::getToken() { + char c; + //Checks to see if the file we are trying to read is open + if( ! inputStream.is_open()) { + std::cout << "Tokenizer::getToken() called with a stream that is not open." << std::endl; + std::cout << "Make sure that " << inputFileName << " exists and is readable. Terminating."; + exit(2); + } + + //GM: This while loop executes until we find a charOfInterest + while( inputStream.get(c) && ! charOfInterest(c) ) { + // keep track of the line number and the character position here. + if (c == '\n') { + lineNumber++; + + } + else { + charPosition++; + } + + } + + + //GM: After loop stops this executes + Token token(lineNumber, charPosition); + + if( inputStream.eof() ) { + token.endOfFile() = true; + } +// if < is found + else if( c == '<' && inputStream.peek() != '/' && inputStream.peek() != '>') { + if( isalpha(inputStream.peek()) ) { + charPosition++; + std::string needthisforPeek; + while (inputStream.get(c) && isalpha(c) && !isspace(c) && inputStream.peek() != '/') { + needthisforPeek = needthisforPeek + c; + charPosition++; + } + + inputStream.putback(c); + token.makeOpenTag(needthisforPeek); + return token; + } + } + + /* + // if /> is found + else if (c == '/' && inputStream.peek() == '>') { + inputStream.get(c); + token.isCloseStandAloneTag() = true; + } + */ + + + else if (c == '/') { + if (c == '/' && isalpha(inputStream.peek()) ) { + token.isSlash() = true; + charPosition++; + + } else if (c == '/' && inputStream.peek() == '>') { + inputStream.get(c); + token.isCloseStandAloneTag() = true; + charPosition++; + } + + + } + + + + + + + +// if > is found + else if( c == '>' ) { + token.isCloseAngleBracket() = true; + charPosition++; + } + // if +#include //used for reading writing files +#include "Token.hpp" + +class Tokenizer { + +public: + //Operations(functions) that we perform on the datatype + Tokenizer(std::string); + + Token getToken(); + +private: + int lineNumber, charPosition; + std::string inputFileName; + std::ifstream inputStream; //declare input-stream variable + + bool charOfInterest(char c); +}; + +#endif //PROJECT1PHASE1_TOKENIZER_HPP diff --git a/imagesForReadme/exampleInput.PNG b/imagesForReadme/exampleInput.PNG new file mode 100644 index 0000000000000000000000000000000000000000..d007710af02ef17bc33b11cc588be19aadf6cebc GIT binary patch literal 10311 zcmch7dpy%`__s%Dx@Nup}wxoKM>{q(XC6!ctDbtYtVE)dg*KY5Sg8^hFLlrJu{b zZDZ`Zto(hnU3S?tP0>^$=h99V-J1K|OY$WUj8YTk1m%)HNiomlNQ675Ry=XlAi7< zWx7jV>tJ_$(8bQzuL8fFHr}ac->13Gj4W*aDk5(%GAUsWm!YK{9_4luxzK_i8a-u zukBrb6nLDlTcm;1%+}p4G#jGt=M^QDl5volyl$-_p8vDJ+vUXcahs-(O6|XT?gI7g zCoI-_>VNiXWp0UBr@6VSfo{?;kp&oedw*|Mr9~_M-x@6mYYRn&+&NyL74xl2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5wR`?DnG;i{cSLPZW#=2RDIiNJj60R{f5vt`$w zK{T5cdG&m7Tf+1r;#_$r_%xMuIf6INP^pF;KEL?%!Ol*`kEmeUlF=Jdx9Jz=j0RAx<<|J2_44F9P+DsRBu+? zC@$GZ8ES32Sp_kky}01i#XR(B9y65m!);~42nWBb*>x)%v~Jcp4&TOMOk=vDM|?%YTX_QB;L z#(sop7Z=JeZb(oF{Vtvc;79Pg9VPn&6(=70$nC{ElmG<>H$NZ_60gU!|D&#rkOaM9PW}E z>zs!E#>Cvk-K$Xn@apDozSB*mGq>kXjghMfi;Jx-(raBsI5VE@3%aO{v z-8|O)MXuZ8TJS!8am5noX1sSmC^#(Cp}oSLCqRo(+z}2lslOFpG9hp_`sd@33|Ohy zSG_KOg-q_4GVuOIpvuvaC#3It(4r_o0fb1^aMsSVQB$r?PopHbp{<~!A|0Gd9 zp#*u^`+2)xJ8cGhgyEOb>yDq?0>9xe{zVI4G}o6*{X5z=Q_u$=Mh>ytj9aGg zNd0X;u>VxW)Zg!Z4*o$w{9xXi-izxYL6&pY6sOpJ0Z%mHBX!(Y_nPc<9ABEW{PzA=lm137UrZxN*f z+AEnisrU0+gD@;#Tr;zGCqGC0r)8y3!zK#EB|G0M%I5G&z!p4L4g-?k1F928s+lnp7#r+C*mrYIT*Ej~$ILRQ9F zzyDj{7S1PcA|j!;`1kyKnE;NTIgA~0gZyioEj7jeWVIgtf0fR1X90tAN9Wgt;mG@ literal 0 HcmV?d00001 diff --git a/imagesForReadme/exampleOutput.PNG b/imagesForReadme/exampleOutput.PNG new file mode 100644 index 0000000000000000000000000000000000000000..45d135366a50207ff0f1d980efbc61f46d414064 GIT binary patch literal 8329 zcmZ`DqCT)W$amAON_nVY-1Z_n^DS|Eo&&n3`qusVQfiK zmedesjODd8#@HE*8Q;U(`~8mNcYNO;b2w%^$Mej6-RF5;=Xu?eaKp@ii=Cex001sS zsGcPNu)x3<{}DFulQ-WVxPyOKf-DVm0PGh*GWh1uU)rYH08pLEvE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*4qylj2K((dX%rN5 zmt$V$X?6y;$6960m=_;oZGZ0z$_hcqi*>`%gMM+qDuf zp=UdH=hV{@1{QtU+YJU+0xZ8Ih0!0c9|jAJ;a;6- zplb+fzc&lDrAZU~^sh3j17`oa>l6$rz9(MxO8`ho@DjJ zsqOn?csvosvy~FA_-F_m-OUz*5|k-!X_r_DS-crWEH_x|6z z_*;f%*PYZj{s62s%_u9w?aW~>~hI-LI}+|E11ollCsWhn^y z8ZQ$G(hX~?6?+}8_ql0Hx`X=z0=vwsY#{tN{w=-;loqog{}}G(a6+C8hW)+bNBzh{ zMipM_&eeNmToQ81h=|j}m)XDHOk?whfdetUnILR(-WY zu5`&wA6sF$^iv6`;j|wrz_?7>LS%!zt30glOyFB%d=n-< zLFH^67ocV)PeKCszjE_x#UKuUyF24Pm5IRY^p8p?eT)52#{zVEVkjQ{ulqOpxNzz* z2+e=aB@OEb9-L*t>w8cAyVUdK zkJ)kDC>e}@L(am~-ia4<8rsV(O;@>Vx}4mqA){`kABaVZGQh~cezY?tznS(SA7O~mi( zpLr%_(l6^`pQYvA(RCvN(d`#X^RwYz^d)6gTdnNJSb-xFr;>fHUM(%}+!Z#YPe(<> zb}Dwi-{@|wr4KjzL>qe25u~H`v9m=EQhtCbLQX^&LUR7_he&H z!J(DC3&xG8JH}{=@Xm~O4praf-t&^KPQtqHnSrNinb|n10PR>jmRQs3ApKI&5sUg$ zO${mUH+*5f`Rnfb-~XHeWqCHD%=Pl%%`Xta4b0Q))P8pvA7_&qv1(u7orNfA)iD!Y;6ZF(LJypwm} zepF)%T|7n<79IRVk%SwXouDZ8{AEi1BKDgAx%-DV;NTcM%-DBH`-9Z|$-~}}dHFJl cvdePT?3?R}yn{aA&j$cQeKS3*j?4Z30fhCG761SM literal 0 HcmV?d00001 diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..ce48a4e --- /dev/null +++ b/main.cpp @@ -0,0 +1,49 @@ +#include +#include +#include "Tokenizer.hpp" + +int main(int argc, char *argv[]) { + + if( argc != 2 ) { // we expect the name of the file as an argument to the program. + std::cout << "usage: " << argv[0] << " nameOfAnInputFile" << std::endl; + exit(1); + } + + // Here, we open the file to make sure that it exists before starting the program. + // When using CLion, the input file has to be in cmake-build-debug directory. + std::ifstream inputStream; + inputStream.open(argv[1], std::ios::in); // open for reading + if( ! inputStream.is_open()) { + std::cout << "Unable top open " << argv[1] << ". Terminating..."; + std::cout << strerror(errno) << std::endl; + exit(2); + } + + + /* + + + // We now know that the input file exists and we can read from it. Here, we will close it + // and give Tokenizer the name of the file so it can open and use it. We also could give + // Tokenizer 'inputStream' so that it just uses it. + inputStream.close(); + + Tokenizer tokenizer(argv[1]); // use the first argument, which contains the name of the input file + // to create an instance of Tokenizer. + Token token = tokenizer.getToken(); // get the first token. + + token.print(); + + + */ + + // this is what the main function for your solution to phase 1 should look like. + Tokenizer tokenizer(argv[1]); + Token token = tokenizer.getToken(); // get the first token to start the while loop + + while( ! token.endOfFile() ) { + token.print(); + token = tokenizer.getToken(); + } + return 0; +} diff --git a/sampleInput.html b/sampleInput.html new file mode 100644 index 0000000..dc3297a --- /dev/null +++ b/sampleInput.html @@ -0,0 +1,6 @@ +

This is a paragraph tag.

+ +

This is another paragraph tag in which the start + tag has some attributes. However, for this project, we are not concerned with the + attributes in this lab and therefore, we will ignore their presence.

+