fgen.h revision 1.2 1 /*
2 * fgen.h -- stuff for the fcode tokenizer.
3 *
4 * Copyright (c) 1998 Eduardo Horvath.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Eduardo Horvath.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software withough specific prior written permission
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 /* Type of a Cell */
34 typedef long Cell;
35
36 /* Token from the scanner. */
37 struct tok {
38 int type;
39 char *text;
40 };
41
42 #define TOKEN struct tok
43 #define YY_DECL TOKEN* yylex __P((void))
44
45 #define FCODE 0xF00DBABE
46 #define MACRO 0xFEEDBABE
47
48 /* Defined fcode and string. */
49 struct fcode {
50 char *name;
51 long num;
52 int type;
53 struct fcode *l;
54 struct fcode *r;
55 };
56
57 /* macro instruction as separate words */
58 struct macro {
59 char *name;
60 char *equiv;
61 int type;
62 struct macro *l;
63 struct macro *r;
64 };
65
66 /*
67 * FCode header -- assumes big-endian machine,
68 * otherwise the bits need twiddling.
69 */
70 struct fcode_header {
71 char header;
72 char format;
73 short checksum;
74 int length;
75 };
76
77 /* Tokenizer tokens */
78 enum toktypes {
79 TOK_OCTAL = 8,
80 TOK_DECIMAL = 10,
81 TOK_HEX = 16,
82
83 TOK_NUMBER,
84 TOK_STRING_LIT,
85 TOK_C_LIT,
86 TOK_PSTRING,
87 TOK_TOKENIZE,
88 TOK_COMMENT,
89 TOK_ENDCOMMENT,
90 TOK_COLON,
91 TOK_SEMICOLON,
92 TOK_TOSTRING,
93
94 /* These are special */
95 TOK_AGAIN,
96 TOK_ALIAS,
97 TOK_GETTOKEN,
98 TOK_ASCII,
99 TOK_BEGIN,
100 TOK_BUFFER,
101 TOK_CASE,
102 TOK_CONSTANT,
103 TOK_CONTROL,
104 TOK_CREATE,
105 TOK_DEFER,
106 TOK_DO,
107 TOK_ELSE,
108 TOK_ENDCASE,
109 TOK_ENDOF,
110 TOK_EXTERNAL,
111 TOK_FIELD,
112 TOK_HEADERLESS,
113 TOK_HEADERS,
114 TOK_IF,
115 TOK_LEAVE,
116 TOK_LOOP,
117 TOK_OF,
118 TOK_REPEAT,
119 TOK_THEN,
120 TOK_TO,
121 TOK_UNTIL,
122 TOK_VALUE,
123 TOK_VARIABLE,
124 TOK_WHILE,
125 TOK_OFFSET16,
126
127 /* Tokenizer directives */
128 TOK_BEGTOK,
129 TOK_EMIT_BYTE,
130 TOK_ENDTOK,
131 TOK_FLOAD,
132
133 TOK_OTHER
134 };
135