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

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