summaryrefslogtreecommitdiff
path: root/includes/compiler/CPrep.h
blob: 02d5a765179c66dd4a07897d1bd5d137c5958c31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#ifndef COMPILER_CPREP_H
#define COMPILER_CPREP_H

#include "compiler/common.h"
#include "compiler/tokens.h"

#ifdef __MWERKS__
#pragma options align=mac68k
#endif

struct Macro {
    Macro *next;
    HashNameNode *name;
    char *c;
    unsigned short xC;
    Boolean is_special;
    Boolean xF;
    HashNameNode *names[0];
};
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) ( &((COpts *)0)->optname ))
enum {
    OPT_OFFSET_MASK = 0x1FFF,
    OPT_FLAG_2000 = 0x2000,
    OPT_FLAG_4000 = 0x4000,
    OPT_FLAG_8000 = 0x8000
};

extern CParams *cparamblkptr;
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;
extern TStreamElement *ts_last;
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 *`
extern void CPrep_TokenStreamGetState(SInt32 *state);
// this is actually an arg of `const PrepState *`
extern void CPrep_TokenStreamSetState(SInt32 *state);
extern void CPrep_UnLex(void);
// this is actually an arg of `const PrepState *`
extern void CPrep_TokenStreamSetCurState(SInt32 *state);
typedef void (*CPrepStreamFuncPtr)(TStreamElement *);
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);
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(CParams *param);
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