]> Pileus Git - ~andy/ct/commitdiff
Fix bugs
authorAndy Spencer <andy753421@gmail.com>
Sun, 22 Nov 2009 05:50:26 +0000 (05:50 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sun, 22 Nov 2009 05:50:26 +0000 (05:50 +0000)
mkfile
parse.y
scan.l

diff --git a/mkfile b/mkfile
index 8f43ffdd6ad3852952231850bdec3bd993827174..c7e4898687fd9bc2d82d2543a37540befa88feee 100644 (file)
--- 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 11eb57cd4e58b4a7de31240ad69a9ebcc0fbf38d..84a62be4733e0062a3d2c80711507ca1b335d383 100644 (file)
--- 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 19f6777f48227aaed311d2d0c848371f048da239..c1b61e7082daf98c6828748d41aab2d7de71e67a 100644 (file)
--- a/scan.l
+++ b/scan.l
 /* %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]"); }
 %%