2016-09-20 22:43:10 +00:00
|
|
|
%{
|
2016-09-24 22:21:46 +00:00
|
|
|
#include <stdbool.h>
|
2016-09-20 22:43:10 +00:00
|
|
|
#include "iburg.h"
|
|
|
|
#include "y.tab.h"
|
|
|
|
|
|
|
|
static int braces = 0;
|
|
|
|
|
|
|
|
%}
|
|
|
|
%option warn
|
|
|
|
%option nodefault
|
|
|
|
%option noyywrap
|
|
|
|
%option yylineno
|
2016-09-24 22:21:46 +00:00
|
|
|
%option debug
|
2016-09-20 22:43:10 +00:00
|
|
|
|
2016-09-24 22:21:46 +00:00
|
|
|
%x QSTRING
|
2016-09-25 09:49:51 +00:00
|
|
|
%x COMMENT
|
2016-09-20 22:43:10 +00:00
|
|
|
|
|
|
|
%%
|
|
|
|
|
2016-09-24 22:21:46 +00:00
|
|
|
<INITIAL>"\"" BEGIN(QSTRING);
|
|
|
|
<QSTRING>"\"" BEGIN(INITIAL);
|
|
|
|
|
2016-09-25 20:17:14 +00:00
|
|
|
<QSTRING>[%$][a-zA-Z_][a-zA_Z_0-9]+ {
|
2016-09-24 22:21:46 +00:00
|
|
|
yylval.string = strdup(yytext);
|
|
|
|
return QFRAGMENT;
|
|
|
|
}
|
|
|
|
|
2016-09-25 20:17:14 +00:00
|
|
|
<QSTRING>[^\r\n%$"]+ {
|
2016-09-24 22:21:46 +00:00
|
|
|
yylval.string = strdup(yytext);
|
|
|
|
return QFRAGMENT;
|
|
|
|
}
|
|
|
|
|
2016-09-25 09:49:51 +00:00
|
|
|
<INITIAL>"/*" BEGIN(COMMENT);
|
|
|
|
<COMMENT>"*/" BEGIN(INITIAL);
|
|
|
|
<COMMENT>[^*]* ;
|
|
|
|
<COMMENT>"*" ;
|
|
|
|
|
2016-09-25 20:17:14 +00:00
|
|
|
"DECLARATIONS" return DECLARATIONS;
|
2016-09-20 22:43:10 +00:00
|
|
|
"PATTERNS" return PATTERNS;
|
2016-09-25 20:17:14 +00:00
|
|
|
"REGISTERS" return REGISTERS;
|
|
|
|
"cost" return COST;
|
2016-09-20 22:43:10 +00:00
|
|
|
"emit" return EMIT;
|
2016-09-24 11:08:17 +00:00
|
|
|
"fragment" return FRAGMENT;
|
2016-10-01 11:56:52 +00:00
|
|
|
"prefers" return PREFERS;
|
2016-10-02 19:51:25 +00:00
|
|
|
"when" return WHEN;
|
|
|
|
"with" return WITH;
|
|
|
|
"==" return EQUALS;
|
|
|
|
"!=" return NOTEQUALS;
|
2016-09-20 22:43:10 +00:00
|
|
|
|
2016-09-25 09:49:51 +00:00
|
|
|
"//"[^\n]*\n ;
|
|
|
|
|
2016-09-20 22:43:10 +00:00
|
|
|
[A-Za-z_][A-Za-z0-9_]* { yylval.string = strdup(yytext); return ID; }
|
|
|
|
[0-9]+ { yylval.n = atoi(yytext); return INT; }
|
|
|
|
[ \t\r\n]* ;
|
|
|
|
. return yytext[0];
|
|
|
|
|
|
|
|
%%
|
|
|
|
/* vim: set sw=4 ts=4 expandtab : */
|