parser.y

changeset 9
de78038d990f
parent 8
7288d2753c18
child 11
30d18cf8bb67
     1.1 --- a/parser.y	Fri Dec 28 16:04:15 2001 +0000
     1.2 +++ b/parser.y	Sat Dec 29 10:19:49 2001 +0000
     1.3 @@ -6,20 +6,29 @@
     1.4    int integer;
     1.5    double fp;
     1.6    char *string;
     1.7 +  struct { double width, double height } size;
     1.8  }
     1.9  
    1.10  %token <integer> INTEGER
    1.11  %token <fp> FLOAT
    1.12  %token <string> STRING
    1.13 +%token <size> PAGE_SIZE
    1.14  
    1.15  %token ELIPSIS
    1.16  
    1.17 +%token CM
    1.18 +%token INCH
    1.19 +
    1.20  %token EVEN
    1.21  %token ODD
    1.22  %token ALL
    1.23  
    1.24 +%token PORTRAIT
    1.25 +%token LANDSCAPE
    1.26 +
    1.27  %token FILE
    1.28  %token IMAGE
    1.29 +%token IMAGES
    1.30  %token ROTATE
    1.31  %token CROP
    1.32  %token SIZE
    1.33 @@ -30,48 +39,96 @@
    1.34  %token BOOKMARK
    1.35  %token OUTPUT
    1.36  
    1.37 -%type <integer> range
    1.38 -%type <integer> ranges
    1.39 +%type <integer> image_range
    1.40 +%type <integer> image_ranges
    1.41 +%type <integer> page_range
    1.42 +%type <integer> page_ranges
    1.43 +
    1.44 +%type <fp> length
    1.45  
    1.46  %%
    1.47  
    1.48 -statements: statement | statements statement ;
    1.49 +statements: 
    1.50 +	statement
    1.51 +	| statements statement ;
    1.52  
    1.53 -statement: input_statement | output_statement ;
    1.54 +statement:
    1.55 +	input_statement
    1.56 +	| output_statement ;
    1.57  
    1.58  
    1.59 -range:	INTEGER ELIPSIS INTEGER
    1.60 +image_range:
    1.61 +	INTEGER ELIPSIS INTEGER
    1.62  	| INTEGER ;
    1.63  
    1.64 -ranges:	range
    1.65 -	| ranges ',' range ;
    1.66 +image_ranges:
    1.67 +	image_range
    1.68 +	| image_ranges ',' image_range ;
    1.69  
    1.70  
    1.71  file_clause:
    1.72  	FILE STRING  ';' ;
    1.73  
    1.74  image_clause:
    1.75 -	IMAGE ranges ';' ;
    1.76 +	IMAGE INTEGER ';'
    1.77 +	| IMAGE INTEGER modifier_clause_list ';' ;
    1.78 +
    1.79 +images_clause:
    1.80 +	IMAGES image_ranges ';'
    1.81 +	| IMAGES image_ranges modifier_clause_list ';'
    1.82 +	| IMAGES image_ranges part_clauses ';' ;
    1.83  
    1.84  rotate_clause:
    1.85  	ROTATE INTEGER ';' ;
    1.86  
    1.87 +unit:
    1.88 +	CM
    1.89 +	| INCH ;
    1.90 +
    1.91 +length:
    1.92 +	FLOAT
    1.93 +	| FLOAT unit ;
    1.94 +
    1.95  crop_clause:
    1.96 -	CROP FLOAT ',' FLOAT ';' ;
    1.97 +	CROP PAGE_SIZE ';'
    1.98 +	| CROP PAGE_SIZE orientation ';'
    1.99 +	| CROP length ',' length ';'
   1.100 +	| CROP length ',' length ',' length ',' length ';' ;
   1.101 +
   1.102 +orientation:
   1.103 +	PORTRAIT
   1.104 +	| LANDSCAPE ;
   1.105  
   1.106  size_clause:
   1.107 -	SIZE FLOAT ',' FLOAT ';' ;
   1.108 +	SIZE PAGE_SIZE ';'
   1.109 +	| SIZE PAGE_SIZE orientation ';'
   1.110 +	| SIZE length ',' length ';' ;
   1.111 +
   1.112 +modifier_clause:
   1.113 +	rotate_clause | crop_clause | size_clause;
   1.114 +
   1.115 +modifier_clauses:
   1.116 +	modifier_clause
   1.117 +	| modifier_clauses modifier_clause;
   1.118 +
   1.119 +modifier_clause_list:
   1.120 +	'{' modifier_clauses '}' ;
   1.121  
   1.122  part:
   1.123  	EVEN | ODD | ALL ;
   1.124  
   1.125  part_clause:
   1.126 -	part input_clause ;
   1.127 +	part modifier_clause_list;
   1.128 +
   1.129 +part_clauses:
   1.130 +	part_clause
   1.131 +	| part_clauses part_clause;
   1.132  
   1.133  input_clause:
   1.134 -	part_clause
   1.135 -	| file_clause | image_clause | rotate_clause
   1.136 -	| crop_clause | size_clause
   1.137 +	file_clause
   1.138 +	| image_clause
   1.139 +	| images_clause
   1.140 +	| modifier_clause
   1.141  	| input_clause_list ;
   1.142  
   1.143  input_clauses:
   1.144 @@ -84,13 +141,21 @@
   1.145  input_statement:
   1.146  	INPUT input_clauses ;
   1.147  
   1.148 +page_range:
   1.149 +	INTEGER ELIPSIS INTEGER
   1.150 +	| INTEGER ;
   1.151 +
   1.152 +page_ranges:
   1.153 +	page_range
   1.154 +	| page_ranges ',' page_range ;
   1.155 +
   1.156  page_clause:
   1.157  	PAGE INTEGER ';'
   1.158 -	| PAGE INTEGER ',' STRING ';' ;
   1.159 +	| PAGE STRING ',' INTEGER ';' ;
   1.160  
   1.161  pages_clause:
   1.162 -	PAGES ranges ';'
   1.163 -	| PAGES ranges ',' STRING ';' ;
   1.164 +	PAGES page_ranges ';'
   1.165 +	| PAGES STRING ',' page_ranges ';' ;
   1.166  
   1.167  bookmark_clause:
   1.168  	BOOKMARK INTEGER ',' STRING ';'