%{
#include <stdio.h>
%}
%%
\+ { printf("Arithmetic Operator: +\n"); }
\- { printf("Arithmetic Operator: -\n"); }
\* { printf("Arithmetic Operator: *\n"); }
\/ { printf("Arithmetic Operator: /\n"); }
\% { printf("Arithmetic Operator: %%\n"); }
= { printf("Assignment Operator: =\n"); }
\+= { printf("Assignment Operator: +=\n"); }
\-= { printf("Assignment Operator: -=\n"); }
\*= { printf("Assignment Operator: *=\n"); }
\/= { printf("Assignment Operator: /=\n"); }
\%= { printf("Assignment Operator: %%=\n"); }
& { printf("Bitwise Operator: &\n"); }
\| { printf("Bitwise Operator: |\n"); }
\^ { printf("Bitwise Operator: ^\n"); }
~ { printf("Bitwise Operator: ~\n"); }
<< { printf("Shift Operator: <<\n"); }
>> { printf("Shift Operator: >>\n"); }
== { printf("Relational Operator: ==\n"); }
!= { printf("Relational Operator: !=\n"); }
< { printf("Relational Operator: <\n"); }
> { printf("Relational Operator: >\n"); }
<= { printf("Relational Operator: <=\n"); }
>= { printf("Relational Operator: >=\n"); }
&& { printf("Logical Operator: &&\n"); }
\|\| { printf("Logical Operator: ||\n"); }
! { printf("Logical Operator: !\n"); }
[ \t\n] { /* Ignore whitespace */ }
. { printf("Unknown symbol: %s\n", yytext); }
%%
int main() {
yylex();
return 0;
}
int yywrap() {
return 1;
}