%{
#include <stdio.h>
// Define token types
#define MOV 1
#define ADD 2
#define NUM 3
#define IDENTIFIER 4
%}
%%
"mov" { return MOV; }
"add" { return ADD; }
[0-9]+ { return NUM; } // Removed yylval since we are not using Yacc/Bison
[a-zA-Z][a-zA-Z0-9]* { return IDENTIFIER; }
[\t\n ]+ { /* Ignore whitespace */ }
. { printf("Unknown character: %s\n", yytext); }
%%
int main() {
int token;
while ((token = yylex())) {
printf("Token: %d\n", token);
}
return 0;
}
JXsKI2luY2x1ZGUgPHN0ZGlvLmg+CgovLyBEZWZpbmUgdG9rZW4gdHlwZXMKI2RlZmluZSBNT1YgMQojZGVmaW5lIEFERCAyCiNkZWZpbmUgTlVNIDMKI2RlZmluZSBJREVOVElGSUVSIDQKJX0KCiUlCgoibW92IiAgICAgICAgICAgeyByZXR1cm4gTU9WOyB9CiJhZGQiICAgICAgICAgICB7IHJldHVybiBBREQ7IH0KWzAtOV0rICAgICAgICAgIHsgcmV0dXJuIE5VTTsgfSAgLy8gUmVtb3ZlZCB5eWx2YWwgc2luY2Ugd2UgYXJlIG5vdCB1c2luZyBZYWNjL0Jpc29uClthLXpBLVpdW2EtekEtWjAtOV0qIHsgcmV0dXJuIElERU5USUZJRVI7IH0KW1x0XG4gXSsgICAgICAgIHsgLyogSWdub3JlIHdoaXRlc3BhY2UgKi8gfQouICAgICAgICAgICAgICAgeyBwcmludGYoIlVua25vd24gY2hhcmFjdGVyOiAlc1xuIiwgeXl0ZXh0KTsgfQoKJSUKCmludCBtYWluKCkgewogICAgaW50IHRva2VuOwogICAgd2hpbGUgKCh0b2tlbiA9IHl5bGV4KCkpKSB7CiAgICAgICAgcHJpbnRmKCJUb2tlbjogJWRcbiIsIHRva2VuKTsKICAgIH0KICAgIHJldHVybiAwOwp9Cg==