Sun, 30 Dec 2001 04:16:46 +0000
*** empty log message ***
eric@5 | 1 | %{ |
eric@11 | 2 | #include <stdio.h> |
eric@11 | 3 | #include "type.h" |
eric@11 | 4 | #include "tiff2pdf.h" |
eric@5 | 5 | %} |
eric@5 | 6 | |
eric@5 | 7 | %union { |
eric@5 | 8 | int integer; |
eric@5 | 9 | double fp; |
eric@5 | 10 | char *string; |
eric@11 | 11 | struct { double width; double height; } size; |
eric@11 | 12 | struct { int first; int last; } range; |
eric@5 | 13 | } |
eric@5 | 14 | |
eric@5 | 15 | %token <integer> INTEGER |
eric@5 | 16 | %token <fp> FLOAT |
eric@5 | 17 | %token <string> STRING |
eric@9 | 18 | %token <size> PAGE_SIZE |
eric@5 | 19 | |
eric@7 | 20 | %token ELIPSIS |
eric@7 | 21 | |
eric@9 | 22 | %token CM |
eric@9 | 23 | %token INCH |
eric@9 | 24 | |
eric@5 | 25 | %token EVEN |
eric@5 | 26 | %token ODD |
eric@5 | 27 | %token ALL |
eric@5 | 28 | |
eric@9 | 29 | %token PORTRAIT |
eric@9 | 30 | %token LANDSCAPE |
eric@9 | 31 | |
eric@11 | 32 | %token FILE_KEYWORD |
eric@5 | 33 | %token IMAGE |
eric@9 | 34 | %token IMAGES |
eric@5 | 35 | %token ROTATE |
eric@5 | 36 | %token CROP |
eric@5 | 37 | %token SIZE |
eric@11 | 38 | %token RESOLUTION |
eric@5 | 39 | %token INPUT |
eric@5 | 40 | |
eric@5 | 41 | %token PAGE |
eric@8 | 42 | %token PAGES |
eric@5 | 43 | %token BOOKMARK |
eric@5 | 44 | %token OUTPUT |
eric@5 | 45 | |
eric@11 | 46 | %type <range> range |
eric@11 | 47 | %type <range> image_ranges |
eric@11 | 48 | %type <range> page_ranges |
eric@11 | 49 | |
eric@11 | 50 | %type <fp> unit |
eric@11 | 51 | |
eric@11 | 52 | |
eric@9 | 53 | |
eric@9 | 54 | %type <fp> length |
eric@5 | 55 | |
eric@5 | 56 | %% |
eric@5 | 57 | |
eric@9 | 58 | statements: |
eric@9 | 59 | statement |
eric@9 | 60 | | statements statement ; |
eric@5 | 61 | |
eric@9 | 62 | statement: |
eric@9 | 63 | input_statement |
eric@9 | 64 | | output_statement ; |
eric@5 | 65 | |
eric@5 | 66 | |
eric@11 | 67 | range: |
eric@11 | 68 | INTEGER ELIPSIS INTEGER { $$.first = $1; $$.last = $3; } |
eric@11 | 69 | | INTEGER { $$.first = $1; $$.last = $1; } ; |
eric@5 | 70 | |
eric@9 | 71 | image_ranges: |
eric@15 | 72 | range { input_images ($1.first, $1.last); } |
eric@15 | 73 | | image_ranges ',' range { input_images ($3.first, $3.last); } ; |
eric@5 | 74 | |
eric@5 | 75 | |
eric@12 | 76 | input_file_clause: |
eric@12 | 77 | FILE_KEYWORD STRING ';' { open_tiff_input_file ($2) } ; |
eric@5 | 78 | |
eric@5 | 79 | image_clause: |
eric@15 | 80 | IMAGE INTEGER ';' { input_images ($2, $2); } |
eric@15 | 81 | | IMAGE INTEGER modifier_clause_list ';' { input_images ($2, $2); } ; |
eric@9 | 82 | |
eric@9 | 83 | images_clause: |
eric@9 | 84 | IMAGES image_ranges ';' |
eric@9 | 85 | | IMAGES image_ranges modifier_clause_list ';' |
eric@9 | 86 | | IMAGES image_ranges part_clauses ';' ; |
eric@5 | 87 | |
eric@5 | 88 | rotate_clause: |
eric@5 | 89 | ROTATE INTEGER ';' ; |
eric@5 | 90 | |
eric@9 | 91 | unit: |
eric@11 | 92 | /* empty */ /* default to INCH */ { $$ = 25.4; } |
eric@11 | 93 | | CM { $$ = 1.0; } |
eric@11 | 94 | | INCH { $$ = 25.4; } ; |
eric@9 | 95 | |
eric@9 | 96 | length: |
eric@11 | 97 | FLOAT unit { $$ = $1 * $2; } ; |
eric@9 | 98 | |
eric@5 | 99 | crop_clause: |
eric@9 | 100 | CROP PAGE_SIZE ';' |
eric@9 | 101 | | CROP PAGE_SIZE orientation ';' |
eric@9 | 102 | | CROP length ',' length ';' |
eric@9 | 103 | | CROP length ',' length ',' length ',' length ';' ; |
eric@9 | 104 | |
eric@9 | 105 | orientation: |
eric@9 | 106 | PORTRAIT |
eric@9 | 107 | | LANDSCAPE ; |
eric@5 | 108 | |
eric@5 | 109 | size_clause: |
eric@9 | 110 | SIZE PAGE_SIZE ';' |
eric@9 | 111 | | SIZE PAGE_SIZE orientation ';' |
eric@9 | 112 | | SIZE length ',' length ';' ; |
eric@9 | 113 | |
eric@11 | 114 | resolution_clause: |
eric@11 | 115 | RESOLUTION FLOAT unit ; |
eric@11 | 116 | |
eric@9 | 117 | modifier_clause: |
eric@11 | 118 | rotate_clause | crop_clause | size_clause | resolution_clause; |
eric@9 | 119 | |
eric@9 | 120 | modifier_clauses: |
eric@9 | 121 | modifier_clause |
eric@9 | 122 | | modifier_clauses modifier_clause; |
eric@9 | 123 | |
eric@9 | 124 | modifier_clause_list: |
eric@9 | 125 | '{' modifier_clauses '}' ; |
eric@5 | 126 | |
eric@5 | 127 | part: |
eric@7 | 128 | EVEN | ODD | ALL ; |
eric@5 | 129 | |
eric@5 | 130 | part_clause: |
eric@9 | 131 | part modifier_clause_list; |
eric@9 | 132 | |
eric@9 | 133 | part_clauses: |
eric@9 | 134 | part_clause |
eric@9 | 135 | | part_clauses part_clause; |
eric@5 | 136 | |
eric@5 | 137 | input_clause: |
eric@12 | 138 | input_file_clause |
eric@9 | 139 | | image_clause |
eric@9 | 140 | | images_clause |
eric@9 | 141 | | modifier_clause |
eric@7 | 142 | | input_clause_list ; |
eric@5 | 143 | |
eric@5 | 144 | input_clauses: |
eric@5 | 145 | input_clause |
eric@7 | 146 | | input_clauses input_clause ; |
eric@7 | 147 | |
eric@7 | 148 | input_clause_list: |
eric@7 | 149 | '{' input_clauses '}' ; |
eric@5 | 150 | |
eric@5 | 151 | input_statement: |
eric@8 | 152 | INPUT input_clauses ; |
eric@5 | 153 | |
eric@12 | 154 | output_file_clause: |
eric@12 | 155 | FILE_KEYWORD STRING ';' { open_pdf_output_file ($2) } ; |
eric@12 | 156 | |
eric@9 | 157 | page_ranges: |
eric@15 | 158 | range { output_pages ($1.first, $1.last); } |
eric@15 | 159 | | page_ranges ',' range { output_pages ($3.first, $3.last); } ; |
eric@9 | 160 | |
eric@5 | 161 | page_clause: |
eric@15 | 162 | PAGE INTEGER ';' { output_pages ($2, $2); } |
eric@15 | 163 | | PAGE STRING ',' INTEGER ';' { output_pages ($4, $4); } ; |
eric@8 | 164 | |
eric@8 | 165 | pages_clause: |
eric@9 | 166 | PAGES page_ranges ';' |
eric@9 | 167 | | PAGES STRING ',' page_ranges ';' ; |
eric@5 | 168 | |
eric@5 | 169 | bookmark_clause: |
eric@8 | 170 | BOOKMARK INTEGER ',' STRING ';' |
eric@8 | 171 | | BOOKMARK STRING ';' ; |
eric@5 | 172 | |
eric@5 | 173 | output_clause: |
eric@12 | 174 | output_file_clause |
eric@12 | 175 | | page_clause | pages_clause |
eric@12 | 176 | | bookmark_clause |
eric@7 | 177 | | output_clause_list ; |
eric@5 | 178 | |
eric@5 | 179 | output_clauses: |
eric@5 | 180 | output_clause |
eric@7 | 181 | | output_clauses output_clause ; |
eric@7 | 182 | |
eric@7 | 183 | output_clause_list: |
eric@7 | 184 | '{' output_clauses '}' ; |
eric@5 | 185 | |
eric@5 | 186 | output_statement: |
eric@8 | 187 | OUTPUT output_clauses ; |