MWCC/includes/compiler/CPrep.h

136 lines
4.9 KiB
C
Raw Permalink Normal View History

2022-11-07 03:06:21 +00:00
#ifndef COMPILER_CPREP_H
#define COMPILER_CPREP_H
#include "compiler/common.h"
#include "compiler/tokens.h"
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
2022-12-29 12:32:55 +00:00
struct Macro {
Macro *next;
2022-11-07 03:06:21 +00:00
HashNameNode *name;
2023-01-10 11:05:21 +00:00
char *c;
2022-11-07 03:06:21 +00:00
unsigned short xC;
Boolean is_special;
Boolean xF;
2023-01-11 22:29:53 +00:00
HashNameNode *names[0];
2022-12-29 12:32:55 +00:00
};
2022-11-07 03:06:21 +00:00
typedef struct TokenStack {
char *pos;
char *macrostart;
Macro *macro;
Boolean macrocheck;
} TokenStack;
//#define OPT_OFFSET(optname) ((short) (((char *) (&copts.optname)) - ((char *) &copts)))
#define OPT_OFFSET(optname) ((UInt16) ( &((CompilerLinkerOptions *)0)->optname ))
enum {
OPT_OFFSET_MASK = 0x1FFF,
OPT_FLAG_2000 = 0x2000,
OPT_FLAG_4000 = 0x4000,
OPT_FLAG_8000 = 0x8000
};
extern CompilerLinkerParamBlk *cparamblkptr;
2022-11-07 03:06:21 +00:00
extern short tk;
extern CInt64 tkintconst;
extern Float tkfloatconst;
extern char *tkstring;
extern HashNameNode *tkidentifier;
extern SInt32 tksize;
extern short ispascalstring;
extern short nlflag;
extern SInt32 lines;
extern Boolean spaceskip;
extern struct Macro **macrohashtable;
extern Boolean cprep_nomem_exit;
extern Boolean cprep_nostring;
extern Boolean cprep_eoltokens;
extern TokenStack tokenstack[128];
extern short tokenstacklevel;
extern CPrepFileInfo *cprep_cursymfile;
extern char *pos;
extern char *macropos;
extern char *nextcharpos;
extern unsigned char CPrep_SkipNewCommentChar;
extern Boolean preprocessing_only;
extern Handle stringmem;
extern SInt32 maxstringsize;
extern char cprep_idarray[256];
extern Boolean was_escchar;
extern Boolean macrocheck;
extern Boolean widestring;
extern Boolean at_linestart;
extern char *prep_file_start;
extern char *prep_file_end;
extern char *macrostart;
extern Boolean cprep_strconcat;
extern CPrepFileInfo *prep_file;
extern short filesp;
extern SInt32 linenumber;
extern struct GList pplist;
2023-01-10 11:05:21 +00:00
extern TStreamElement *ts_last;
2022-11-07 03:06:21 +00:00
extern TStreamElement *ts_current;
extern SInt32 ts_preread_elements;
extern void CPrep_InsertSpecialMacro(Macro *macro, char *name);
extern void CPrep_InsertSpecialMacros(void);
extern void CPrep_RemoveSpecialMacros(void);
extern Boolean setupprep(void);
extern void cleanupprep(void);
extern void CPrep_TSBufferGrow(int amount);
// this is actually an arg of `PrepState *`
2022-11-07 03:06:21 +00:00
extern void CPrep_TokenStreamGetState(SInt32 *state);
// this is actually an arg of `const PrepState *`
2022-11-07 03:06:21 +00:00
extern void CPrep_TokenStreamSetState(SInt32 *state);
extern void CPrep_UnLex(void);
// this is actually an arg of `const PrepState *`
2022-11-07 03:06:21 +00:00
extern void CPrep_TokenStreamSetCurState(SInt32 *state);
typedef void (*CPrepStreamFuncPtr)(TStreamElement *);
2023-01-11 22:29:53 +00:00
extern void CPrep_StreamGetBlock(TokenStream *stream, CPrepStreamFuncPtr func, int arg);
extern void CPrep_StreamGetSemicolon(TokenStream *stream, CPrepStreamFuncPtr func);
extern void CPrep_StreamGetTemplate(TokenStream *stream, CPrepStreamFuncPtr func);
extern void CPrep_StreamInsert(TokenStream *stream, SInt32 *state);
extern void CPrep_StreamRemove(TokenStream *stream, SInt32 *state);
2022-11-07 03:06:21 +00:00
extern void CPrep_RemoveTokens(SInt32 amount);
extern void CPrep_TokenStreamFlush(void);
extern TStreamElement *CPrep_CurStreamElement(void);
extern void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SInt32 *selectionoffset, short *tokensize, SInt32 *linenumber, char *buf1, short *tokenoffset, short *tokenlength, char *buf2, short *lastarg);
extern void CPrep_Error(short code);
extern void CPrep_ErrorName(short code, const char *name);
extern void CPrep_Warning(short code);
extern void CPrep_WarningName(short code, const char *name);
extern void CPrep_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2);
extern void CPrep_ErrorMessageVA(int code, const char *format, va_list list, Boolean flag1, Boolean flag2);
extern void popfile(void);
extern void CPrep_SetSourceFile(FileOffsetInfo *foi);
extern HashNameNode *CPrep_GetSourceFilePath(CPrepFileInfo *fileinfo);
extern void CPrep_NewFileOffsetInfo(FileOffsetInfo *foi, TStreamElement *ts);
extern SInt32 CPrep_GetFileOffsetInfo(FileOffsetInfo *foi);
extern void CPrep_GetFileOffsetInfo2(FileOffsetInfo *foi, SInt32 *pLine, HashNameNode **pName);
extern void CPrep_ResetFileInfo(FileOffsetInfo *foi);
extern void CPrep_GetPrepPos(CPrepFileInfo **file, SInt32 *ppos);
extern UInt8 C_Compiler(CompilerLinkerParamBlk *param);
2022-11-07 03:06:21 +00:00
extern void poptokenseq(void);
extern void foundnl(void);
extern void newline(void);
extern short notendofline(void);
extern char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2);
extern Boolean macrotest(void);
extern short CPrep_PragmaLex(Boolean no_err);
extern void CPrep_PushOption(SInt32 id, char value);
extern void CPrep_PopOption(SInt32 id);
extern void preprocessor(void);
extern SInt32 CPrep_BrowserTokenOffset(FileOffsetInfo *foi);
extern SInt32 CPrep_BrowserFileOffset(void);
extern void CPrep_BrowserFilePosition(CPrepFileInfo **fileinfo, SInt32 *offset);
extern CPrepFileInfo *CPrep_BrowserCurrentFile(void);
#ifdef __MWERKS__
#pragma options align=reset
#endif
#endif