]> git.sur5r.net Git - cc65/blob - src/ca65/token.h
b334c5bbf0e7fdb871229a85d4fb2abce56d1f48
[cc65] / src / ca65 / token.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                  token.h                                  */
4 /*                                                                           */
5 /*                  Token list for the ca65 macro assembler                  */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2007-2011, Ullrich von Bassewitz                                      */
10 /*                Roemerstrasse 52                                           */
11 /*                D-70794 Filderstadt                                        */
12 /* EMail:         uz@cc65.org                                                */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef TOKEN_H
37 #define TOKEN_H
38
39
40
41 /* common */
42 #include "inline.h"
43
44
45
46 /*****************************************************************************/
47 /*                                   Data                                    */
48 /*****************************************************************************/
49
50
51
52 /* Tokens */ 
53 typedef enum token_t {
54     TOK_NONE,           /* Start value, invalid */
55     TOK_EOF,            /* End of input file */
56     TOK_SEP,            /* Separator (usually newline) */
57     TOK_IDENT,          /* An identifier */
58     TOK_LOCAL_IDENT,    /* A cheap local identifier */
59
60     TOK_INTCON,         /* Integer constant */
61     TOK_CHARCON,        /* Character constant */
62     TOK_STRCON,         /* String constant */
63
64     TOK_A,              /* A)ccumulator */
65     TOK_X,              /* X register */
66     TOK_Y,              /* Y register */
67     TOK_S,              /* S register */
68     TOK_REG,            /* Sweet16 R.. register (in sweet16 mode) */
69
70     TOK_ASSIGN,         /* := */
71     TOK_ULABEL,         /* :++ or :-- */
72
73     TOK_EQ,             /* = */
74     TOK_NE,             /* <> */
75     TOK_LT,             /* < */
76     TOK_GT,             /* > */
77     TOK_LE,             /* <= */
78     TOK_GE,             /* >= */
79
80     TOK_BOOLAND,        /* .and */
81     TOK_BOOLOR,         /* .or */
82     TOK_BOOLXOR,        /* .xor */
83     TOK_BOOLNOT,        /* .not */
84
85     TOK_PLUS,           /* + */
86     TOK_MINUS,          /* - */
87     TOK_MUL,            /* * */
88     TOK_STAR = TOK_MUL, /* Alias */
89     TOK_DIV,            /* / */
90     TOK_MOD,            /* ! */
91     TOK_OR,             /* | */
92     TOK_XOR,            /* ^ */
93     TOK_BANK = TOK_XOR, /* Alias */
94     TOK_AND,            /* & */
95     TOK_SHL,            /* << */
96     TOK_SHR,            /* >> */
97     TOK_NOT,            /* ~ */
98
99     TOK_PC,             /* $ if enabled */
100     TOK_NAMESPACE,      /* :: */
101     TOK_DOT,            /* . */
102     TOK_COMMA,          /* , */
103     TOK_HASH,           /* # */
104     TOK_COLON,          /* : */
105     TOK_LPAREN,         /* ( */
106     TOK_RPAREN,         /* ) */
107     TOK_LBRACK,         /* [ */
108     TOK_RBRACK,         /* ] */
109     TOK_LCURLY,         /* { */
110     TOK_RCURLY,         /* } */
111     TOK_AT,             /* @ - in Sweet16 mode */
112
113     TOK_OVERRIDE_ZP,    /* z: */
114     TOK_OVERRIDE_ABS,   /* a: */
115     TOK_OVERRIDE_FAR,   /* f: */
116
117     TOK_MACPARAM,       /* Macro parameter, not generated by scanner */
118     TOK_REPCOUNTER,     /* Repeat counter, not generated by scanner */
119
120     /* The next ones are tokens for the pseudo instructions. Keep together! */
121     TOK_FIRSTPSEUDO,
122     TOK_A16             = TOK_FIRSTPSEUDO,
123     TOK_A8,
124     TOK_ADDR,
125     TOK_ALIGN,
126     TOK_ASCIIZ,
127     TOK_ASSERT,
128     TOK_AUTOIMPORT,
129     TOK_BANKBYTE,
130     TOK_BANKBYTES,
131     TOK_BLANK,
132     TOK_BSS,
133     TOK_BYTE,
134     TOK_CASE,
135     TOK_CHARMAP,
136     TOK_CODE,
137     TOK_CONCAT,
138     TOK_CONDES,
139     TOK_CONST,
140     TOK_CONSTRUCTOR,
141     TOK_CPU,
142     TOK_DATA,
143     TOK_DBG,
144     TOK_DBYT,
145     TOK_DEBUGINFO,
146     TOK_DEFINE,
147     TOK_DEFINED,
148     TOK_DESTRUCTOR,
149     TOK_DWORD,
150     TOK_ELSE,
151     TOK_ELSEIF,
152     TOK_END,
153     TOK_ENDENUM,
154     TOK_ENDIF,
155     TOK_ENDMACRO,
156     TOK_ENDPROC,
157     TOK_ENDREP,
158     TOK_ENDSCOPE,
159     TOK_ENDSTRUCT,
160     TOK_ENDUNION,
161     TOK_ENUM,
162     TOK_ERROR,
163     TOK_EXITMACRO,
164     TOK_EXPORT,
165     TOK_EXPORTZP,
166     TOK_FARADDR,
167     TOK_FATAL,
168     TOK_FEATURE,
169     TOK_FILEOPT,
170     TOK_FORCEIMPORT,
171     TOK_FORCEWORD,
172     TOK_GLOBAL,
173     TOK_GLOBALZP,
174     TOK_HIBYTE,
175     TOK_HIBYTES,
176     TOK_HIWORD,
177     TOK_I16,
178     TOK_I8,
179     TOK_MAKEIDENT,
180     TOK_IF,
181     TOK_IFBLANK,
182     TOK_IFCONST,
183     TOK_IFDEF,
184     TOK_IFNBLANK,
185     TOK_IFNCONST,
186     TOK_IFNDEF,
187     TOK_IFNREF,
188     TOK_IFP02,
189     TOK_IFP816,
190     TOK_IFPC02,
191     TOK_IFPSC02,
192     TOK_IFREF,
193     TOK_IMPORT,
194     TOK_IMPORTZP,
195     TOK_INCBIN,
196     TOK_INCLUDE,
197     TOK_INTERRUPTOR,
198     TOK_LEFT,
199     TOK_LINECONT,
200     TOK_LIST,
201     TOK_LISTBYTES,
202     TOK_LOBYTE,
203     TOK_LOBYTES,
204     TOK_LOCAL,
205     TOK_LOCALCHAR,
206     TOK_LOWORD,
207     TOK_MACPACK,
208     TOK_MACRO,
209     TOK_MATCH,
210     TOK_MAX,
211     TOK_MID,
212     TOK_MIN,
213     TOK_NULL,
214     TOK_ORG,
215     TOK_OUT,
216     TOK_P02,
217     TOK_P816,
218     TOK_PAGELENGTH,
219     TOK_PARAMCOUNT,
220     TOK_PC02,
221     TOK_POPCPU,
222     TOK_POPSEG,
223     TOK_PROC,
224     TOK_PSC02,
225     TOK_PUSHCPU,
226     TOK_PUSHSEG,
227     TOK_REFERENCED,
228     TOK_RELOC,
229     TOK_REPEAT,
230     TOK_RES,
231     TOK_RIGHT,
232     TOK_RODATA,
233     TOK_SCOPE,
234     TOK_SEGMENT,
235     TOK_SET,
236     TOK_SETCPU,
237     TOK_SIZEOF,
238     TOK_SMART,
239     TOK_SPRINTF,
240     TOK_STRAT,
241     TOK_STRING,
242     TOK_STRLEN,
243     TOK_STRUCT,
244     TOK_SUNPLUS,
245     TOK_TAG,
246     TOK_TCOUNT,
247     TOK_TIME,
248     TOK_UNION,
249     TOK_VERSION,
250     TOK_WARNING,
251     TOK_WORD,
252     TOK_XMATCH,
253     TOK_ZEROPAGE,
254     TOK_LASTPSEUDO      = TOK_ZEROPAGE,
255
256     TOK_COUNT           /* Count of tokens */
257 } token_t;
258
259
260
261 /*****************************************************************************/
262 /*                                   Code                                    */
263 /*****************************************************************************/
264
265
266
267 int TokHasSVal (token_t Tok);
268 /* Return true if the given token has an attached SVal */
269
270 int TokHasIVal (token_t Tok);
271 /* Return true if the given token has an attached IVal */
272
273 #if defined(HAVE_INLINE)
274 INLINE int TokIsSep (enum token_t T)
275 /* Return true if this is a separator token */
276 {
277     return (T == TOK_SEP || T == TOK_EOF);
278 }
279 #else
280 #  define TokIsSep(T)   ((T) == TOK_SEP || (T) == TOK_EOF)
281 #endif
282
283
284
285 /* End of token.h */
286
287 #endif
288
289
290