*** empty log message ***

Mon, 31 Dec 2001 02:33:50 +0000

author
eric
date
Mon, 31 Dec 2001 02:33:50 +0000
changeset 19
e9bf1ed4f331
parent 18
3de372e4b230
child 20
a1cd8cb9d09e

*** empty log message ***

parser.y file | annotate | diff | revisions
semantics.c file | annotate | diff | revisions
semantics.h file | annotate | diff | revisions
     1.1 --- a/parser.y	Sun Dec 30 17:09:08 2001 +0000
     1.2 +++ b/parser.y	Mon Dec 31 02:33:50 2001 +0000
     1.3 @@ -77,16 +77,13 @@
     1.4  	FILE_KEYWORD STRING  ';'  { input_set_file ($2) } ;
     1.5  
     1.6  image_clause:
     1.7 -	IMAGE INTEGER ';' { input_images ($2, $2); }
     1.8 -	| IMAGE INTEGER modifier_clause_list ';' { input_images ($2, $2); } ;
     1.9 +	IMAGE INTEGER ';' { input_images ($2, $2); } ;
    1.10  
    1.11  images_clause:
    1.12 -	IMAGES image_ranges ';'
    1.13 -	| IMAGES image_ranges modifier_clause_list ';'
    1.14 -	| IMAGES image_ranges part_clauses ';' ;
    1.15 +	IMAGES image_ranges ';' ;
    1.16  
    1.17  rotate_clause:
    1.18 -	ROTATE INTEGER ';' ;
    1.19 +	ROTATE INTEGER ';' { input_set_rotation ($2) };
    1.20  
    1.21  unit:
    1.22  	/* empty */  /* default to INCH */ { $$ = 25.4; }
    1.23 @@ -124,20 +121,19 @@
    1.24  modifier_clause_list:
    1.25  	'{' modifier_clauses '}' ;
    1.26  
    1.27 -part:
    1.28 -	EVEN | ODD | ALL ;
    1.29 -
    1.30  part_clause:
    1.31 -	part modifier_clause_list;
    1.32 -
    1.33 -part_clauses:
    1.34 -	part_clause
    1.35 -	| part_clauses part_clause;
    1.36 +	ODD { input_set_modifier_context (INPUT_MODIFIER_ODD); }
    1.37 +          modifier_clause_list ';'
    1.38 +          { input_set_modifier_context (INPUT_MODIFIER_ALL); }
    1.39 +	| EVEN { input_set_modifier_context (INPUT_MODIFIER_ODD); }
    1.40 +	  modifier_clause_list ';'
    1.41 +          { input_set_modifier_context (INPUT_MODIFIER_ALL); } ;
    1.42  
    1.43  input_clause:
    1.44  	input_file_clause
    1.45  	| image_clause
    1.46  	| images_clause
    1.47 +	| part_clause
    1.48  	| modifier_clause
    1.49  	| input_clause_list ;
    1.50  
     2.1 --- a/semantics.c	Sun Dec 30 17:09:08 2001 +0000
     2.2 +++ b/semantics.c	Mon Dec 31 02:33:50 2001 +0000
     2.3 @@ -7,6 +7,14 @@
     2.4  #include "parser.tab.h"
     2.5  
     2.6  
     2.7 +#define SEMANTIC_DEBUG
     2.8 +#ifdef SEMANTIC_DEBUG
     2.9 +#define SDBG(x) printf x
    2.10 +#else
    2.11 +#define SDBG(x)
    2.12 +#endif
    2.13 +
    2.14 +
    2.15  FILE *yyin;
    2.16  int line;  /* line number in spec file */
    2.17  
    2.18 @@ -16,9 +24,10 @@
    2.19  
    2.20  
    2.21  input_context_t *current_input_context;
    2.22 +input_modifier_type_t current_modifier_context;
    2.23  
    2.24  
    2.25 -void input_push_context (input_context_type_t type)
    2.26 +void input_push_context (void)
    2.27  {
    2.28    input_context_t *new_input_context;
    2.29  
    2.30 @@ -52,17 +61,42 @@
    2.31    current_input_context = current_input_context->parent_input_context;
    2.32  };
    2.33  
    2.34 +void input_set_modifier_context (input_modifier_type_t type)
    2.35 +{
    2.36 +  current_modifier_context = type;
    2.37 +#ifdef SEMANTIC_DEBUG
    2.38 +  SDBG(("modifier type "));
    2.39 +  switch (type)
    2.40 +    {
    2.41 +    case INPUT_MODIFIER_ALL: SDBG(("all")); break;
    2.42 +    case INPUT_MODIFIER_ODD: SDBG(("odd")); break;
    2.43 +    case INPUT_MODIFIER_EVEN: SDBG(("even")); break;
    2.44 +    default: SDBG(("unknown %d", type));
    2.45 +    }
    2.46 +  SDBG(("\n"));
    2.47 +#endif /* SEMANTIC_DEBUG */
    2.48 +}
    2.49 +
    2.50  void input_set_file (char *name)
    2.51  {
    2.52  };
    2.53  
    2.54 +void input_set_rotation (int rotation)
    2.55 +{
    2.56 +  current_input_context->modifiers [current_modifier_context].has_rotation = 1;
    2.57 +  current_input_context->modifiers [current_modifier_context].rotation = rotation;
    2.58 +  SDBG(("rotation %d\n", rotation));
    2.59 +}
    2.60 +
    2.61  void input_images (int first, int last)
    2.62  {
    2.63    input_page_count += ((last - first) + 1);
    2.64 +#ifdef SEMANTIC_DEBUG
    2.65    if (first == last)
    2.66 -    printf ("image %d\n", first);
    2.67 +    SDBG(("image %d\n", first));
    2.68    else
    2.69 -    printf ("images %d..%d\n", first, last);
    2.70 +    SDBG(("images %d..%d\n", first, last));
    2.71 +#endif /* SEMANTIC_DEBUG */
    2.72  }
    2.73  
    2.74  
    2.75 @@ -77,10 +111,12 @@
    2.76  void output_pages (int first, int last)
    2.77  {
    2.78    output_page_count += ((last - first) + 1);
    2.79 +#ifdef SEMANTIC_DEBUG
    2.80    if (first == last)
    2.81 -    printf ("page %d\n", first);
    2.82 +    SDBG(("page %d\n", first));
    2.83    else
    2.84 -    printf ("pages %d..%d\n", first, last);
    2.85 +    SDBG(("pages %d..%d\n", first, last));
    2.86 +#endif /* SEMANTIC_DEBUG */
    2.87  }
    2.88  
    2.89  
    2.90 @@ -103,7 +139,7 @@
    2.91  
    2.92    line = 1;
    2.93  
    2.94 -  input_push_context (INPUT_CONTEXT_ALL);  /* create initial input context */
    2.95 +  input_push_context ();  /* create initial input context */
    2.96    output_push_context ();  /* create initial output context */
    2.97  
    2.98    yyparse ();
     3.1 --- a/semantics.h	Sun Dec 30 17:09:08 2001 +0000
     3.2 +++ b/semantics.h	Mon Dec 31 02:33:50 2001 +0000
     3.3 @@ -18,14 +18,6 @@
     3.4    double bottom;
     3.5  } crop_t;
     3.6  
     3.7 -typedef enum
     3.8 -{
     3.9 -  INPUT_CONTEXT_ALL,
    3.10 -  INPUT_CONTEXT_ODD,
    3.11 -  INPUT_CONTEXT_EVEN
    3.12 -} input_context_type_t;
    3.13 -
    3.14 -
    3.15  typedef struct
    3.16  {
    3.17    boolean has_size;
    3.18 @@ -70,9 +62,11 @@
    3.19  
    3.20  
    3.21  /* semantic routines for input statements */
    3.22 -void input_push_context (input_context_type_t type);
    3.23 +void input_push_context (void);
    3.24  void input_pop_context (void);
    3.25 +void input_set_modifier_context (input_modifier_type_t type);
    3.26  void input_set_file (char *name);
    3.27 +void input_set_rotation (int rotation);
    3.28  void input_images (int first, int last);
    3.29  
    3.30  /* semantic routines for output statements */