[project @ 1996-01-11 14:06:51 by partain]
[ghc-hetmet.git] / ghc / compiler / yaccParser / 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 extern BOOLEAN warnSCC;
20                                   
21 extern BOOLEAN implicitPrelude;
22 extern BOOLEAN ignorePragmas;
23
24 extern int minAcceptablePragmaVersion;
25 extern int maxAcceptablePragmaVersion;
26 extern int thisIfacePragmaVersion;
27
28 extern unsigned hash_table_size;
29 extern char *input_file_dir;
30
31 extern list imports_dirlist;
32 extern list sys_imports_dirlist;
33
34 extern char HiSuffix[];
35 extern char PreludeHiSuffix[];
36
37 void process_args PROTO((int, char **));
38
39 /* end of util.c stuff */
40
41 list mklcons    PROTO((void *h, list t)); /* if we have PROTO, we have "void *" */
42 list lapp       PROTO((list l1, void *l2));
43 list lconc      PROTO((list l1, list l2));
44 list mktruecase PROTO((tree t));
45
46 #define lsing(l) mklcons(l, Lnil)               /* Singleton Lists */
47 #define ldub(l1, l2) mklcons(l1, lsing(l2))     /* Two-element Lists */
48
49 #define FN fns[icontexts]
50 #define SAMEFN samefn[icontexts]
51 #define PREVPATT prevpatt[icontexts]
52
53 tree *Rginfun PROTO((struct Sap *));
54 tree *Rginarg1 PROTO((struct Sap *));
55 tree *Rginarg2 PROTO((struct Sap *));
56
57 #define ginfun(xx) *Rginfun(xx)
58 #define ginarg1(xx) *Rginarg1(xx)
59 #define ginarg2(xx) *Rginarg2(xx)
60
61 id installid PROTO((char *));              /* Create a new identifier */
62 hstring installHstring PROTO((int, char *)); /* Create a new literal string */
63
64 id      install_literal PROTO((char *));
65 char   *id_to_string PROTO((id));
66
67 struct infix *infixlookup PROTO((id));
68
69 /* partain additions */
70
71 char    *xmalloc PROTO((unsigned)); /* just a GNU-style error-checking malloc */
72 int      printf  PROTO((const char *, ...));
73 int      fprintf PROTO((FILE *, const char *, ...));
74 /*varies (sun/alpha): int fputc   PROTO((char, FILE *)); */
75 int      fputs   PROTO((const char *, FILE *));
76 int      sscanf  PROTO((const char *, const char *, ...));
77 long     strtol  PROTO((const char *, char **, int));
78 size_t   fread   PROTO((void *, size_t, size_t, FILE *));
79 int      fclose  PROTO((FILE *));
80 int      isatty  PROTO((int));
81 /*extern ???       _filbuf */
82 /*extern ???     _flsbuf */
83
84 void     format_string PROTO((FILE *, unsigned char *, int));
85 tree     mkbinop PROTO((char *, tree, tree));
86 tree     mkinfixop PROTO((char *, tree, tree));
87 list     type2context PROTO((ttype));
88 pbinding createpat PROTO((list, binding));
89 void     process_args PROTO((int, char **));
90 void     hash_init PROTO((void));
91 void     print_hash_table PROTO((void));
92 long int hash_index PROTO((id));
93 void     yyinit PROTO((void));
94 int      yyparse PROTO((void));
95 int      yylex PROTO((void));
96 void     setyyin PROTO((char *));
97 void     yyerror PROTO((char *));
98 void     error PROTO((char *));
99 void     hsperror PROTO((char *));
100 void     enteriscope PROTO((void));
101 void     exposeis PROTO((void));
102 void     makeinfix PROTO((id, int, int));
103 int      nfixes PROTO((void));
104 long int precedence PROTO((int));
105 int      pprecedence PROTO((struct infix *));
106 int      pfixity PROTO((struct infix *));
107 void     pprogram PROTO((tree));
108 void     hsincindent PROTO((void));
109 void     hssetindent PROTO((void));
110 void     hsendindent PROTO((void));
111 void     hsindentoff PROTO((void));
112
113 int      checkfixity PROTO((char *));
114 void     checksamefn PROTO((char *));
115 void     checkinpat PROTO((void));
116
117 void     patternOrExpr PROTO((int,tree));
118 /* the "int" arg says what we want; it is one of: */
119 #define LEGIT_PATT 1
120 #define LEGIT_EXPR 2
121
122 BOOLEAN lhs_is_patt PROTO((tree));
123 tree    function PROTO((tree));
124 void    extendfn PROTO((binding, binding));
125 void    precparse PROTO((tree));
126 void    checkorder PROTO((binding));
127 void    checkprec PROTO((tree, id, BOOLEAN));
128 BOOLEAN isconstr PROTO((char *));
129 void    setstartlineno PROTO((void));
130 void    find_module_on_imports_dirlist PROTO((char *, BOOLEAN, char *));
131 char   *fixop PROTO((int));
132 char   *fixtype PROTO((int));
133
134 /* mattson additions */
135 char *xstrdup PROTO((char *));            /* Duplicate a string */
136 char *xstrndup PROTO((char *, unsigned)); /* Duplicate a substring */
137 char *xrealloc PROTO((char *, unsigned)); /* Re-allocate a string */
138
139 #endif /* __UTILS_H */