semantics.c

changeset 19
e9bf1ed4f331
parent 18
3de372e4b230
child 20
a1cd8cb9d09e
     1.1 --- a/semantics.c	Sun Dec 30 17:09:08 2001 +0000
     1.2 +++ b/semantics.c	Mon Dec 31 02:33:50 2001 +0000
     1.3 @@ -7,6 +7,14 @@
     1.4  #include "parser.tab.h"
     1.5  
     1.6  
     1.7 +#define SEMANTIC_DEBUG
     1.8 +#ifdef SEMANTIC_DEBUG
     1.9 +#define SDBG(x) printf x
    1.10 +#else
    1.11 +#define SDBG(x)
    1.12 +#endif
    1.13 +
    1.14 +
    1.15  FILE *yyin;
    1.16  int line;  /* line number in spec file */
    1.17  
    1.18 @@ -16,9 +24,10 @@
    1.19  
    1.20  
    1.21  input_context_t *current_input_context;
    1.22 +input_modifier_type_t current_modifier_context;
    1.23  
    1.24  
    1.25 -void input_push_context (input_context_type_t type)
    1.26 +void input_push_context (void)
    1.27  {
    1.28    input_context_t *new_input_context;
    1.29  
    1.30 @@ -52,17 +61,42 @@
    1.31    current_input_context = current_input_context->parent_input_context;
    1.32  };
    1.33  
    1.34 +void input_set_modifier_context (input_modifier_type_t type)
    1.35 +{
    1.36 +  current_modifier_context = type;
    1.37 +#ifdef SEMANTIC_DEBUG
    1.38 +  SDBG(("modifier type "));
    1.39 +  switch (type)
    1.40 +    {
    1.41 +    case INPUT_MODIFIER_ALL: SDBG(("all")); break;
    1.42 +    case INPUT_MODIFIER_ODD: SDBG(("odd")); break;
    1.43 +    case INPUT_MODIFIER_EVEN: SDBG(("even")); break;
    1.44 +    default: SDBG(("unknown %d", type));
    1.45 +    }
    1.46 +  SDBG(("\n"));
    1.47 +#endif /* SEMANTIC_DEBUG */
    1.48 +}
    1.49 +
    1.50  void input_set_file (char *name)
    1.51  {
    1.52  };
    1.53  
    1.54 +void input_set_rotation (int rotation)
    1.55 +{
    1.56 +  current_input_context->modifiers [current_modifier_context].has_rotation = 1;
    1.57 +  current_input_context->modifiers [current_modifier_context].rotation = rotation;
    1.58 +  SDBG(("rotation %d\n", rotation));
    1.59 +}
    1.60 +
    1.61  void input_images (int first, int last)
    1.62  {
    1.63    input_page_count += ((last - first) + 1);
    1.64 +#ifdef SEMANTIC_DEBUG
    1.65    if (first == last)
    1.66 -    printf ("image %d\n", first);
    1.67 +    SDBG(("image %d\n", first));
    1.68    else
    1.69 -    printf ("images %d..%d\n", first, last);
    1.70 +    SDBG(("images %d..%d\n", first, last));
    1.71 +#endif /* SEMANTIC_DEBUG */
    1.72  }
    1.73  
    1.74  
    1.75 @@ -77,10 +111,12 @@
    1.76  void output_pages (int first, int last)
    1.77  {
    1.78    output_page_count += ((last - first) + 1);
    1.79 +#ifdef SEMANTIC_DEBUG
    1.80    if (first == last)
    1.81 -    printf ("page %d\n", first);
    1.82 +    SDBG(("page %d\n", first));
    1.83    else
    1.84 -    printf ("pages %d..%d\n", first, last);
    1.85 +    SDBG(("pages %d..%d\n", first, last));
    1.86 +#endif /* SEMANTIC_DEBUG */
    1.87  }
    1.88  
    1.89  
    1.90 @@ -103,7 +139,7 @@
    1.91  
    1.92    line = 1;
    1.93  
    1.94 -  input_push_context (INPUT_CONTEXT_ALL);  /* create initial input context */
    1.95 +  input_push_context ();  /* create initial input context */
    1.96    output_push_context ();  /* create initial output context */
    1.97  
    1.98    yyparse ();