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