I make my calculator compiler into my bytecode in C ++ as more productive than Java. It came to turning the string into a token or as they are called differently tokens. That is, the string "(var1 + var2) * var3" should turn into tokens[left_bracket, var var1, operator_plus, var var2, right_bracket, operator_multiplication, var var3] 'The code' of the tokens array consists of the heirs of the Token class. This requires the string getStatement(string str, int statement_position) function string getStatement(string str, int statement_position) which returns a string containing the word.

It is necessary to get the word from space to space. Example: getStatement("int variable_a = variable_b + variable_c", 8); should return variable_a .

  • All additions to the question should be in the question itself, not in the comments (click "edit" in question, and enter the code in the question itself). - insolor
  • "compiler calculator, bytecode in C ++" that neither a word, then a riddle. And on the topic, your brain is too straightforward - in this case split (), but you cannot get all the ready-made functions. need an algorithm. like a finite state machine. least. - DollarDollar
  • I did a similar thing in Java, in C ++ I have no development experience. - Kozinetov

0