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