lexema
Wed Jun 05 2024 20:42:18 GMT+0000 (Coordinated Universal Time)
Saved by
@gabriellesoares
%{
#include <stdio.h>
%}
/* Definições de padrões */
letra [a-zA-Z]
dígito [0-9]
número {dígito}+
identificador {letra}({letra}|{dígito})*
operador (\+|\-|\*|\/|\=|\<|\>|\!\=|\=\=|\>\=|\<\=)
palavra_reservada (if|else|while|for|return|int|float|void|char)
pontuação [\(\)\{\}\[\]\;\,\.]
comentário /\*([^*]|\*+[^*/])*\*+/
%%
{número} { printf("Número: %s\n", yytext); }
{identificador} { printf("Identificador: %s\n", yytext); }
{operador} { printf("Operador: %s\n", yytext); }
{palavra_reservada} { printf("Palavra Reservada: %s\n", yytext); }
{pontuação} { printf("Pontuação: %s\n", yytext); }
{comentário} { /* Ignorar comentários */ }
[ \t\n]+ { /* Ignorar espaços em branco */ }
. { printf("Caractere não reconhecido: %s\n", yytext); }
%%
int main(int argc, char **argv) {
yylex();
return 0;
}
int yywrap() {
return 1;
}
content_copyCOPY
Comments