Created
March 27, 2022 05:15
-
-
Save melchisedech333/af619f2f423b6aa7a5124622cda0c9b9 to your computer and use it in GitHub Desktop.
Lexer da análise dos arrays
This file contains hidden or 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); | |
%} | |
CHARS [a-zA-Z0-9]+ | |
STRING \"{CHARS}\" | |
NUMBER [0-9]+ | |
IDENTIFIER {CHARS} | |
VARTYPE [:]{CHARS} | |
SPACETABS [ \t\n] | |
%% | |
var { | |
return START; | |
} | |
{STRING} { | |
yylval.value = strdup(yytext); | |
return STRING; | |
} | |
{NUMBER} { | |
yylval.value = strdup(yytext); | |
return INTEGER; | |
} | |
{IDENTIFIER} { | |
yylval.value = strdup(yytext); | |
return VARIABLE; | |
} | |
{VARTYPE} { | |
yylval.value = strdup(yytext); | |
return TYPE; | |
} | |
\[ { return ARRAY_A_OPEN; } | |
\] { return ARRAY_A_CLOSE; } | |
= { return ATTR; } | |
, { return SEPARATOR; } | |
; { return END; } | |
{SPACETABS} { } | |
%% | |
int yywrap () { | |
return 1; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment