I have assignment to write a simple lex anayzer. I can't get the output to print the tokens correctly.
All that should print is the characters from a file, and their assigned token. Mine just ends in DIGIT DIGIT DIGIT every time (because i have "int token = 0". If i change the value it just changes the constant token name. Due tonight, and feeling desperate. Please show my what I am doing wrong. Thank you so much.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
ifstream foo("file name here");
while (foo >> characters)
int t = 0;
string convertToken(int t);
cout << characters << convertToken(t);
it should print
It is part of the point of the assignment. Setting up all the code you cannot see is another part. And, after many many days I cannot figure out how to do it, so in desperation I am coming for help.
If i code it so that it takes information from user input, it works correctly. When I switch it to take the information from a file, something breaks. I cannot figure out what is wrong, and I am asking for straight up help at this point. Please.