%{
#include <stdio.h>
%}
%%
"+" { printf("Operator: Addition\n"); }
"-" { printf("Operator: Subtraction\n"); }
"*" { printf("Operator: Multiplication\n"); }
"/" { printf("Operator: Division\n"); }
"%" { printf("Operator: Modulus\n"); }
"=" { printf("Operator: Assignment\n"); }
"==" { printf("Operator: Equality\n"); }
"!=" { printf("Operator: Not Equal\n"); }
"<" { printf("Operator: Less Than\n"); }
"<=" { printf("Operator: Less Than or Equal\n"); }
">" { printf("Operator: Greater Than\n"); }
">=" { printf("Operator: Greater Than or Equal\n"); }
"&&" { printf("Operator: Logical AND\n"); }
"||" { printf("Operator: Logical OR\n"); }
"!" { printf("Operator: Logical NOT\n"); }
. { printf("Unknown symbol: %s\n", yytext); }
\n { /* Ignore newline */ }
%%
int main() {
printf("Enter an operator: ");
yylex();
return 0;
}
int yywrap() {
return 1;
}