parser.y

changeset 32
3aac131058da
parent 31
2cec996b38bc
child 48
3d0be1c1c1b2
     1.1 --- a/parser.y	Tue Jan 01 06:17:39 2002 +0000
     1.2 +++ b/parser.y	Tue Jan 01 10:16:50 2002 +0000
     1.3 @@ -59,9 +59,11 @@
     1.4  
     1.5  %type <fp> unit
     1.6  
     1.7 -
     1.8 +%type <fp> length
     1.9  
    1.10 -%type <fp> length
    1.11 +%type <integer> orientation
    1.12 +
    1.13 +%type <size> page_size
    1.14  
    1.15  %%
    1.16  
    1.17 @@ -96,9 +98,9 @@
    1.18  	ROTATE INTEGER ';' { input_set_rotation ($2) } ;
    1.19  
    1.20  unit:
    1.21 -	/* empty */  /* default to INCH */ { $$ = 25.4; }
    1.22 -	| CM { $$ = 1.0; }
    1.23 -	| INCH { $$ = 25.4; } ;
    1.24 +	/* empty */  /* default to INCH */ { $$ = 1.0; }
    1.25 +	| CM { $$ = (1.0 / 25.4); }
    1.26 +	| INCH { $$ = 1.0; } ;
    1.27  
    1.28  length:
    1.29  	FLOAT unit { $$ = $1 * $2; } ;
    1.30 @@ -110,13 +112,23 @@
    1.31  	| CROP length ',' length ',' length ',' length ';' ;
    1.32  
    1.33  orientation:
    1.34 -	PORTRAIT
    1.35 -	| LANDSCAPE ;
    1.36 +	PORTRAIT { $$ = 0; }
    1.37 +	| LANDSCAPE { $$ = 1; } ;
    1.38 +
    1.39 +page_size:
    1.40 +	PAGE_SIZE { $$ = $1; }
    1.41 +	| PAGE_SIZE orientation { if ($2)
    1.42 +                                    {
    1.43 +                                      $$.width = $1.height;
    1.44 +				      $$.height = $1.width;
    1.45 +                                    }
    1.46 +                                  else
    1.47 +                                    $$ = $1;
    1.48 +                                }
    1.49 +	| length ',' length { $$.width = $1; $$.height = $3; } ;
    1.50  
    1.51  size_clause:
    1.52 -	SIZE PAGE_SIZE ';'
    1.53 -	| SIZE PAGE_SIZE orientation ';'
    1.54 -	| SIZE length ',' length ';' ;
    1.55 +	SIZE page_size ';' { input_set_page_size ($2); } ;
    1.56  
    1.57  resolution_clause:
    1.58  	RESOLUTION FLOAT unit ;