Initial revision
This commit is contained in:
parent
12b6146032
commit
da77cde2e9
79
semantics.c
Normal file
79
semantics.c
Normal file
@ -0,0 +1,79 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "type.h"
|
||||
#include "parser.tab.h"
|
||||
#include "semantics.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 */
|
||||
|
||||
|
||||
void input_push_context (input_context_type_t type)
|
||||
{
|
||||
};
|
||||
|
||||
void input_pop_context (void)
|
||||
{
|
||||
};
|
||||
|
||||
void input_set_file (char *name)
|
||||
{
|
||||
};
|
||||
|
||||
void input_images (int first, int last)
|
||||
{
|
||||
input_count += ((last - first) + 1);
|
||||
if (first == last)
|
||||
printf ("image %d\n", first);
|
||||
else
|
||||
printf ("iamges %d..%d\n", first, last);
|
||||
}
|
||||
|
||||
void output_set_file (char *name)
|
||||
{
|
||||
};
|
||||
|
||||
void output_pages (int first, int last)
|
||||
{
|
||||
output_count += ((last - first) + 1);
|
||||
if (first == last)
|
||||
printf ("page %d\n", first);
|
||||
else
|
||||
printf ("pages %d..%d\n", first, last);
|
||||
}
|
||||
|
||||
|
||||
void yyerror (char *s)
|
||||
{
|
||||
fprintf (stderr, "%d: %s\n", line, s);
|
||||
}
|
||||
|
||||
|
||||
boolean parse_spec_file (char *fn)
|
||||
{
|
||||
boolean result = 0;
|
||||
|
||||
yyin = fopen (fn, "r");
|
||||
if (! yyin)
|
||||
{
|
||||
fprintf (stderr, "can't open spec file '%s'\n", fn);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
line = 1;
|
||||
|
||||
yyparse ();
|
||||
|
||||
result = 1;
|
||||
|
||||
fail:
|
||||
if (yyin)
|
||||
fclose (yyin);
|
||||
|
||||
return (result);
|
||||
}
|
||||
27
semantics.h
Normal file
27
semantics.h
Normal file
@ -0,0 +1,27 @@
|
||||
typedef enum
|
||||
{
|
||||
INPUT_CONTEXT_ALL,
|
||||
INPUT_CONTEXT_ODD,
|
||||
INPUT_CONTEXT_EVEN
|
||||
} input_context_type_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 */
|
||||
|
||||
|
||||
boolean parse_spec_file (char *fn);
|
||||
|
||||
|
||||
/* semantic routines for input statements */
|
||||
void input_push_context (input_context_type_t type);
|
||||
void input_pop_context (void);
|
||||
void input_set_file (char *name);
|
||||
void input_images (int first, int last);
|
||||
|
||||
/* semantic routines for output statements */
|
||||
void output_set_file (char *name);
|
||||
void output_pages (int first, int last);
|
||||
Loading…
x
Reference in New Issue
Block a user