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