Created
March 27, 2022 02:19
-
-
Save melchisedech333/552ffe8bf51ade73a68dea639245aae9 to your computer and use it in GitHub Desktop.
Lexer - chave e valor
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); | |
%} | |
CHARS [a-zA-Z0-9]+ | |
STRING \"{CHARS}\" | |
INTEGER [0-9]+ | |
SPACETABS [ \t\n] | |
%% | |
\{ { return OPEN; } | |
\} { return CLOSE; } | |
: { return ATTR; } | |
{STRING} { | |
yylval.value = strdup(yytext); | |
return JSTRING; | |
} | |
{INTEGER} { | |
yylval.value = strdup(yytext); | |
return JINTEGER; | |
} | |
, { | |
return SEPARATOR; | |
} | |
{SPACETABS} { } | |
%% | |
int yywrap () { | |
return 1; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment