1
0
mirror of synced 2026-04-05 13:31:38 +00:00

*** empty log message ***

This commit is contained in:
Eric Smith
2001-12-30 17:09:08 +00:00
parent dbc4896166
commit 83f20f0702
6 changed files with 117 additions and 16 deletions

View File

@@ -8,8 +8,8 @@
int integer;
double fp;
char *string;
struct { double width; double height; } size;
struct { int first; int last; } range;
page_size_t size;
range_t range;
}
%token <integer> INTEGER

View File

@@ -1,5 +1,5 @@
/*
$Id: scanner.l,v 1.9 2001/12/30 08:29:50 eric Exp $
$Id: scanner.l,v 1.10 2001/12/30 09:09:08 eric Exp $
*/
%option case-insensitive
@@ -8,9 +8,9 @@ $Id: scanner.l,v 1.9 2001/12/30 08:29:50 eric Exp $
%{
#include <stdio.h>
#include <string.h>
#include "parser.tab.h"
#include "type.h"
#include "semantics.h"
#include "parser.tab.h"
#ifdef SCANNER_DEBUG
#define LDBG(x) printf x

View File

@@ -1,24 +1,55 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "type.h"
#include "parser.tab.h"
#include "semantics.h"
#include "parser.tab.h"
FILE *yyin;
int line; /* line number in spec file */
int input_count; /* total input pages in spec */
int output_count; /* total output pages in spec */
int input_page_count; /* total input pages in spec */
int output_page_count; /* total output pages in spec */
input_context_t *current_input_context;
void input_push_context (input_context_type_t type)
{
input_context_t *new_input_context;
new_input_context = malloc (sizeof (input_context_t));
if (! new_input_context)
{
fprintf (stderr, "failed to calloc an input context\n");
return;
}
if (current_input_context)
{
memcpy (new_input_context, current_input_context, sizeof (input_context_t));
new_input_context->page_count = 0;
}
else
memset (new_input_context, 0, sizeof (input_context_t));
new_input_context->parent_input_context = current_input_context;
current_input_context = new_input_context;
};
void input_pop_context (void)
{
if (! current_input_context)
{
fprintf (stderr, "failed to pop an input context\n");
return;
}
current_input_context = current_input_context->parent_input_context;
};
void input_set_file (char *name)
@@ -27,20 +58,25 @@ void input_set_file (char *name)
void input_images (int first, int last)
{
input_count += ((last - first) + 1);
input_page_count += ((last - first) + 1);
if (first == last)
printf ("image %d\n", first);
else
printf ("iamges %d..%d\n", first, last);
printf ("images %d..%d\n", first, last);
}
void output_push_context (void)
{
};
void output_set_file (char *name)
{
};
void output_pages (int first, int last)
{
output_count += ((last - first) + 1);
output_page_count += ((last - first) + 1);
if (first == last)
printf ("page %d\n", first);
else
@@ -67,8 +103,20 @@ boolean parse_spec_file (char *fn)
line = 1;
input_push_context (INPUT_CONTEXT_ALL); /* create initial input context */
output_push_context (); /* create initial output context */
yyparse ();
if (input_page_count != output_page_count)
{
fprintf (stderr, "input page count %d != output page count %d\n",
input_page_count, output_page_count);
goto fail;
}
fprintf (stderr, "%d pages specified\n", input_page_count);
result = 1;
fail:

View File

@@ -1,3 +1,23 @@
typedef struct
{
double width;
double height;
} page_size_t;
typedef struct
{
int first;
int last;
} range_t;
typedef struct
{
double left;
double right;
double top;
double bottom;
} crop_t;
typedef enum
{
INPUT_CONTEXT_ALL,
@@ -6,11 +26,44 @@ typedef enum
} input_context_type_t;
typedef struct
{
boolean has_size;
page_size_t size;
boolean has_rotation;
int rotation;
boolean has_crop;
crop_t crop;
} input_modifiers_t;
typedef enum
{
INPUT_MODIFIER_ALL,
INPUT_MODIFIER_ODD,
INPUT_MODIFIER_EVEN,
INPUT_MODIFIER_TYPE_COUNT /* must be last */
} input_modifier_type_t;
typedef struct input_context_t
{
struct input_context_t *parent_input_context;
int page_count; /* how many pages reference this context,
including those from subcontexts */
input_modifiers_t modifiers [INPUT_MODIFIER_TYPE_COUNT];
} input_context_t;
extern int line; /* line number in spec file */
extern int input_count; /* total input pages in spec */
extern int output_count; /* total output pages in spec */
extern int input_page_count; /* total input pages in spec */
extern int output_page_count; /* total output pages in spec */
boolean parse_spec_file (char *fn);

4
t2p.c
View File

@@ -1,7 +1,7 @@
/*
* tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4
* Main program
* $Id: t2p.c,v 1.4 2001/12/30 08:29:50 eric Exp $
* $Id: t2p.c,v 1.5 2001/12/30 09:09:08 eric Exp $
* Copyright 2001 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -28,8 +28,8 @@
#include "type.h"
#include "bitblt.h"
#include "parser.tab.h"
#include "semantics.h"
#include "parser.tab.h"
#include "tiff2pdf.h"

View File

@@ -1,7 +1,7 @@
/*
* tiffg4: reencode a bilevel TIFF file as a single-strip TIFF Class F Group 4
* Main program
* $Id: tumble.c,v 1.4 2001/12/30 08:29:50 eric Exp $
* $Id: tumble.c,v 1.5 2001/12/30 09:09:08 eric Exp $
* Copyright 2001 Eric Smith <eric@brouhaha.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -28,8 +28,8 @@
#include "type.h"
#include "bitblt.h"
#include "parser.tab.h"
#include "semantics.h"
#include "parser.tab.h"
#include "tiff2pdf.h"