]> Pileus Git - ~andy/ct/blob - scan.l
Add timestamp checking
[~andy/ct] / scan.l
1 %{
2 #define YYSTYPE char *
3 #include <glib.h>
4 #include "parse.h"
5 #define debug(arg) // g_message("scan: " arg, yytext);
6 %}
7 %option noyywrap
8 %option nounput
9 %option noinput
10 %option yylineno
11 %option never-interactive
12 /* %option nodebug */
13 START [ \t]*<%
14 END   [ \t]*%>
15 DATA  ([^<\n]|<[^%])*\n*
16 CODE  [ \t\n]([^%\n]|%[^>])*\n*
17 %s IN
18 %%
19 [[:space:]]*\n   { debug("NL    [%s]"); }
20 <INITIAL>{START} { debug("START [%s]"); yylval = g_strdup(yytext); BEGIN(IN);      return START; }
21 <INITIAL>{DATA}  { debug("DATA  [%s]"); yylval = g_strdup(yytext);                 return DATA;  }
22 <IN>{END}        { debug("END   [%s]"); yylval = g_strdup(yytext); BEGIN(INITIAL); return END;   }
23 <IN>=            { debug("OUT   [%s]"); yylval = g_strdup(yytext);                 return OUT;   }
24 <IN>%            { debug("FMT   [%s]"); yylval = g_strdup(yytext);                 return FMT;   }
25 <IN>{CODE}       { debug("CODE  [%s]"); yylval = g_strdup(yytext);                 return DATA;  }
26 %%