%{
#include <iostream>
#include <cstdlib>
using namespace std;
%}
%option noyywrap
%%
[ \t\n\r]+ /* Ignore whitespace (spaces, tabs, newlines) */
"+" { cout << "Arithmetic Operator: +" << endl; }
"-" { cout << "Arithmetic Operator: -" << endl; }
"*" { cout << "Arithmetic Operator: *" << endl; }
"/" { cout << "Arithmetic Operator: /" << endl; }
">" { cout << "Relational Operator: >" << endl; }
"<" { cout << "Relational Operator: <" << endl; }
"==" { cout << "Relational Operator: ==" << endl; }
[0-9]+ { cout << "Constant: " << yytext << endl; }
[a-zA-Z_][a-zA-Z0-9_]* { cout << "Identifier: " << yytext << endl; }
%%
int main() {
// Start the lexical analyzer
cout << "Enter input for tokenization:" << endl;
yylex(); // Runs the lexical analyzer
return 0;
}
JXsKI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGxpYj4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKJX0KCiVvcHRpb24gbm95eXdyYXAKCiUlCgpbIFx0XG5ccl0rICAgICAgICAgIC8qIElnbm9yZSB3aGl0ZXNwYWNlIChzcGFjZXMsIHRhYnMsIG5ld2xpbmVzKSAqLwoiKyIgICAgICAgICAgICAgICAgIHsgY291dCA8PCAiQXJpdGhtZXRpYyBPcGVyYXRvcjogKyIgPDwgZW5kbDsgfQoiLSIgICAgICAgICAgICAgICAgIHsgY291dCA8PCAiQXJpdGhtZXRpYyBPcGVyYXRvcjogLSIgPDwgZW5kbDsgfQoiKiIgICAgICAgICAgICAgICAgIHsgY291dCA8PCAiQXJpdGhtZXRpYyBPcGVyYXRvcjogKiIgPDwgZW5kbDsgfQoiLyIgICAgICAgICAgICAgICAgIHsgY291dCA8PCAiQXJpdGhtZXRpYyBPcGVyYXRvcjogLyIgPDwgZW5kbDsgfQoKIj4iICAgICAgICAgICAgICAgICB7IGNvdXQgPDwgIlJlbGF0aW9uYWwgT3BlcmF0b3I6ID4iIDw8IGVuZGw7IH0KIjwiICAgICAgICAgICAgICAgICB7IGNvd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