#include <stdio.h>
#include <string.h>
#include <ctype.h>

void lexer(char *input) {
    int i = 0;
    int len = strlen(input);

    printf("\nTokens Found:\n");

    while (i < len) {

        if (isspace(input[i])) {
            i++;
            continue;
        }

        if (i + 1 < len) {
            char two[3] = {input[i], input[i+1], '\0'};

            if (strcmp(two, "+=") == 0 || strcmp(two, "-=") == 0 ||
                strcmp(two, "/=") == 0 || strcmp(two, "*=") == 0 ||
                strcmp(two, ">=") == 0 || strcmp(two, "<=") == 0 ||
                strcmp(two, "==") == 0 || strcmp(two, "!=") == 0) {

                printf("OPERATOR: %s\n", two);
                i += 2;  
                continue;
            }
        }

        if (input[i] == '+' || input[i] == '-' || input[i] == '*' ||
            input[i] == '/' || input[i] == '=' || input[i] == '>' ||
            input[i] == '<' || input[i] == '!') {

            printf("OPERATOR: %c\n", input[i]);
            i++;
            continue;
        }

        i++;
    }
}

int main() {
   char input[] = "x += 5; y -= 2; z *= 3; w /= 4; a == b; c != d; e >= f; g <= h; i = j + k - l * m / n > o < p ! q";
      
    printf("Testing Lexer with Hardcoded Input:\n");
    printf("%s\n", input);
    lexer(input);
    return 0;
}