semantics.c

Sun, 30 Dec 2001 16:29:50 +0000

author
eric
date
Sun, 30 Dec 2001 16:29:50 +0000
changeset 16
dbf5e39b1658
child 18
3de372e4b230
permissions
-rw-r--r--

Initial revision

eric@16 1 #include <stdio.h>
eric@16 2
eric@16 3 #include "type.h"
eric@16 4 #include "parser.tab.h"
eric@16 5 #include "semantics.h"
eric@16 6
eric@16 7
eric@16 8 FILE *yyin;
eric@16 9 int line; /* line number in spec file */
eric@16 10
eric@16 11
eric@16 12 int input_count; /* total input pages in spec */
eric@16 13 int output_count; /* total output pages in spec */
eric@16 14
eric@16 15
eric@16 16 void input_push_context (input_context_type_t type)
eric@16 17 {
eric@16 18 };
eric@16 19
eric@16 20 void input_pop_context (void)
eric@16 21 {
eric@16 22 };
eric@16 23
eric@16 24 void input_set_file (char *name)
eric@16 25 {
eric@16 26 };
eric@16 27
eric@16 28 void input_images (int first, int last)
eric@16 29 {
eric@16 30 input_count += ((last - first) + 1);
eric@16 31 if (first == last)
eric@16 32 printf ("image %d\n", first);
eric@16 33 else
eric@16 34 printf ("iamges %d..%d\n", first, last);
eric@16 35 }
eric@16 36
eric@16 37 void output_set_file (char *name)
eric@16 38 {
eric@16 39 };
eric@16 40
eric@16 41 void output_pages (int first, int last)
eric@16 42 {
eric@16 43 output_count += ((last - first) + 1);
eric@16 44 if (first == last)
eric@16 45 printf ("page %d\n", first);
eric@16 46 else
eric@16 47 printf ("pages %d..%d\n", first, last);
eric@16 48 }
eric@16 49
eric@16 50
eric@16 51 void yyerror (char *s)
eric@16 52 {
eric@16 53 fprintf (stderr, "%d: %s\n", line, s);
eric@16 54 }
eric@16 55
eric@16 56
eric@16 57 boolean parse_spec_file (char *fn)
eric@16 58 {
eric@16 59 boolean result = 0;
eric@16 60
eric@16 61 yyin = fopen (fn, "r");
eric@16 62 if (! yyin)
eric@16 63 {
eric@16 64 fprintf (stderr, "can't open spec file '%s'\n", fn);
eric@16 65 goto fail;
eric@16 66 }
eric@16 67
eric@16 68 line = 1;
eric@16 69
eric@16 70 yyparse ();
eric@16 71
eric@16 72 result = 1;
eric@16 73
eric@16 74 fail:
eric@16 75 if (yyin)
eric@16 76 fclose (yyin);
eric@16 77
eric@16 78 return (result);
eric@16 79 }