2016-09-20 22:43:10 +00:00
|
|
|
%{
|
2016-09-24 22:21:46 +00:00
|
|
|
#include <stdbool.h>
|
2016-10-16 15:58:01 +00:00
|
|
|
#include <stdint.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-10-21 21:31:00 +00:00
|
|
|
<QSTRING>[%$][a-zA-Z_][a-zA_Z_0-9]+(\.[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;
|
2016-10-20 19:47:28 +00:00
|
|
|
"aliases" return ALIASES;
|
2016-10-14 23:15:08 +00:00
|
|
|
"corrupted" return CORRUPTED;
|
2016-09-25 20:17:14 +00:00
|
|
|
"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-21 21:31:00 +00:00
|
|
|
"named" return NAMED;
|
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; }
|
2016-10-09 10:32:36 +00:00
|
|
|
-?[0-9]+ { yylval.n = atoi(yytext); return INT; }
|
|
|
|
-?0x[0-9a-fA-F]+ { yylval.n = strtol(yytext, NULL, 0); return INT; }
|
2016-09-20 22:43:10 +00:00
|
|
|
[ \t\r\n]* ;
|
|
|
|
. return yytext[0];
|
|
|
|
|
|
|
|
%%
|
|
|
|
/* vim: set sw=4 ts=4 expandtab : */
|