%{
#include <stdio.h>
%}
DIGIT [0-9] /* Definition for single digit */
ID [a-zA-Z_][a-zA-Z0-9_]* /* Definition for identifiers: Starts with a letter or underscore, followed by letters, digits, or underscores */
OP [+\-*/=<>] /* Definition for operators: +, -, *, /, =, <, > */
%%
{DIGIT} { printf("Digit: %s\n", yytext); }
{ID} { printf("Identifier: %s\n", yytext); }
{OP} { printf
("Operator
: %s\n", yytext); } \n { /* Skip newlines */ }
[ \t]+ { /* Skip spaces and tabs */ }
. { printf("Invalid character: %s\n", yytext); } /* Handles invalid characters */
%%
int main() {
printf("Enter a string of characters:\n");
yylex();
return 0;
}
int yywrap() {
return 1;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CiV9CgpESUdJVCBbMC05XSAgICAgICAgICAvKiBEZWZpbml0aW9uIGZvciBzaW5nbGUgZGlnaXQgKi8KSUQgW2EtekEtWl9dW2EtekEtWjAtOV9dKiAgLyogRGVmaW5pdGlvbiBmb3IgaWRlbnRpZmllcnM6IFN0YXJ0cyB3aXRoIGEgbGV0dGVyIG9yIHVuZGVyc2NvcmUsIGZvbGxvd2VkIGJ5IGxldHRlcnMsIGRpZ2l0cywgb3IgdW5kZXJzY29yZXMgKi8KT1AgWytcLSovPTw+XSAgICAgICAgLyogRGVmaW5pdGlvbiBmb3Igb3BlcmF0b3JzOiArLCAtLCAqLCAvLCA9LCA8LCA+ICovCgolJQp7RElHSVR9IHsgcHJpbnRmKCJEaWdpdDogJXNcbiIsIHl5dGV4dCk7IH0Ke0lEfSAgICB7IHByaW50ZigiSWRlbnRpZmllcjogJXNcbiIsIHl5dGV4dCk7IH0Ke09QfSAgICB7IHByaW50ZigiT3BlcmF0b3I6ICVzXG4iLCB5eXRleHQpOyB9ClxuICAgICAgeyAvKiBTa2lwIG5ld2xpbmVzICovIH0KWyBcdF0rICB7IC8qIFNraXAgc3BhY2VzIGFuZCB0YWJzICovIH0KLiAgICAgICB7IHByaW50ZigiSW52YWxpZCBjaGFyYWN0ZXI6ICVzXG4iLCB5eXRleHQpOyB9IC8qIEhhbmRsZXMgaW52YWxpZCBjaGFyYWN0ZXJzICovCiUlCgppbnQgbWFpbigpIHsKICAgIHByaW50ZigiRW50ZXIgYSBzdHJpbmcgb2YgY2hhcmFjdGVyczpcbiIpOwogICAgeXlsZXgoKTsKICAgIHJldHVybiAwOwp9CgppbnQgeXl3cmFwKCkgewogICAgcmV0dXJuIDE7Cn0K