Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
brouhaha committed Dec 31, 2001
1 parent 83f20f0 commit 54a3bf9
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 29 deletions.
24 changes: 10 additions & 14 deletions parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,13 @@ input_file_clause:
FILE_KEYWORD STRING ';' { input_set_file ($2) } ;

image_clause:
IMAGE INTEGER ';' { input_images ($2, $2); }
| IMAGE INTEGER modifier_clause_list ';' { input_images ($2, $2); } ;
IMAGE INTEGER ';' { input_images ($2, $2); } ;

images_clause:
IMAGES image_ranges ';'
| IMAGES image_ranges modifier_clause_list ';'
| IMAGES image_ranges part_clauses ';' ;
IMAGES image_ranges ';' ;

rotate_clause:
ROTATE INTEGER ';' ;
ROTATE INTEGER ';' { input_set_rotation ($2) };

unit:
/* empty */ /* default to INCH */ { $$ = 25.4; }
Expand Down Expand Up @@ -124,20 +121,19 @@ modifier_clauses:
modifier_clause_list:
'{' modifier_clauses '}' ;

part:
EVEN | ODD | ALL ;

part_clause:
part modifier_clause_list;

part_clauses:
part_clause
| part_clauses part_clause;
ODD { input_set_modifier_context (INPUT_MODIFIER_ODD); }
modifier_clause_list ';'
{ input_set_modifier_context (INPUT_MODIFIER_ALL); }
| EVEN { input_set_modifier_context (INPUT_MODIFIER_ODD); }
modifier_clause_list ';'
{ input_set_modifier_context (INPUT_MODIFIER_ALL); } ;

input_clause:
input_file_clause
| image_clause
| images_clause
| part_clause
| modifier_clause
| input_clause_list ;

Expand Down
48 changes: 42 additions & 6 deletions semantics.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
#include "parser.tab.h"


#define SEMANTIC_DEBUG
#ifdef SEMANTIC_DEBUG
#define SDBG(x) printf x
#else
#define SDBG(x)
#endif


FILE *yyin;
int line; /* line number in spec file */

Expand All @@ -16,9 +24,10 @@ int output_page_count; /* total output pages in spec */


input_context_t *current_input_context;
input_modifier_type_t current_modifier_context;


void input_push_context (input_context_type_t type)
void input_push_context (void)
{
input_context_t *new_input_context;

Expand Down Expand Up @@ -52,17 +61,42 @@ void input_pop_context (void)
current_input_context = current_input_context->parent_input_context;
};

void input_set_modifier_context (input_modifier_type_t type)
{
current_modifier_context = type;
#ifdef SEMANTIC_DEBUG
SDBG(("modifier type "));
switch (type)
{
case INPUT_MODIFIER_ALL: SDBG(("all")); break;
case INPUT_MODIFIER_ODD: SDBG(("odd")); break;
case INPUT_MODIFIER_EVEN: SDBG(("even")); break;
default: SDBG(("unknown %d", type));
}
SDBG(("\n"));
#endif /* SEMANTIC_DEBUG */
}

void input_set_file (char *name)
{
};

void input_set_rotation (int rotation)
{
current_input_context->modifiers [current_modifier_context].has_rotation = 1;
current_input_context->modifiers [current_modifier_context].rotation = rotation;
SDBG(("rotation %d\n", rotation));
}

void input_images (int first, int last)
{
input_page_count += ((last - first) + 1);
#ifdef SEMANTIC_DEBUG
if (first == last)
printf ("image %d\n", first);
SDBG(("image %d\n", first));
else
printf ("images %d..%d\n", first, last);
SDBG(("images %d..%d\n", first, last));
#endif /* SEMANTIC_DEBUG */
}


Expand All @@ -77,10 +111,12 @@ void output_set_file (char *name)
void output_pages (int first, int last)
{
output_page_count += ((last - first) + 1);
#ifdef SEMANTIC_DEBUG
if (first == last)
printf ("page %d\n", first);
SDBG(("page %d\n", first));
else
printf ("pages %d..%d\n", first, last);
SDBG(("pages %d..%d\n", first, last));
#endif /* SEMANTIC_DEBUG */
}


Expand All @@ -103,7 +139,7 @@ boolean parse_spec_file (char *fn)

line = 1;

input_push_context (INPUT_CONTEXT_ALL); /* create initial input context */
input_push_context (); /* create initial input context */
output_push_context (); /* create initial output context */

yyparse ();
Expand Down
12 changes: 3 additions & 9 deletions semantics.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ typedef struct
double bottom;
} crop_t;

typedef enum
{
INPUT_CONTEXT_ALL,
INPUT_CONTEXT_ODD,
INPUT_CONTEXT_EVEN
} input_context_type_t;


typedef struct
{
boolean has_size;
Expand Down Expand Up @@ -70,9 +62,11 @@ boolean parse_spec_file (char *fn);


/* semantic routines for input statements */
void input_push_context (input_context_type_t type);
void input_push_context (void);
void input_pop_context (void);
void input_set_modifier_context (input_modifier_type_t type);
void input_set_file (char *name);
void input_set_rotation (int rotation);
void input_images (int first, int last);

/* semantic routines for output statements */
Expand Down

0 comments on commit 54a3bf9

Please sign in to comment.