1 /**********************************************************************
7 **********************************************************************/
10 #include "constants.h"
13 #define PARSER_VERSION "1.3-???"
15 tree root; /* The root of the built syntax tree. */
18 BOOLEAN nonstandardFlag = FALSE; /* Set if non-std Haskell extensions to be used. */
19 BOOLEAN acceptPrim = FALSE; /* Set if Int#, etc., may be used */
20 BOOLEAN haskell1_2Flag = FALSE; /* Set if we are compiling for 1.2 */
21 BOOLEAN etags = FALSE; /* Set if we're parsing only to produce tags. */
22 BOOLEAN hashIds = FALSE; /* Set if Identifiers should be hashed. */
24 BOOLEAN ignoreSCC = TRUE; /* Set if we ignore/filter scc expressions. */
26 BOOLEAN implicitPrelude = TRUE; /* Set if we implicitly import the Prelude. */
27 BOOLEAN ignorePragmas = FALSE; /* Set if we want to ignore pragmas */
29 /* From time to time, the format of interface files may change.
31 So that we don't get gratuitous syntax errors or silently slurp in
32 junk info, two things: (a) the compiler injects a "this is a
35 {-# GHC_PRAGMA INTERFACE VERSION <n> #-}
37 (b) this parser has a "minimum acceptable version", below which it
38 refuses to parse the pragmas (it just considers them as comments).
39 It also has a "maximum acceptable version", above which...
41 The minimum is so a new parser won't try to grok overly-old
42 interfaces; the maximum (usually the current version number when
43 the parser was released) is so an old parser will not try to grok
44 since-upgraded interfaces.
46 If an interface has no INTERFACE VERSION line, it is taken to be
49 int minAcceptablePragmaVersion = 7; /* 1.3-xx ONLY */
50 int maxAcceptablePragmaVersion = 7; /* 1.3-xx+ */
51 int thisIfacePragmaVersion = 0;
53 char *input_file_dir; /* The directory where the input file is. */
55 char HiSuffix[64] = ".hi"; /* can be changed with -h flag */
56 char PreludeHiSuffix[64] = ".hi"; /* can be changed with -g flag */
58 static BOOLEAN verbose = FALSE; /* Set for verbose messages. */
61 static void who_am_i PROTO((void));
63 /**********************************************************************
69 **********************************************************************/
72 # include "constants.h"
77 process_args(argc,argv)
81 BOOLEAN keep_munging_option = FALSE;
83 imports_dirlist = mklnil();
84 sys_imports_dirlist = mklnil();
88 while (argc > 0 && argv[0][0] == '-') {
90 keep_munging_option = TRUE;
92 while (keep_munging_option && *++*argv != '\0') {
97 imports_dirlist = lapp(imports_dirlist,*argv+1);
98 keep_munging_option = FALSE;
101 /* -J dir (for system imports) */
103 sys_imports_dirlist = lapp(sys_imports_dirlist,*argv+1);
104 keep_munging_option = FALSE;
108 strcpy(PreludeHiSuffix, *argv+1);
109 keep_munging_option = FALSE;
113 strcpy(HiSuffix, *argv+1);
114 keep_munging_option = FALSE;
118 who_am_i(); /* identify myself */
123 nonstandardFlag = TRUE;
128 haskell1_2Flag = TRUE;
136 ignorePragmas = TRUE;
140 implicitPrelude = FALSE;
145 { extern int yydebug;
151 /* -Hn -- Use Hash Table, Size n (if given) */
154 if(*(*argv+1)!= '\0')
155 hash_table_size = atoi(*argv+1);
165 if(argc >= 1 && freopen(argv[0], "r", stdin) == NULL) {
166 fprintf(stderr, "Cannot open %s.\n", argv[0]);
170 if(argc >= 2 && freopen(argv[1], "w", stdout) == NULL) {
171 fprintf(stderr, "Cannot open %s.\n", argv[1]);
176 /* By default, imports come from the directory of the source file */
181 input_file_dir = xmalloc (strlen(argv[0]) + 1);
182 strcpy(input_file_dir, argv[0]);
184 endchar = rindex(input_file_dir, (int) ':');
186 endchar = rindex(input_file_dir, (int) '/');
187 #endif /* ! macintosh */
189 if ( endchar == NULL )
191 free(input_file_dir);
192 input_file_dir = ".";
198 /* No input file -- imports come from the current directory first */
200 input_file_dir = ".";
202 imports_dirlist = mklcons( input_file_dir, imports_dirlist );
206 fprintf(stderr,"Hash Table Contains %d entries\n",hash_table_size);
208 fprintf(stderr,"Allowing special syntax for Unboxed Values\n");
216 fprintf(stderr, "PARSER: Error %s\n", s);
223 fprintf(stderr,"Glasgow Haskell parser, version %s\n", PARSER_VERSION);
233 if (tlist(l1) == lnil)
235 for(t = l1; tlist(ltl(t)) != lnil; t = ltl(t))
242 lapp(list l1, VOID_STAR l2)
246 if (tlist(l1) == lnil)
247 return(mklcons(l2, mklnil()));
248 for(t = l1; tlist(ltl(t)) != lnil; t = ltl(t))
250 ltl(t) = mklcons(l2, mklnil());