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