Skip to content

Instantly share code, notes, and snippets.

@melchisedech333
Created March 27, 2022 02:19
Show Gist options
  • Save melchisedech333/552ffe8bf51ade73a68dea639245aae9 to your computer and use it in GitHub Desktop.
Save melchisedech333/552ffe8bf51ade73a68dea639245aae9 to your computer and use it in GitHub Desktop.
Lexer - chave e valor
%{
#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