[go: up one dir, main page]

Menu

[r266]: / calculadora / lexer.l  Maximize  Restore  History

Download this file

35 lines (22 with data), 791 Bytes

/* Analisador léxico da calculadora para a disciplina de PCS

   Aluno: Felipe Monteiro de Carvalho                           
   No USP: 5179576                                              */

%{
#include "y.tab.h"
#include <stdlib.h> 
%}
%%

[0-9]+[dD]?          {yylval.numero = atoi(yytext); return NUMBER; }

[0-9a-fA-F]+[hH]     {yylval.numero = strtoul(yytext, NULL , 16); return NUMBER; }

[ \t]                {} /* ignorar espaćos em branco */

[-]                  {return MENOS;}

[+*/()]              {return yytext[0];}

[=][hH]              {return IGUALH;}

[=][dD]?             {return IGUALD;}

\n                   {return yytext[0];}

.                    {ECHO; yyerror("Caracter inexperado");}

%%
int yywrap (void)
{
    return 1;
}