From ea1ec85fd94e887ad47403458f416d01b2af2213 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sun, 22 Nov 2009 05:50:26 +0000 Subject: [PATCH] Fix bugs --- mkfile | 11 ++++++----- parse.y | 2 +- scan.l | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/mkfile b/mkfile index 8f43ffd..c7e4898 100644 --- a/mkfile +++ b/mkfile @@ -2,10 +2,11 @@ PROGS=ct 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 diff --git a/parse.y b/parse.y index 11eb57c..84a62be 100644 --- a/parse.y +++ b/parse.y @@ -20,7 +20,7 @@ all : data | code | print ; 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", diff --git a/scan.l b/scan.l index 19f6777..c1b61e7 100644 --- a/scan.l +++ b/scan.l @@ -10,14 +10,14 @@ /* %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]"); } {START} { debug("START [%s]"); yylval = g_strdup(yytext); BEGIN(IN); return START; } {DATA} { debug("DATA [%s]"); yylval = g_strdup(yytext); return DATA; } {END} { debug("END [%s]"); yylval = g_strdup(yytext); BEGIN(INITIAL); return END; } = { debug("OUT [%s]"); yylval = g_strdup(yytext); return OUT; } {CODE} { debug("CODE [%s]"); yylval = g_strdup(yytext); return DATA; } -[\n] { debug("NL [%s]"); } %% -- 2.43.2