4 * (c)Copyright 1993-2014, Matthew Dillon, All Rights Reserved. See the
5 * COPYRIGHT file at the base of the distribution.
9 * Headers needed by others using this library
11 #include <sys/types.h>
28 void LexDebugLine(token_t *tok);
33 Declaration *FindDeclId(SemGroup *db, string_t id, int *eno);
34 Declaration *FindDeclIdLevel(SemGroup *db, string_t id, int level, int *eno);
35 Declaration *FindDeclByIndex(SemGroup *sg, int index);
36 void DeclPrintError(Declaration *d, int type);
37 Declaration *FindDeclPath(LexRef *lexRef, SemGroup *osg, SemGroup *sg,
38 Type *nomatch, string_t *ary, int mask,
39 int *visibility, int level, int *eno);
40 Declaration *FindDeclPathAltContext(LexRef *lexRef, SemGroup *osg, SemGroup *sg,
41 Type *nomatch, string_t *ary, int mask,
42 int *visibility, int level, int *eno);
43 void *FindDLLSymbol(SemGroup *osg, SemGroup *sg, string_t id);
48 void ExpPrintError(Exp *exp, int type);
53 Lex *LexOpen(const char *path, token_t *tok);
54 void LexClose(Lex **plex);
55 int LexRedactToken(token_t *tok, int bytes);
56 int LexPeekToken(token_t *tok);
57 int LexToken(token_t *tok);
58 int LexSkipToken(token_t *tok, int type);
59 int LexStripQuotes(token_t *tok, token_t *tmp);
60 int LexError(token_t *tok, int err);
61 void LexPrintError(token_t *tok);
62 void LexPrintRef(LexRef *lr, int type);
63 void LexInitRef(LexRef *lr, token_t *tok);
64 void LexDupRef(LexRef *s, LexRef *d);
65 void LexDoneRef(LexRef *lr);
66 const char *LexErrStr(token_t *tok);
71 void LibRuneInit(void);
76 void *heapAlloc(PointerStor *ps, Type *type);
81 int ParseOpen(Stmt *st, Parse **pp, void **dll);
82 void ParseDone(Parse *p);
83 void ParseClose(Parse **pp);
84 void AddImportPath(const char *path, int flags);
85 void PrefixImportPaths(const char *basePath);
90 int ParseModule(Parse *p, Stmt *st, int t);
91 int ParseStmt(Parse *p, int t, Stmt **pst);
92 int ParseDeclarationStmt(Parse *p, int t, int idRequired, Stmt **pst,
93 int dop, Scope *scope);
98 int ParseScopeQual(Parse *p, int t, Scope *scope);
99 int ParseStorageQual(Parse *p, int t, int *pmask);
100 int ParseDeclaration(Parse *p, int t, Declaration **pd, int idRequired,
101 int dop, Scope *scope);
102 int ParseType(Parse *p, int t, Type **ptype, int sqflags);
103 int ParseDeclType(Parse *p, int t, Type **ptype, SemGroup **psg,
104 int scopeFlags, int rqflags, string_t *id,
105 int idRequired, int isLocked);
110 int ParseExp(Parse *p, int t, Exp **pexp);
111 int ParseParenthesizedExp(Parse *p, int t, Exp **pexp, int docomp);
112 int ParseNotExp(Parse *p, int t, Exp **pexp);
117 void ResolveProject(Parse *p, Stmt *st);
118 void CollapseProject(Stmt *st);
123 Stmt *BuildRootImportStmt(const char *path);
124 void StmtPrintError(Stmt *st, int type);
129 string_t StrTableEscapeQuotedString(const char *str, int len, int term);
130 string_t StrTableAlloc(const char *str, int len, int special);
131 string_t StrTableToken(token_t *tok);
132 string_t StrTableInt(int v);
133 string_t StrTableDup(string_t str);
134 int StrTableSpecial(string_t id);
135 int StrTableLen(string_t id);
136 int StrCmpToken(string_t id, token_t *tok);
137 void ReplaceStrTable(string_t *pstr, string_t id);
138 void RelStrTable(string_t *pstr);
139 const char *StripPathId(const char *path, int *len);
140 int SimpleIntToken(token_t *tok, int *rv);
141 int SimpleRunesizeToken(token_t *tok, runesize_t *rv);
142 int StrTableEnumerate(string_t id);
147 int SymKeywordFind(const char *ptr, int len, int t);
152 char *TypeToStr(Type *type, char **pstr);
153 int SameType(Type *t1, Type *t2, int sqFlags2);
154 int SimilarType(Type *t1, Type *t2);
155 int SimilarSemGroup(SemGroup *s1, SemGroup *s2);
156 int MatchType(Type *super, Type *type);
157 void InternalRegisterType(const char *str, const char *linkname, Type *type);
158 Type *InternalRegisteredTypeLookup(string_t id);
159 void initType(Type *type, typelist_t *list, int op);
160 void initQualType(Type *type, typelist_t *list, int op, int sqflags);
161 void initPtrType(Type *type, Type *ptrto, int sqflags);
162 void initCPtrType(Type *type, Type *ptrto, int sqflags);
163 SemGroup *BaseType(Type **ptype);
166 * High-level Interpreter and Generator
168 runctx_p RunUnresolvedStmt(runctx_p ct, Stmt *st);
169 genctx_p GenUnresolvedStmt(genctx_p ct, Stmt *st);
171 void RunUnresolvedExp(runctx_p ct, rundata_t *data, Exp *exp);
172 int64_t Run64DefaultExp(runctx_p ct, Exp *exp);
173 gendata_t *GenUnresolvedExp(genctx_p ct, Exp *exp);
175 extern typelist_t DynamicTypeList;
176 extern typelist_t CompoundTypeList;
177 extern typelist_t ArgsTypeList;
178 extern typelist_t StorageTypeList;
180 extern void **DefaultDynamicVector;
182 extern Type DynamicRValueType;
183 extern Type DynamicLValueType;
184 extern Type NumericType;
185 extern Type IntegralType;
186 extern Type SIntegerType;
187 extern Type UIntegerType;
188 extern Type VoidType;
189 extern Type BoolType;
190 extern Type Int8Type;
191 extern Type UInt8Type;
192 extern Type Int16Type;
193 extern Type UInt16Type;
194 extern Type Int32Type;
195 extern Type UInt32Type;
196 extern Type Int64Type;
197 extern Type UInt64Type;
198 extern Type Int128Type;
199 extern Type UInt128Type;
201 extern Type FloatType;
202 extern Type Float32Type;
203 extern Type Float64Type;
204 extern Type Float128Type;
206 extern Type CCharType;
207 extern Type StrType; /* NOTE: const char *, chars are unsigned */
208 extern Type CharPtrType;
209 extern Type CharPtrPtrType;
210 extern Type VoidPtrType;
211 extern Type VoidRefType;
212 extern Type CVoidPtrType;
213 extern Type LVoidPtrType;
214 extern Type PointerType; /* generic pointer placeholder */
216 extern Type LexRefType; /* run-time access class tie-ins */
217 extern Type ScopeType;
218 extern Type DeclarationType;
219 extern Type SemGroupType;
220 extern Type TypeType;
221 extern Type FILLERTypeType;
222 extern Type FILLERDeclType;
224 extern Type IntPtrType;
225 extern Type UIntPtrType;
227 extern Type SizeType;
229 extern Type *BaseTypeAry[];
230 extern typereglist_t TypeRegList;