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