[project @ 1996-03-19 08:58:34 by partain]
[ghc-hetmet.git] / ghc / compiler / parser / 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
33     /* copy the args we're interested in (first char: comma)
34         to hsp_argv; arrange to point after the comma!
35     */
36     hsp_i = 0;
37     for (prog_i = 0; prog_i < prog_argc; prog_i++) {
38         if (prog_argv[prog_i][0] == ',') {
39             hsp_argv[hsp_i] = &(prog_argv[prog_i][1]);
40             hsp_i++;
41         }
42     }
43     hsp_argc = hsp_i; /* set count */
44
45     process_args(hsp_argc, hsp_argv); /* HACK */
46
47     hash_init();
48
49 #ifdef HSP_DEBUG
50     fprintf(stderr,"input_file_dir=%s\n",input_file_dir);
51 #endif
52
53     yyinit();
54
55     if (yyparse() != 0) {
56         /* There was a syntax error. */
57         printf("\n");
58         exit(1);
59     }
60
61     return(root);
62 }