parser.y

Sat, 29 Dec 2001 17:45:43 +0000

author
eric
date
Sat, 29 Dec 2001 17:45:43 +0000
changeset 11
30d18cf8bb67
parent 9
de78038d990f
child 12
c3e2c2344560
permissions
-rw-r--r--

*** empty log message ***

     1 %{
     2   #include <stdio.h>
     3   #include "type.h"
     4   #include "tiff2pdf.h"
     5 %}
     7 %union {
     8   int integer;
     9   double fp;
    10   char *string;
    11   struct { double width; double height; } size;
    12   struct { int first; int last; } range;
    13 }
    15 %token <integer> INTEGER
    16 %token <fp> FLOAT
    17 %token <string> STRING
    18 %token <size> PAGE_SIZE
    20 %token ELIPSIS
    22 %token CM
    23 %token INCH
    25 %token EVEN
    26 %token ODD
    27 %token ALL
    29 %token PORTRAIT
    30 %token LANDSCAPE
    32 %token FILE_KEYWORD
    33 %token IMAGE
    34 %token IMAGES
    35 %token ROTATE
    36 %token CROP
    37 %token SIZE
    38 %token RESOLUTION
    39 %token INPUT
    41 %token PAGE
    42 %token PAGES
    43 %token BOOKMARK
    44 %token OUTPUT
    46 %type <range> range
    47 %type <range> image_ranges
    48 %type <range> page_ranges
    50 %type <fp> unit
    54 %type <fp> length
    56 %%
    58 statements: 
    59 	statement
    60 	| statements statement ;
    62 statement:
    63 	input_statement
    64 	| output_statement ;
    67 range:
    68 	INTEGER ELIPSIS INTEGER { $$.first = $1; $$.last = $3; }
    69 	| INTEGER { $$.first = $1; $$.last = $1; } ;
    71 image_ranges:
    72 	range
    73 	| image_ranges ',' range ;
    76 file_clause:
    77 	FILE_KEYWORD STRING  ';' ;
    79 image_clause:
    80 	IMAGE INTEGER ';'
    81 	| IMAGE INTEGER modifier_clause_list ';' ;
    83 images_clause:
    84 	IMAGES image_ranges ';'
    85 	| IMAGES image_ranges modifier_clause_list ';'
    86 	| IMAGES image_ranges part_clauses ';' ;
    88 rotate_clause:
    89 	ROTATE INTEGER ';' ;
    91 unit:
    92 	/* empty */  /* default to INCH */ { $$ = 25.4; }
    93 	| CM { $$ = 1.0; }
    94 	| INCH { $$ = 25.4; } ;
    96 length:
    97 	FLOAT unit { $$ = $1 * $2; } ;
    99 crop_clause:
   100 	CROP PAGE_SIZE ';'
   101 	| CROP PAGE_SIZE orientation ';'
   102 	| CROP length ',' length ';'
   103 	| CROP length ',' length ',' length ',' length ';' ;
   105 orientation:
   106 	PORTRAIT
   107 	| LANDSCAPE ;
   109 size_clause:
   110 	SIZE PAGE_SIZE ';'
   111 	| SIZE PAGE_SIZE orientation ';'
   112 	| SIZE length ',' length ';' ;
   114 resolution_clause:
   115 	RESOLUTION FLOAT unit ;
   117 modifier_clause:
   118 	rotate_clause | crop_clause | size_clause | resolution_clause;
   120 modifier_clauses:
   121 	modifier_clause
   122 	| modifier_clauses modifier_clause;
   124 modifier_clause_list:
   125 	'{' modifier_clauses '}' ;
   127 part:
   128 	EVEN | ODD | ALL ;
   130 part_clause:
   131 	part modifier_clause_list;
   133 part_clauses:
   134 	part_clause
   135 	| part_clauses part_clause;
   137 input_clause:
   138 	file_clause
   139 	| image_clause
   140 	| images_clause
   141 	| modifier_clause
   142 	| input_clause_list ;
   144 input_clauses:
   145 	input_clause
   146 	| input_clauses input_clause ;
   148 input_clause_list:
   149 	'{' input_clauses '}' ;
   151 input_statement:
   152 	INPUT input_clauses ;
   154 page_ranges:
   155 	range
   156 	| page_ranges ',' range ;
   158 page_clause:
   159 	PAGE INTEGER ';'
   160 	| PAGE STRING ',' INTEGER ';' ;
   162 pages_clause:
   163 	PAGES page_ranges ';'
   164 	| PAGES STRING ',' page_ranges ';' ;
   166 bookmark_clause:
   167 	BOOKMARK INTEGER ',' STRING ';'
   168 	| BOOKMARK STRING ';' ;
   170 output_clause:
   171 	page_clause | pages_clause | bookmark_clause
   172 	| output_clause_list ;
   174 output_clauses:
   175 	output_clause
   176 	| output_clauses output_clause ;
   178 output_clause_list:
   179 	'{' output_clauses '}' ;
   181 output_statement:
   182 	OUTPUT output_clauses ;