[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / compiler / yaccParser / hsclink.c
1 /* This is the "top-level" file for the *linked-into-the-compiler* parser.
2    See also main.c.  (WDP 94/10)
3 */
4
5 #include <stdio.h>
6
7 #include "hspincl.h"
8 #include "constants.h"
9 #include "utils.h"
10
11 /**********************************************************************
12 *                                                                     *
13 *                                                                     *
14 *     The main program                                                *
15 *                                                                     *
16 *                                                                     *
17 **********************************************************************/
18
19 extern long  prog_argc; 
20 extern char  **prog_argv;
21
22 #define MAX_HSP_ARGS 64
23 long hsp_argc;
24 char *hsp_argv[MAX_HSP_ARGS];   /* sigh */
25
26 tree
27 hspmain()
28 {
29     int hsp_i, prog_i;
30
31     Lnil = mklnil();    /* The null list -- used in lsing, etc. */
32     all = mklnil();     /* This should be the list of all derivable types */
33
34     /* copy the args we're interested in (first char: comma)
35         to hsp_argv; arrange to point after the comma!
36     */
37     hsp_i = 0;
38     for (prog_i = 0; prog_i < prog_argc; prog_i++) {
39         if (prog_argv[prog_i][0] == ',') {
40             hsp_argv[hsp_i] = &(prog_argv[prog_i][1]);
41             hsp_i++;
42         }
43     }
44     hsp_argc = hsp_i; /* set count */
45
46     process_args(hsp_argc, hsp_argv); /* HACK */
47
48     hash_init();
49
50 #ifdef HSP_DEBUG
51     fprintf(stderr,"input_file_dir=%s\n",input_file_dir);
52 #endif
53
54     yyinit();
55
56     if (yyparse() != 0) {
57         /* There was a syntax error. */
58         printf("\n");
59         exit(1);
60     }
61
62     return(root);
63 }