Tue, 01 Jan 2002 10:16:50 +0000
added start of page size support.
eric@5 | 1 | %{ |
eric@11 | 2 | #include <stdio.h> |
eric@11 | 3 | #include "type.h" |
eric@17 | 4 | #include "semantics.h" |
eric@5 | 5 | %} |
eric@5 | 6 | |
eric@5 | 7 | %union { |
eric@5 | 8 | int integer; |
eric@27 | 9 | char character; |
eric@5 | 10 | double fp; |
eric@5 | 11 | char *string; |
eric@18 | 12 | page_size_t size; |
eric@18 | 13 | range_t range; |
eric@27 | 14 | page_label_t page_label; |
eric@5 | 15 | } |
eric@5 | 16 | |
eric@5 | 17 | %token <integer> INTEGER |
eric@5 | 18 | %token <fp> FLOAT |
eric@5 | 19 | %token <string> STRING |
eric@27 | 20 | %token <character> CHARACTER |
eric@9 | 21 | %token <size> PAGE_SIZE |
eric@5 | 22 | |
eric@7 | 23 | %token ELIPSIS |
eric@7 | 24 | |
eric@9 | 25 | %token CM |
eric@9 | 26 | %token INCH |
eric@9 | 27 | |
eric@5 | 28 | %token EVEN |
eric@5 | 29 | %token ODD |
eric@5 | 30 | %token ALL |
eric@5 | 31 | |
eric@9 | 32 | %token PORTRAIT |
eric@9 | 33 | %token LANDSCAPE |
eric@9 | 34 | |
eric@11 | 35 | %token FILE_KEYWORD |
eric@5 | 36 | %token IMAGE |
eric@9 | 37 | %token IMAGES |
eric@5 | 38 | %token ROTATE |
eric@5 | 39 | %token CROP |
eric@5 | 40 | %token SIZE |
eric@11 | 41 | %token RESOLUTION |
eric@5 | 42 | %token INPUT |
eric@5 | 43 | |
eric@27 | 44 | %token LABEL |
eric@5 | 45 | %token PAGE |
eric@8 | 46 | %token PAGES |
eric@5 | 47 | %token BOOKMARK |
eric@5 | 48 | %token OUTPUT |
eric@5 | 49 | |
eric@30 | 50 | %token AUTHOR |
eric@30 | 51 | %token CREATOR |
eric@30 | 52 | %token TITLE |
eric@30 | 53 | %token SUBJECT |
eric@30 | 54 | %token KEYWORDS |
eric@30 | 55 | |
eric@11 | 56 | %type <range> range |
eric@11 | 57 | %type <range> image_ranges |
eric@11 | 58 | %type <range> page_ranges |
eric@11 | 59 | |
eric@11 | 60 | %type <fp> unit |
eric@11 | 61 | |
eric@32 | 62 | %type <fp> length |
eric@9 | 63 | |
eric@32 | 64 | %type <integer> orientation |
eric@32 | 65 | |
eric@32 | 66 | %type <size> page_size |
eric@5 | 67 | |
eric@5 | 68 | %% |
eric@5 | 69 | |
eric@9 | 70 | statements: |
eric@9 | 71 | statement |
eric@9 | 72 | | statements statement ; |
eric@5 | 73 | |
eric@9 | 74 | statement: |
eric@9 | 75 | input_statement |
eric@9 | 76 | | output_statement ; |
eric@5 | 77 | |
eric@5 | 78 | |
eric@11 | 79 | range: |
eric@11 | 80 | INTEGER ELIPSIS INTEGER { $$.first = $1; $$.last = $3; } |
eric@11 | 81 | | INTEGER { $$.first = $1; $$.last = $1; } ; |
eric@5 | 82 | |
eric@9 | 83 | image_ranges: |
eric@20 | 84 | range { input_images ($1); } |
eric@20 | 85 | | image_ranges ',' range { input_images ($3); } ; |
eric@5 | 86 | |
eric@5 | 87 | |
eric@12 | 88 | input_file_clause: |
eric@17 | 89 | FILE_KEYWORD STRING ';' { input_set_file ($2) } ; |
eric@5 | 90 | |
eric@5 | 91 | image_clause: |
eric@20 | 92 | IMAGE INTEGER ';' { range_t range = { $2, $2 }; input_images (range); } ; |
eric@9 | 93 | |
eric@9 | 94 | images_clause: |
eric@19 | 95 | IMAGES image_ranges ';' ; |
eric@5 | 96 | |
eric@5 | 97 | rotate_clause: |
eric@20 | 98 | ROTATE INTEGER ';' { input_set_rotation ($2) } ; |
eric@5 | 99 | |
eric@9 | 100 | unit: |
eric@32 | 101 | /* empty */ /* default to INCH */ { $$ = 1.0; } |
eric@32 | 102 | | CM { $$ = (1.0 / 25.4); } |
eric@32 | 103 | | INCH { $$ = 1.0; } ; |
eric@9 | 104 | |
eric@9 | 105 | length: |
eric@11 | 106 | FLOAT unit { $$ = $1 * $2; } ; |
eric@9 | 107 | |
eric@5 | 108 | crop_clause: |
eric@9 | 109 | CROP PAGE_SIZE ';' |
eric@9 | 110 | | CROP PAGE_SIZE orientation ';' |
eric@9 | 111 | | CROP length ',' length ';' |
eric@9 | 112 | | CROP length ',' length ',' length ',' length ';' ; |
eric@9 | 113 | |
eric@9 | 114 | orientation: |
eric@32 | 115 | PORTRAIT { $$ = 0; } |
eric@32 | 116 | | LANDSCAPE { $$ = 1; } ; |
eric@32 | 117 | |
eric@32 | 118 | page_size: |
eric@32 | 119 | PAGE_SIZE { $$ = $1; } |
eric@32 | 120 | | PAGE_SIZE orientation { if ($2) |
eric@32 | 121 | { |
eric@32 | 122 | $$.width = $1.height; |
eric@32 | 123 | $$.height = $1.width; |
eric@32 | 124 | } |
eric@32 | 125 | else |
eric@32 | 126 | $$ = $1; |
eric@32 | 127 | } |
eric@32 | 128 | | length ',' length { $$.width = $1; $$.height = $3; } ; |
eric@5 | 129 | |
eric@5 | 130 | size_clause: |
eric@32 | 131 | SIZE page_size ';' { input_set_page_size ($2); } ; |
eric@9 | 132 | |
eric@11 | 133 | resolution_clause: |
eric@11 | 134 | RESOLUTION FLOAT unit ; |
eric@11 | 135 | |
eric@9 | 136 | modifier_clause: |
eric@11 | 137 | rotate_clause | crop_clause | size_clause | resolution_clause; |
eric@9 | 138 | |
eric@9 | 139 | modifier_clauses: |
eric@9 | 140 | modifier_clause |
eric@9 | 141 | | modifier_clauses modifier_clause; |
eric@9 | 142 | |
eric@9 | 143 | modifier_clause_list: |
eric@9 | 144 | '{' modifier_clauses '}' ; |
eric@5 | 145 | |
eric@5 | 146 | part_clause: |
eric@19 | 147 | ODD { input_set_modifier_context (INPUT_MODIFIER_ODD); } |
eric@19 | 148 | modifier_clause_list ';' |
eric@19 | 149 | { input_set_modifier_context (INPUT_MODIFIER_ALL); } |
eric@20 | 150 | | EVEN { input_set_modifier_context (INPUT_MODIFIER_EVEN); } |
eric@19 | 151 | modifier_clause_list ';' |
eric@19 | 152 | { input_set_modifier_context (INPUT_MODIFIER_ALL); } ; |
eric@5 | 153 | |
eric@5 | 154 | input_clause: |
eric@12 | 155 | input_file_clause |
eric@9 | 156 | | image_clause |
eric@9 | 157 | | images_clause |
eric@19 | 158 | | part_clause |
eric@9 | 159 | | modifier_clause |
eric@7 | 160 | | input_clause_list ; |
eric@5 | 161 | |
eric@5 | 162 | input_clauses: |
eric@5 | 163 | input_clause |
eric@7 | 164 | | input_clauses input_clause ; |
eric@7 | 165 | |
eric@7 | 166 | input_clause_list: |
eric@7 | 167 | '{' input_clauses '}' ; |
eric@5 | 168 | |
eric@5 | 169 | input_statement: |
eric@8 | 170 | INPUT input_clauses ; |
eric@5 | 171 | |
eric@30 | 172 | pdf_file_attribute: |
eric@30 | 173 | AUTHOR STRING { output_set_author ($2); } |
eric@30 | 174 | | CREATOR STRING { output_set_creator ($2); } |
eric@30 | 175 | | TITLE STRING { output_set_title ($2); } |
eric@30 | 176 | | SUBJECT STRING { output_set_subject ($2); } |
eric@30 | 177 | | KEYWORDS STRING { output_set_keywords ($2); } ; |
eric@30 | 178 | |
eric@31 | 179 | pdf_file_attribute_list: |
eric@31 | 180 | pdf_file_attribute |
eric@31 | 181 | | pdf_file_attribute_list pdf_file_attribute ; |
eric@31 | 182 | |
eric@30 | 183 | pdf_file_attributes: |
eric@30 | 184 | /* empty */ |
eric@31 | 185 | | pdf_file_attribute_list ; |
eric@30 | 186 | |
eric@12 | 187 | output_file_clause: |
eric@30 | 188 | FILE_KEYWORD STRING { output_set_file ($2); } |
eric@30 | 189 | pdf_file_attributes ';' |
eric@12 | 190 | |
eric@27 | 191 | label_clause: |
eric@27 | 192 | LABEL ';' { page_label_t label = { NULL, '\0' }; output_set_page_label (label); } |
eric@27 | 193 | | LABEL STRING ';' { page_label_t label = { $2, '\0' }; output_set_page_label (label); } |
eric@27 | 194 | | LABEL CHARACTER ';' { page_label_t label = { NULL, $2 }; output_set_page_label (label); } |
eric@27 | 195 | | LABEL STRING ',' CHARACTER ';' { page_label_t label = { $2, $4 }; output_set_page_label (label); } ; |
eric@20 | 196 | |
eric@9 | 197 | page_ranges: |
eric@20 | 198 | range { output_pages ($1); } |
eric@20 | 199 | | page_ranges ',' range { output_pages ($3); } ; |
eric@9 | 200 | |
eric@5 | 201 | page_clause: |
eric@20 | 202 | PAGE INTEGER ';' { range_t range = { $2, $2 }; output_pages (range); } ; |
eric@8 | 203 | |
eric@8 | 204 | pages_clause: |
eric@20 | 205 | PAGES page_ranges ';' ; |
eric@20 | 206 | |
eric@20 | 207 | bookmark_name: |
eric@20 | 208 | STRING { output_set_bookmark ($1); } ; |
eric@20 | 209 | |
eric@20 | 210 | bookmark_name_list: |
eric@20 | 211 | bookmark_name |
eric@20 | 212 | | bookmark_name_list ',' bookmark_name ; |
eric@5 | 213 | |
eric@5 | 214 | bookmark_clause: |
eric@27 | 215 | BOOKMARK { output_push_context (); bookmark_level++; } |
eric@20 | 216 | bookmark_name_list |
eric@27 | 217 | output_clause_list ';' { bookmark_level--; output_pop_context (); } ; |
eric@5 | 218 | |
eric@5 | 219 | output_clause: |
eric@12 | 220 | output_file_clause |
eric@27 | 221 | | label_clause |
eric@12 | 222 | | page_clause | pages_clause |
eric@12 | 223 | | bookmark_clause |
eric@7 | 224 | | output_clause_list ; |
eric@5 | 225 | |
eric@5 | 226 | output_clauses: |
eric@5 | 227 | output_clause |
eric@7 | 228 | | output_clauses output_clause ; |
eric@7 | 229 | |
eric@7 | 230 | output_clause_list: |
eric@20 | 231 | '{' { output_push_context (); } |
eric@20 | 232 | output_clauses '}' { output_pop_context (); } ; |
eric@5 | 233 | |
eric@5 | 234 | output_statement: |
eric@8 | 235 | OUTPUT output_clauses ; |