[project @ 1996-03-19 08:58:34 by partain]
[ghc-hetmet.git] / ghc / compiler / parser / utils.h
1 /*
2         Utility Definitions.
3 */
4
5 #ifndef __UTILS_H
6 #define __UTILS_H
7
8 /* stuff from util.c */
9 extern tree root;
10 extern list Lnil;
11 extern list all;
12
13 extern BOOLEAN nonstandardFlag;
14 extern BOOLEAN hashIds;
15 extern BOOLEAN acceptPrim;
16 extern BOOLEAN etags;
17                                   
18 extern BOOLEAN ignoreSCC;
19                                   
20 extern BOOLEAN implicitPrelude;
21 extern BOOLEAN ignorePragmas;
22
23 extern int minAcceptablePragmaVersion;
24 extern int maxAcceptablePragmaVersion;
25 extern int thisIfacePragmaVersion;
26
27 extern unsigned hash_table_size;
28 extern char *input_file_dir;
29
30 extern list imports_dirlist;
31 extern list sys_imports_dirlist;
32
33 extern char HiSuffix[];
34 extern char PreludeHiSuffix[];
35
36 void process_args PROTO((int, char **));
37
38 /* end of util.c stuff */
39
40 list mklcons    PROTO((void *h, list t)); /* if we have PROTO, we have "void *" */
41 list lapp       PROTO((list l1, void *l2));
42 list lconc      PROTO((list l1, list l2));
43
44 #define lsing(l) mklcons(l, Lnil)               /* Singleton Lists */
45 #define ldub(l1, l2) mklcons(l1, lsing(l2))     /* Two-element Lists */
46
47 #define FN fns[icontexts]
48 #define SAMEFN samefn[icontexts]
49 #define PREVPATT prevpatt[icontexts]
50
51 id installid PROTO((char *));                /* Create a new identifier */
52 hstring installHstring PROTO((int, char *)); /* Create a new literal string */
53
54 id      install_literal PROTO((char *));
55 char   *id_to_string PROTO((id));
56
57 id      qid_to_id PROTO((qid));
58 char   *qid_to_string PROTO((qid));
59 char   *qid_to_mod PROTO((qid));             /* NULL if unqual */
60 char   *qid_to_pmod PROTO((qid));            /* "?"  if unqual */
61 qid     creategid PROTO((long));
62
63 /* partain additions */
64
65 char    *xmalloc PROTO((unsigned)); /* just a GNU-style error-checking malloc */
66 int      printf  PROTO((const char *, ...));
67 int      fprintf PROTO((FILE *, const char *, ...));
68 /*varies (sun/alpha): int fputc   PROTO((char, FILE *)); */
69 int      fputs   PROTO((const char *, FILE *));
70 int      sscanf  PROTO((const char *, const char *, ...));
71 long     strtol  PROTO((const char *, char **, int));
72 size_t   fread   PROTO((void *, size_t, size_t, FILE *));
73 int      fclose  PROTO((FILE *));
74 int      isatty  PROTO((int));
75 /*extern ???       _filbuf */
76 /*extern ???     _flsbuf */
77
78 void     pprogram PROTO((tree));
79
80 void     format_string PROTO((FILE *, unsigned char *, int));
81 list     type2context PROTO((ttype));
82 pbinding createpat PROTO((pbinding, binding));
83 void     process_args PROTO((int, char **));
84 void     hash_init PROTO((void));
85 void     print_hash_table PROTO((void));
86 long int hash_index PROTO((id));
87 void     yyinit PROTO((void));
88 int      yyparse PROTO((void));
89 int      yylex PROTO((void));
90 void     setyyin PROTO((char *));
91 void     yyerror PROTO((char *));
92 void     error PROTO((char *));
93 void     hsperror PROTO((char *));
94
95 void     makeinfix PROTO((id, int, int, id, long, long, id, id, long, long, long, list));
96 struct infix *infixlookup PROTO((qid));
97 int      pprecedence PROTO((struct infix *));
98 int      pfixity PROTO((struct infix *));
99 char *   infixstr PROTO((int));
100 long     infixint PROTO((int));
101
102 void     hsincindent PROTO((void));
103 void     hssetindent PROTO((void));
104 void     hsendindent PROTO((void));
105 void     hsindentoff PROTO((void));
106
107 int      checkfixity PROTO((char *));
108 void     checksamefn PROTO((qid));
109 void     checkinpat PROTO((void));
110
111 void     expORpat PROTO((int,tree));
112 /* the "int" arg says what we want; it is one of: */
113 #define LEGIT_PATT 1
114 #define LEGIT_EXPR 2
115
116 BOOLEAN lhs_is_patt PROTO((tree));
117 tree    function PROTO((tree));
118 void    extendfn PROTO((binding, binding));
119 void    checkorder PROTO((binding));
120
121 void    precparse PROTO((tree));
122 void    checkprec PROTO((tree, qid, BOOLEAN));
123 void    checkdostmts PROTO((list));
124 void    checknobangs PROTO((ttype));
125 void    splittyconapp PROTO((ttype, qid *, list *));
126
127 BOOLEAN isconstr PROTO((char *));
128 void    setstartlineno PROTO((void));
129 void    find_module_on_imports_dirlist PROTO((char *, BOOLEAN, char *));
130
131 /* mattson additions */
132 char *xstrdup PROTO((char *));            /* Duplicate a string */
133 char *xstrndup PROTO((char *, unsigned)); /* Duplicate a substring */
134 char *xrealloc PROTO((char *, unsigned)); /* Re-allocate a string */
135
136 #endif /* __UTILS_H */