Sun, 30 Dec 2001 04:16:46 +0000
*** empty log message ***
Makefile | file | annotate | diff | revisions | |
parser.y | file | annotate | diff | revisions | |
scanner.l | file | annotate | diff | revisions | |
t2p.h | file | annotate | diff | revisions | |
tumble.h | file | annotate | diff | revisions |
1.1 diff -r 4c261fbf8c77 -r dda3d673b82b Makefile 1.2 --- a/Makefile Sun Dec 30 04:16:46 2001 +0000 1.3 +++ b/Makefile Sun Dec 30 04:16:46 2001 +0000 1.4 @@ -1,6 +1,6 @@ 1.5 # tiff2pdf: build a PDF file out of one or more TIFF Class F Group 4 files 1.6 # Makefile 1.7 -# $Id: Makefile,v 1.5 2001/12/29 10:59:17 eric Exp $ 1.8 +# $Id: Makefile,v 1.6 2001/12/29 20:16:46 eric Exp $ 1.9 # Copyright 2001 Eric Smith <eric@brouhaha.com> 1.10 # 1.11 # This program is free software; you can redistribute it and/or modify 1.12 @@ -28,14 +28,33 @@ 1.13 HDRS = type.h bitblt.h tiff2pdf.h 1.14 MISC = Makefile scanner.l parser.y 1.15 1.16 +TARGETS = tiff2pdf bitblt_test 1.17 + 1.18 +AUTO_SRCS = scanner.c parser.tab.c 1.19 +AUTO_HDRS = parser.tab.h 1.20 +AUTO_MISC = parser.output 1.21 + 1.22 tiff2pdf: tiff2pdf.o scanner.o parser.tab.o 1.23 1.24 bitblt_test: bitblt_test.o bitblt.o 1.25 1.26 1.27 -%.tab.c %.tab.h: %.y 1.28 +clean: 1.29 + rm -f *.o *.d $(TARGETS) $(AUTO_SRCS) $(AUTO_HDRS) $(AUTO_MISC) 1.30 + 1.31 + 1.32 +%.tab.c %.tab.h %.output: %.y 1.33 $(YACC) $(YFLAGS) $< 1.34 1.35 # %.c: %.l 1.36 # $(LEX) $(LFLAGS) $< 1.37 1.38 + 1.39 +ALL_SRCS = $(SRCS) $(AUTO_SRCS) 1.40 + 1.41 +DEPENDS = $(ALL_SRCS:.c=.d) 1.42 + 1.43 +%.d: %.c 1.44 + $(CC) -M -MG $(CFLAGS) $< | sed -e 's@ /[^ ]*@@g' -e 's@^\(.*\)\.o:@\1.d \1.o:@' > $@ 1.45 + 1.46 +include $(DEPENDS)
2.1 diff -r 4c261fbf8c77 -r dda3d673b82b parser.y 2.2 --- a/parser.y Sun Dec 30 04:16:46 2001 +0000 2.3 +++ b/parser.y Sun Dec 30 04:16:46 2001 +0000 2.4 @@ -69,16 +69,16 @@ 2.5 | INTEGER { $$.first = $1; $$.last = $1; } ; 2.6 2.7 image_ranges: 2.8 - range 2.9 - | image_ranges ',' range ; 2.10 + range { input_images ($1.first, $1.last); } 2.11 + | image_ranges ',' range { input_images ($3.first, $3.last); } ; 2.12 2.13 2.14 input_file_clause: 2.15 FILE_KEYWORD STRING ';' { open_tiff_input_file ($2) } ; 2.16 2.17 image_clause: 2.18 - IMAGE INTEGER ';' 2.19 - | IMAGE INTEGER modifier_clause_list ';' ; 2.20 + IMAGE INTEGER ';' { input_images ($2, $2); } 2.21 + | IMAGE INTEGER modifier_clause_list ';' { input_images ($2, $2); } ; 2.22 2.23 images_clause: 2.24 IMAGES image_ranges ';' 2.25 @@ -155,12 +155,12 @@ 2.26 FILE_KEYWORD STRING ';' { open_pdf_output_file ($2) } ; 2.27 2.28 page_ranges: 2.29 - range 2.30 - | page_ranges ',' range ; 2.31 + range { output_pages ($1.first, $1.last); } 2.32 + | page_ranges ',' range { output_pages ($3.first, $3.last); } ; 2.33 2.34 page_clause: 2.35 - PAGE INTEGER ';' 2.36 - | PAGE STRING ',' INTEGER ';' ; 2.37 + PAGE INTEGER ';' { output_pages ($2, $2); } 2.38 + | PAGE STRING ',' INTEGER ';' { output_pages ($4, $4); } ; 2.39 2.40 pages_clause: 2.41 PAGES page_ranges ';'
3.1 diff -r 4c261fbf8c77 -r dda3d673b82b scanner.l 3.2 --- a/scanner.l Sun Dec 30 04:16:46 2001 +0000 3.3 +++ b/scanner.l Sun Dec 30 04:16:46 2001 +0000 3.4 @@ -1,25 +1,36 @@ 3.5 /* 3.6 -$Id: scanner.l,v 1.7 2001/12/29 17:54:43 eric Exp $ 3.7 +$Id: scanner.l,v 1.8 2001/12/29 20:16:46 eric Exp $ 3.8 */ 3.9 3.10 %option case-insensitive 3.11 %option noyywrap 3.12 3.13 %{ 3.14 +#include <stdio.h> 3.15 #include <string.h> 3.16 #include "parser.tab.h" 3.17 +#include "type.h" 3.18 +#include "tiff2pdf.h" 3.19 + 3.20 +#ifdef SCANNER_DEBUG 3.21 +#define LDBG(x) printf x 3.22 +#else 3.23 +#define LDBG(x) 3.24 +#endif 3.25 %} 3.26 3.27 3.28 digit [0-9] 3.29 alpha [a-zA-Z] 3.30 +dot [\.] 3.31 3.32 %% 3.33 3.34 -\.\. { return (ELIPSIS); } 3.35 +[\,;{}] { return (yytext [0]); } 3.36 +{dot}{dot} { LDBG(("elipsis\n")); return (ELIPSIS); } 3.37 3.38 -{digit}+ { yylval.integer = atoi (yytext); return (INTEGER); } 3.39 -{digit}+.{digit}* { yylval.fp = atof (yytext); return (FLOAT); } 3.40 +{digit}+ { yylval.integer = atoi (yytext); LDBG(("integer %d\n", yylval.integer)); return (INTEGER); } 3.41 +{digit}+\.{digit}+ { yylval.fp = atof (yytext); return (FLOAT); } 3.42 3.43 a { yylval.size.width = 8.5 * 25.4; 3.44 yylval.size.height = 11.0 * 25.4; 3.45 @@ -57,12 +68,21 @@ 3.46 rotate { return (ROTATE); } 3.47 size { return (SIZE); } 3.48 3.49 -\".*\" { yylval.string = strdup (yytext); return (STRING); } 3.50 +\".*\" { 3.51 + int len = strlen (yytext) - 2; 3.52 + yylval.string = malloc (len + 1); 3.53 + memcpy (yylval.string, yytext + 1, len); 3.54 + yylval.string [len] = '\0'; 3.55 + LDBG (("string \"%s\"\n", yylval.string)); 3.56 + return (STRING); 3.57 + } 3.58 3.59 -[ \t\n]+ /* whitespace */ 3.60 +[ \t]+ /* whitespace */ 3.61 +\n { line++; } 3.62 3.63 --.* /* Ada/VHDL style one-line comment */ 3.64 +#.* /* shell-style one-line comment */ 3.65 3.66 -. { printf( "Unrecognized character: %s\n", yytext ); } 3.67 +. { fprintf (stderr, "Unrecognized character: %s\n", yytext); } 3.68 3.69 %%
4.1 diff -r 4c261fbf8c77 -r dda3d673b82b t2p.h 4.2 --- a/t2p.h Sun Dec 30 04:16:46 2001 +0000 4.3 +++ b/t2p.h Sun Dec 30 04:16:46 2001 +0000 4.4 @@ -1,3 +1,5 @@ 4.5 +extern int line; 4.6 + 4.7 boolean open_tiff_input_file (char *name); 4.8 boolean close_tiff_input_file (void); 4.9 4.10 @@ -5,3 +7,13 @@ 4.11 boolean close_pdf_output_file (void); 4.12 4.13 boolean process_page (int image); /* range 1 .. n */ 4.14 + 4.15 +void input_images (int first, int last); 4.16 +void output_pages (int first, int last); 4.17 + 4.18 + 4.19 + 4.20 + 4.21 + 4.22 + 4.23 +
5.1 diff -r 4c261fbf8c77 -r dda3d673b82b tumble.h 5.2 --- a/tumble.h Sun Dec 30 04:16:46 2001 +0000 5.3 +++ b/tumble.h Sun Dec 30 04:16:46 2001 +0000 5.4 @@ -1,3 +1,5 @@ 5.5 +extern int line; 5.6 + 5.7 boolean open_tiff_input_file (char *name); 5.8 boolean close_tiff_input_file (void); 5.9 5.10 @@ -5,3 +7,13 @@ 5.11 boolean close_pdf_output_file (void); 5.12 5.13 boolean process_page (int image); /* range 1 .. n */ 5.14 + 5.15 +void input_images (int first, int last); 5.16 +void output_pages (int first, int last); 5.17 + 5.18 + 5.19 + 5.20 + 5.21 + 5.22 + 5.23 +