1.1 diff -r dda3d673b82b -r dbf5e39b1658 semantics.c 1.2 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.3 +++ b/semantics.c Sun Dec 30 16:29:50 2001 +0000 1.4 @@ -0,0 +1,79 @@ 1.5 +#include <stdio.h> 1.6 + 1.7 +#include "type.h" 1.8 +#include "parser.tab.h" 1.9 +#include "semantics.h" 1.10 + 1.11 + 1.12 +FILE *yyin; 1.13 +int line; /* line number in spec file */ 1.14 + 1.15 + 1.16 +int input_count; /* total input pages in spec */ 1.17 +int output_count; /* total output pages in spec */ 1.18 + 1.19 + 1.20 +void input_push_context (input_context_type_t type) 1.21 +{ 1.22 +}; 1.23 + 1.24 +void input_pop_context (void) 1.25 +{ 1.26 +}; 1.27 + 1.28 +void input_set_file (char *name) 1.29 +{ 1.30 +}; 1.31 + 1.32 +void input_images (int first, int last) 1.33 +{ 1.34 + input_count += ((last - first) + 1); 1.35 + if (first == last) 1.36 + printf ("image %d\n", first); 1.37 + else 1.38 + printf ("iamges %d..%d\n", first, last); 1.39 +} 1.40 + 1.41 +void output_set_file (char *name) 1.42 +{ 1.43 +}; 1.44 + 1.45 +void output_pages (int first, int last) 1.46 +{ 1.47 + output_count += ((last - first) + 1); 1.48 + if (first == last) 1.49 + printf ("page %d\n", first); 1.50 + else 1.51 + printf ("pages %d..%d\n", first, last); 1.52 +} 1.53 + 1.54 + 1.55 +void yyerror (char *s) 1.56 +{ 1.57 + fprintf (stderr, "%d: %s\n", line, s); 1.58 +} 1.59 + 1.60 + 1.61 +boolean parse_spec_file (char *fn) 1.62 +{ 1.63 + boolean result = 0; 1.64 + 1.65 + yyin = fopen (fn, "r"); 1.66 + if (! yyin) 1.67 + { 1.68 + fprintf (stderr, "can't open spec file '%s'\n", fn); 1.69 + goto fail; 1.70 + } 1.71 + 1.72 + line = 1; 1.73 + 1.74 + yyparse (); 1.75 + 1.76 + result = 1; 1.77 + 1.78 + fail: 1.79 + if (yyin) 1.80 + fclose (yyin); 1.81 + 1.82 + return (result); 1.83 +}