2 // RMAC - Reboot's Macro Assembler for the Atari Jaguar Console System
3 // TOKEN.H - Token Handling
4 // Copyright (C) 199x Landon Dyer, 2011 Reboot and Friends
5 // RMAC derived from MADMAC v1.07 Written by Landon Dyer, 1986
6 // Source Utilised with the Kind Permission of Landon Dyer
15 // Include Files and Macros
16 #define SRC_IFILE 0 // Input source is IFILE
17 #define SRC_IMACRO 1 // Input source is IMACRO
18 #define SRC_IREPT 2 // Input source is IREPT
21 #define INOBJ struct _inobj
22 #define IUNION union _iunion
23 #define IFILE struct _incldfile
24 #define IMACRO struct _imacro
25 #define IREPT struct _irept
26 #define IFENT struct _ifent
28 // Tunable definitions
29 #define LNSIZ 256 // Maximum size of a line of text
30 #define TOKBUFSIZE 400 // Size of token-line buffer
31 #define QUANTUM 4096L // #bytes to eat at a time from a file
32 #define LNBUFSIZ (QUANTUM*2) // Size of file's buffer
33 #define KWSIZE 7 // Maximum size of keyword in kwtab.h
35 // (Normally) non-printable tokens
36 #define COLON ':' // : (grumble: GNUmacs hates ':')
37 #define CONST 'a' // CONST <value>
38 #define ACONST 'A' // ACONST <value> <attrib>
39 #define STRING 'b' // STRING <address>
40 #define SYMBOL 'c' // SYMBOL <address>
41 #define EOL 'e' // End of line
42 #define TKEOF 'f' // End of file (or macro)
43 #define DEQUALS 'g' // ==
44 #define SET 149 // Set
45 #define REG 'R' // Reg
46 #define DCOLON 'h' // ::
49 #define NE 'k' // <> or !=
52 #define UNMINUS 'n' // Unary '-'
53 #define DOTB 'B' // .b or .B or .s or .S
54 #define DOTW 'W' // .w or .W
55 #define DOTL 'L' // .l or .L
56 #define DOTI 'I' // .l or .L
57 #define ENDEXPR 'E' // End of expression
60 #define CR_DEFINED 'p' // ^^defined - is symbol defined?
61 #define CR_REFERENCED 'q' // ^^referenced - was symbol referenced?
62 #define CR_STREQ 'v' // ^^streq - compare two strings
63 #define CR_MACDEF 'w' // ^^macdef - is macro defined?
64 #define CR_TIME 'x' // ^^time - DOS format time
65 #define CR_DATE 'y' // ^^date - DOS format date
67 // Character Attributes
68 #define ILLEG 0 // Illegal character (unused)
69 #define DIGIT 1 // 0-9
70 #define HDIGIT 2 // A-F, a-f
71 #define STSYM 4 // A-Z, a-z, _~.
72 #define CTSYM 8 // A-Z, a-z, 0-9, _~$?
73 #define SELF 16 // Single-character tokens: ( ) [ ] etc
74 #define WHITE 32 // Whitespace (space, tab, etc.)
75 #define MULTX 64 // Multiple-character tokens
76 #define DOT 128 // [bwlsBWSL] for what follows a `.'
78 // Conditional assembly structures
80 IFENT *if_prev; // Ptr prev .if state block (or NULL)
81 WORD if_state; // 0:enabled, 1:disabled
84 // Pointer to IFILE or IMACRO
91 // Ptr to IFILEs, IMACROs, and so on; back-ptr to previous input objects
93 WORD in_type; // 0=IFILE, 1=IMACRO ...
94 IFENT *in_ifent; // Pointer to .if context on entry
95 INOBJ *in_link; // Pointer to previous INOBJ
96 TOKEN *in_otok; // Old `tok' value
97 TOKEN *in_etok; // Old `etok' value
98 IUNION inobj; // IFILE or IMACRO ...
101 // Information about a file
103 IFILE *if_link; // Pointer to ancient IFILEs
104 char *ifoldfname; // Old file's name
105 int ifoldlineno; // Old line number
106 int ifind; // Position in file buffer
107 int ifcnt; // #chars left in file buffer
108 int ifhandle; // File's descriptor
109 WORD ifno; // File number
110 char ifbuf[LNBUFSIZ]; // Line buffer
113 // Information about a macro invocation
115 IMACRO *im_link; // Pointer to ancient IMACROs
116 LONG *im_nextln; // Next line to include
117 WORD im_nargs; // # of arguments supplied on invocation
118 WORD im_siz; // Size suffix supplied on invocation
119 LONG im_olduniq; // Old value of 'macuniq'
120 SYM *im_macro; // Pointer to macro we're in
121 char im_lnbuf[LNSIZ]; // Line buffer
124 // Information about a .rept invocation
126 LONG *ir_firstln; // Pointer to first line
127 LONG *ir_nextln; // Pointer to next line
128 VALUE ir_count; // Repeat count (decrements)
131 // Globals, externals etc
133 extern int curlineno;
134 extern char *curfname;
139 extern char tolowertab[];
140 extern INOBJ *cur_inobj;
141 extern unsigned orgactive;
142 extern unsigned orgaddr;
144 extern int mjump_align;
147 int include(int, char *);
148 void init_token(void);
156 #endif // __TOKEN_H__