]> git.sur5r.net Git - cc65/blob - src/ca65/token.h
Added builtin .min() and .max() pseudo functions to the assembler.
[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      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 {
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_FEATURE,
168     TOK_FILEOPT,
169     TOK_FORCEIMPORT,
170     TOK_FORCEWORD,
171     TOK_GLOBAL,
172     TOK_GLOBALZP,
173     TOK_HIBYTE,
174     TOK_HIBYTES,
175     TOK_HIWORD,
176     TOK_I16,
177     TOK_I8,
178     TOK_MAKEIDENT,
179     TOK_IF,
180     TOK_IFBLANK,
181     TOK_IFCONST,
182     TOK_IFDEF,
183     TOK_IFNBLANK,
184     TOK_IFNCONST,
185     TOK_IFNDEF,
186     TOK_IFNREF,
187     TOK_IFP02,
188     TOK_IFP816,
189     TOK_IFPC02,
190     TOK_IFPSC02,
191     TOK_IFREF,
192     TOK_IMPORT,
193     TOK_IMPORTZP,
194     TOK_INCBIN,
195     TOK_INCLUDE,
196     TOK_INTERRUPTOR,
197     TOK_LEFT,
198     TOK_LINECONT,
199     TOK_LIST,
200     TOK_LISTBYTES,
201     TOK_LOBYTE,
202     TOK_LOBYTES,
203     TOK_LOCAL,
204     TOK_LOCALCHAR,
205     TOK_LOWORD,
206     TOK_MACPACK,
207     TOK_MACRO,
208     TOK_MATCH,
209     TOK_MAX,
210     TOK_MID,
211     TOK_MIN,
212     TOK_NULL,
213     TOK_ORG,
214     TOK_OUT,
215     TOK_P02,
216     TOK_P816,
217     TOK_PAGELENGTH,
218     TOK_PARAMCOUNT,
219     TOK_PC02,
220     TOK_POPSEG,
221     TOK_PROC,
222     TOK_PSC02,
223     TOK_PUSHSEG,
224     TOK_REFERENCED,
225     TOK_RELOC,
226     TOK_REPEAT,
227     TOK_RES,
228     TOK_RIGHT,
229     TOK_RODATA,
230     TOK_SCOPE,
231     TOK_SEGMENT,
232     TOK_SET,
233     TOK_SETCPU,
234     TOK_SIZEOF,
235     TOK_SMART,
236     TOK_SPRINTF,
237     TOK_STRAT,
238     TOK_STRING,
239     TOK_STRLEN,
240     TOK_STRUCT,
241     TOK_SUNPLUS,
242     TOK_TAG,
243     TOK_TCOUNT,
244     TOK_TIME,
245     TOK_UNION,
246     TOK_VERSION,
247     TOK_WARNING,
248     TOK_WORD,
249     TOK_XMATCH,
250     TOK_ZEROPAGE,
251     TOK_LASTPSEUDO      = TOK_ZEROPAGE,
252
253     TOK_COUNT           /* Count of tokens */
254 } Token;
255
256
257
258 /*****************************************************************************/
259 /*                                   Code                                    */
260 /*****************************************************************************/
261
262
263
264 int TokHasSVal (Token Tok);
265 /* Return true if the given token has an attached SVal */
266
267 int TokHasIVal (Token Tok);
268 /* Return true if the given token has an attached IVal */
269
270 #if defined(HAVE_INLINE)
271 INLINE int TokIsSep (enum Token T)
272 /* Return true if this is a separator token */
273 {
274     return (T == TOK_SEP || T == TOK_EOF);
275 }
276 #else
277 #  define TokIsSep(T)   (T == TOK_SEP || T == TOK_EOF)
278 #endif
279
280
281
282 /* End of token.h */
283
284 #endif
285
286
287