Created
March 27, 2022 01:12
-
-
Save melchisedech333/be97d7f410b018ded40b81d50400b5bc to your computer and use it in GitHub Desktop.
Código Lex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%{ | |
#include <stdio.h> | |
#include <string.h> | |
#include "y.tab.h" | |
void yyerror (char *c); | |
%} | |
/* Todos outros tokens não especificados. */ | |
OTHERS . | |
/* Ignora todos espaços, tabs e semelhantes. */ | |
SPACE_TABS [[:space:]]+ | |
/* Inteiros. */ | |
INTEGER [0-9]+ | |
%% | |
{INTEGER} { | |
yylval.token.type = TOKEN_INTEGER; | |
yylval.token.integer = atoi(yytext); | |
return TOKEN; | |
} | |
{SPACE_TABS} ; | |
{OTHERS} { | |
yylval.token.type = TOKEN_UNKNOWN; | |
yylval.token.unknown = strdup(yytext); | |
return TOKEN; | |
} | |
%% | |
int yywrap () { | |
return 1; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment