Mon, 31 Dec 2001 07:25:08 +0000
*** empty log message ***
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@5 | 9 | double fp; |
eric@5 | 10 | char *string; |
eric@18 | 11 | page_size_t size; |
eric@18 | 12 | range_t 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@20 | 41 | %token FORMAT |
eric@5 | 42 | %token PAGE |
eric@8 | 43 | %token PAGES |
eric@5 | 44 | %token BOOKMARK |
eric@5 | 45 | %token OUTPUT |
eric@5 | 46 | |
eric@11 | 47 | %type <range> range |
eric@11 | 48 | %type <range> image_ranges |
eric@11 | 49 | %type <range> page_ranges |
eric@11 | 50 | |
eric@11 | 51 | %type <fp> unit |
eric@11 | 52 | |
eric@11 | 53 | |
eric@9 | 54 | |
eric@9 | 55 | %type <fp> length |
eric@5 | 56 | |
eric@5 | 57 | %% |
eric@5 | 58 | |
eric@9 | 59 | statements: |
eric@9 | 60 | statement |
eric@9 | 61 | | statements statement ; |
eric@5 | 62 | |
eric@9 | 63 | statement: |
eric@9 | 64 | input_statement |
eric@9 | 65 | | output_statement ; |
eric@5 | 66 | |
eric@5 | 67 | |
eric@11 | 68 | range: |
eric@11 | 69 | INTEGER ELIPSIS INTEGER { $$.first = $1; $$.last = $3; } |
eric@11 | 70 | | INTEGER { $$.first = $1; $$.last = $1; } ; |
eric@5 | 71 | |
eric@9 | 72 | image_ranges: |
eric@20 | 73 | range { input_images ($1); } |
eric@20 | 74 | | image_ranges ',' range { input_images ($3); } ; |
eric@5 | 75 | |
eric@5 | 76 | |
eric@12 | 77 | input_file_clause: |
eric@17 | 78 | FILE_KEYWORD STRING ';' { input_set_file ($2) } ; |
eric@5 | 79 | |
eric@5 | 80 | image_clause: |
eric@20 | 81 | IMAGE INTEGER ';' { range_t range = { $2, $2 }; input_images (range); } ; |
eric@9 | 82 | |
eric@9 | 83 | images_clause: |
eric@19 | 84 | IMAGES image_ranges ';' ; |
eric@5 | 85 | |
eric@5 | 86 | rotate_clause: |
eric@20 | 87 | ROTATE INTEGER ';' { input_set_rotation ($2) } ; |
eric@5 | 88 | |
eric@9 | 89 | unit: |
eric@11 | 90 | /* empty */ /* default to INCH */ { $$ = 25.4; } |
eric@11 | 91 | | CM { $$ = 1.0; } |
eric@11 | 92 | | INCH { $$ = 25.4; } ; |
eric@9 | 93 | |
eric@9 | 94 | length: |
eric@11 | 95 | FLOAT unit { $$ = $1 * $2; } ; |
eric@9 | 96 | |
eric@5 | 97 | crop_clause: |
eric@9 | 98 | CROP PAGE_SIZE ';' |
eric@9 | 99 | | CROP PAGE_SIZE orientation ';' |
eric@9 | 100 | | CROP length ',' length ';' |
eric@9 | 101 | | CROP length ',' length ',' length ',' length ';' ; |
eric@9 | 102 | |
eric@9 | 103 | orientation: |
eric@9 | 104 | PORTRAIT |
eric@9 | 105 | | LANDSCAPE ; |
eric@5 | 106 | |
eric@5 | 107 | size_clause: |
eric@9 | 108 | SIZE PAGE_SIZE ';' |
eric@9 | 109 | | SIZE PAGE_SIZE orientation ';' |
eric@9 | 110 | | SIZE length ',' length ';' ; |
eric@9 | 111 | |
eric@11 | 112 | resolution_clause: |
eric@11 | 113 | RESOLUTION FLOAT unit ; |
eric@11 | 114 | |
eric@9 | 115 | modifier_clause: |
eric@11 | 116 | rotate_clause | crop_clause | size_clause | resolution_clause; |
eric@9 | 117 | |
eric@9 | 118 | modifier_clauses: |
eric@9 | 119 | modifier_clause |
eric@9 | 120 | | modifier_clauses modifier_clause; |
eric@9 | 121 | |
eric@9 | 122 | modifier_clause_list: |
eric@9 | 123 | '{' modifier_clauses '}' ; |
eric@5 | 124 | |
eric@5 | 125 | part_clause: |
eric@19 | 126 | ODD { input_set_modifier_context (INPUT_MODIFIER_ODD); } |
eric@19 | 127 | modifier_clause_list ';' |
eric@19 | 128 | { input_set_modifier_context (INPUT_MODIFIER_ALL); } |
eric@20 | 129 | | EVEN { input_set_modifier_context (INPUT_MODIFIER_EVEN); } |
eric@19 | 130 | modifier_clause_list ';' |
eric@19 | 131 | { input_set_modifier_context (INPUT_MODIFIER_ALL); } ; |
eric@5 | 132 | |
eric@5 | 133 | input_clause: |
eric@12 | 134 | input_file_clause |
eric@9 | 135 | | image_clause |
eric@9 | 136 | | images_clause |
eric@19 | 137 | | part_clause |
eric@9 | 138 | | modifier_clause |
eric@7 | 139 | | input_clause_list ; |
eric@5 | 140 | |
eric@5 | 141 | input_clauses: |
eric@5 | 142 | input_clause |
eric@7 | 143 | | input_clauses input_clause ; |
eric@7 | 144 | |
eric@7 | 145 | input_clause_list: |
eric@7 | 146 | '{' input_clauses '}' ; |
eric@5 | 147 | |
eric@5 | 148 | input_statement: |
eric@8 | 149 | INPUT input_clauses ; |
eric@5 | 150 | |
eric@12 | 151 | output_file_clause: |
eric@17 | 152 | FILE_KEYWORD STRING ';' { output_set_file ($2) } ; |
eric@12 | 153 | |
eric@20 | 154 | format_clause: |
eric@20 | 155 | FORMAT STRING ';' { output_set_page_number_format ($2) } ; |
eric@20 | 156 | |
eric@9 | 157 | page_ranges: |
eric@20 | 158 | range { output_pages ($1); } |
eric@20 | 159 | | page_ranges ',' range { output_pages ($3); } ; |
eric@9 | 160 | |
eric@5 | 161 | page_clause: |
eric@20 | 162 | PAGE INTEGER ';' { range_t range = { $2, $2 }; output_pages (range); } ; |
eric@8 | 163 | |
eric@8 | 164 | pages_clause: |
eric@20 | 165 | PAGES page_ranges ';' ; |
eric@20 | 166 | |
eric@20 | 167 | bookmark_name: |
eric@20 | 168 | STRING { output_set_bookmark ($1); } ; |
eric@20 | 169 | |
eric@20 | 170 | bookmark_name_list: |
eric@20 | 171 | bookmark_name |
eric@20 | 172 | | bookmark_name_list ',' bookmark_name ; |
eric@5 | 173 | |
eric@5 | 174 | bookmark_clause: |
eric@20 | 175 | BOOKMARK { output_push_context (); } |
eric@20 | 176 | bookmark_name_list |
eric@20 | 177 | output_clause_list ';' { output_pop_context (); } ; |
eric@5 | 178 | |
eric@5 | 179 | output_clause: |
eric@12 | 180 | output_file_clause |
eric@20 | 181 | | format_clause |
eric@12 | 182 | | page_clause | pages_clause |
eric@12 | 183 | | bookmark_clause |
eric@7 | 184 | | output_clause_list ; |
eric@5 | 185 | |
eric@5 | 186 | output_clauses: |
eric@5 | 187 | output_clause |
eric@7 | 188 | | output_clauses output_clause ; |
eric@7 | 189 | |
eric@7 | 190 | output_clause_list: |
eric@20 | 191 | '{' { output_push_context (); } |
eric@20 | 192 | output_clauses '}' { output_pop_context (); } ; |
eric@5 | 193 | |
eric@5 | 194 | output_statement: |
eric@8 | 195 | OUTPUT output_clauses ; |