]> Pileus Git - ~andy/ct/blob - scan.l
Update knots
[~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 nodebug */
11 START [ \t]*<%
12 END   [ \t]*%>[ \t]*
13 DATA  ([^<\n]|<[^%])*\n*
14 CODE  [ \t\n]([^%\n]|%[^>])*\n*
15 %s IN FMT
16 %%
17 [[:space:]]*\n   { debug("NL    [%s]"); }
18 <INITIAL>{START} { debug("START [%s]"); yylval = g_strdup(yytext); BEGIN(IN);      return START; }
19 <INITIAL>{DATA}  { debug("DATA  [%s]"); yylval = g_strdup(yytext);                 return DATA;  }
20 <IN>{END}        { debug("END   [%s]"); yylval = g_strdup(yytext); BEGIN(INITIAL); return END;   }
21 <IN>=            { debug("OUT   [%s]"); yylval = g_strdup(yytext);                 return OUT;   }
22 <IN>{CODE}       { debug("CODE  [%s]"); yylval = g_strdup(yytext);                 return DATA;  }
23 %%