Question: Create a C++ Tokenizer class. This Tokenizer class will consist of both a header and a class file. You will create the prog2_1.hpp and prog2_1.cpp

 Create a C++ Tokenizer class. This Tokenizer class will consist of

Create a C++ Tokenizer class. This Tokenizer class will consist of both a header and a class file. You will create the prog2_1.hpp and prog2_1.cpp This Tokenizer class will have four public methods. First, the constructor, which will setup/create any internal data structures you need. Second, the destructor, which will delete any internal data structures you created during the lifetime of the object. Third will be a void function that takes a single string argument name Tokeni This Tokenize function will tokenize the input string on the space character. Only the following tokens are valid: push, pop, add, sub, mul, div, mod, skip, save, get and any valid integer If an input string contains a potential token that is not one of those values the function should throw a std::exception with the message "Unexpected token: is replaced by the unexpected token. (If the input was "foobar 3.14" only the first bad token foobar should cause the exception, which should read "Unexpected token: foobar" Any valid input should then have all of those tokens saved inside the tokenizer in some sort of queue structure that will return them when requested by the GetTokens function Fourth will be a vector function that takes no arguments named GetTokens. This function will retrieve a single set of input tokens that had previously been passed to the function Tokenize in a queue fashion (the first input to Tokenize is the first output from GetTokens). If there are no remaining outputs the function should throw a std::exception with the message "No tokens

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!