Implementing IF statements to a Interpreter

I need help adding if statements to my in progress esoteric joke language CarLang

Link: https://replit.com/@EarthRulerr/CarLang#main.cpp

Code
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <string>
#ifdef _WIN32
#include <Windows.h>
#else
#include <unistd.h>
#endif
using namespace std;
int main() {
  system("clear");
  string print, input, comment, shift, op, engine;
  int op1, op2, decelerate, ifL;
  int ifL2 = 0;
  int printL = 0;
  int loop = 1;
  while (loop == 1) {
    if (ifL != 1) {
      cin >> input;
    }
    if (input == "PARK") {
      getline(cin, comment);
    } else if (input == "DRIVE") {
      printL = 1;
      while (printL == 1) {
        cin >> print;
        if (print != "BRAKE") {
          cout << print << " ";
        } else {
          printL = 0;
        }
      }
    } else if (input == "SHIFT") {
      cin >> shift;
      if (shift == "GEAR") {
        cin >> op1;
        cin >> op;
        cin >> op2;
        if (op == "+") {
          cout << op1 + op2;
        } else if (op == "-") {
          cout << op1 - op2;
        } else if (op == "*") {
          cout << op1 * op2;
        } else if (op == "/") {
          cout << op1 / op2;
        }
      }
    } else if (input == "DECELERATE") {
      cin >> decelerate;
      sleep(decelerate);
    } else if (input == "START") {
      cin >> engine;
      if (input == "ENGINE") {
        system("clear");
      }
    } else if (input == "IF") {
      cin >> op1;
      cin >> op;
      cin >> op2;
      cin >> input;
      if (input == "DO") {
        ifL2 = 1;
        while (ifL2 == 1) {
          cin >> input;
          if (input == "ENDIF") {
            ifL2 = 0;
          }
        }
        ifL = 1;
      }
    } else if (input == "ENDIF") {
      ifL = 0;
    }
  }
}

CarLang, how to use (so far):
DRIVE string text haha BRAKE - Printing text, output: string text haha
GEAR SHIFT 5 - 5 - Arithmetic, operators +, -, *, / output: 0
PARK string text haha - Comments. output: nil
IF 5 = 5 DO DRIVE text BRAKE ENDIF - If statement, this need work doesnt do anything currently. Output: text

Format for IF statement:

IF # = # DO code ENDIF

Operators: =, <, >, !=

1 Like