PKGS=glib-2.0
ct-test:V: ct
./ct < example/html.ct
-ct: ct.o scan.o parse.o parse.h
-%.c: %.l
- flex -o $target $prereq
-%.h %.c: %.y
- bison -d -o $stem.c $stem.y
+ct: ct.o parse.o scan.o
+ct.o: parse.h
+parse.h parse.c: parse.y
+ bison -d -o parse.c parse.y
+scan.c: scan.l parse.h
+ flex -o scan.c scan.l
CLEAN=parse.h parse.c scan.c
<$HOME/lib/mkcommon
data : DATA {
static int i = 0;
data = g_list_prepend(data, g_strdup_printf(
- "static char data%d[] = \"%s\\n\";\n",
+ "static char data%d[] = \"%s\";\n",
i, g_strescape($1, "")));
code = g_list_prepend(code, g_strdup_printf(
"fwrite(data%d, sizeof(data%d)-1, 1, stdout);\n",
/* %option nodebug */
START [ \t]*<%
END [ \t]*%>[ \t]*
-DATA ([^<\n]|<[^%])*
-CODE [ \t\n]([^%\n]|%[^>])*
+DATA ([^<\n]|<[^%])*\n*
+CODE [ \t\n]([^%\n]|%[^>])*\n*
%s IN FMT
%%
+[[:space:]]*\n { debug("NL [%s]"); }
<INITIAL>{START} { debug("START [%s]"); yylval = g_strdup(yytext); BEGIN(IN); return START; }
<INITIAL>{DATA} { debug("DATA [%s]"); yylval = g_strdup(yytext); return DATA; }
<IN>{END} { debug("END [%s]"); yylval = g_strdup(yytext); BEGIN(INITIAL); return END; }
<IN>= { debug("OUT [%s]"); yylval = g_strdup(yytext); return OUT; }
<IN>{CODE} { debug("CODE [%s]"); yylval = g_strdup(yytext); return DATA; }
-[\n] { debug("NL [%s]"); }
%%