parser.y

changeset 20
a1cd8cb9d09e
parent 19
e9bf1ed4f331
child 27
7a28031fe457
     1.1 --- a/parser.y	Mon Dec 31 02:33:50 2001 +0000
     1.2 +++ b/parser.y	Mon Dec 31 07:25:08 2001 +0000
     1.3 @@ -38,6 +38,7 @@
     1.4  %token RESOLUTION
     1.5  %token INPUT
     1.6  
     1.7 +%token FORMAT
     1.8  %token PAGE
     1.9  %token PAGES
    1.10  %token BOOKMARK
    1.11 @@ -69,21 +70,21 @@
    1.12  	| INTEGER { $$.first = $1; $$.last = $1; } ;
    1.13  
    1.14  image_ranges:
    1.15 -	range { input_images ($1.first, $1.last); }
    1.16 -	| image_ranges ',' range { input_images ($3.first, $3.last); } ;
    1.17 +	range { input_images ($1); }
    1.18 +	| image_ranges ',' range { input_images ($3); } ;
    1.19  
    1.20  
    1.21  input_file_clause:
    1.22  	FILE_KEYWORD STRING  ';'  { input_set_file ($2) } ;
    1.23  
    1.24  image_clause:
    1.25 -	IMAGE INTEGER ';' { input_images ($2, $2); } ;
    1.26 +	IMAGE INTEGER ';' { range_t range = { $2, $2 }; input_images (range); } ;
    1.27  
    1.28  images_clause:
    1.29  	IMAGES image_ranges ';' ;
    1.30  
    1.31  rotate_clause:
    1.32 -	ROTATE INTEGER ';' { input_set_rotation ($2) };
    1.33 +	ROTATE INTEGER ';' { input_set_rotation ($2) } ;
    1.34  
    1.35  unit:
    1.36  	/* empty */  /* default to INCH */ { $$ = 25.4; }
    1.37 @@ -125,7 +126,7 @@
    1.38  	ODD { input_set_modifier_context (INPUT_MODIFIER_ODD); }
    1.39            modifier_clause_list ';'
    1.40            { input_set_modifier_context (INPUT_MODIFIER_ALL); }
    1.41 -	| EVEN { input_set_modifier_context (INPUT_MODIFIER_ODD); }
    1.42 +	| EVEN { input_set_modifier_context (INPUT_MODIFIER_EVEN); }
    1.43  	  modifier_clause_list ';'
    1.44            { input_set_modifier_context (INPUT_MODIFIER_ALL); } ;
    1.45  
    1.46 @@ -150,24 +151,34 @@
    1.47  output_file_clause:
    1.48  	FILE_KEYWORD STRING  ';' { output_set_file ($2) } ;
    1.49  
    1.50 +format_clause:
    1.51 +	FORMAT STRING ';' { output_set_page_number_format ($2) } ;
    1.52 +
    1.53  page_ranges:
    1.54 -	range { output_pages ($1.first, $1.last); }
    1.55 -	| page_ranges ',' range { output_pages ($3.first, $3.last); } ;
    1.56 +	range { output_pages ($1); }
    1.57 +	| page_ranges ',' range { output_pages ($3); } ;
    1.58  
    1.59  page_clause:
    1.60 -	PAGE INTEGER ';' { output_pages ($2, $2); }
    1.61 -	| PAGE STRING ',' INTEGER ';' { output_pages ($4, $4); } ;
    1.62 +	PAGE INTEGER ';' { range_t range = { $2, $2 }; output_pages (range); } ;
    1.63  
    1.64  pages_clause:
    1.65 -	PAGES page_ranges ';'
    1.66 -	| PAGES STRING ',' page_ranges ';' ;
    1.67 +	PAGES page_ranges ';' ;
    1.68 +
    1.69 +bookmark_name:
    1.70 +	STRING { output_set_bookmark ($1); } ;
    1.71 +
    1.72 +bookmark_name_list:
    1.73 +	bookmark_name
    1.74 +	| bookmark_name_list ',' bookmark_name ;
    1.75  
    1.76  bookmark_clause:
    1.77 -	BOOKMARK INTEGER ',' STRING ';'
    1.78 -	| BOOKMARK STRING ';' ;
    1.79 +	BOOKMARK { output_push_context (); }
    1.80 +	bookmark_name_list
    1.81 +	output_clause_list ';' { output_pop_context (); } ;
    1.82  
    1.83  output_clause:
    1.84  	output_file_clause
    1.85 +	| format_clause
    1.86  	| page_clause | pages_clause
    1.87  	| bookmark_clause
    1.88  	| output_clause_list ;
    1.89 @@ -177,7 +188,8 @@
    1.90  	| output_clauses output_clause ;
    1.91  
    1.92  output_clause_list:
    1.93 -	'{' output_clauses '}' ;
    1.94 +	'{' { output_push_context (); }
    1.95 +	output_clauses '}' { output_pop_context (); } ;
    1.96  
    1.97  output_statement:
    1.98  	OUTPUT output_clauses ;