Home | History | Annotate | Line # | Download | only in fgen
fgen.h revision 1.1
      1 /*
      2  * fgen.h -- stuff for the fcode tokenizer.
      3  */
      4 
      5 /* Type of a Cell */
      6 typedef long Cell;
      7 
      8 /* Token from the scanner. */
      9 struct tok {
     10 	int type;
     11 	char *text;
     12 };
     13 
     14 #define TOKEN struct tok
     15 #define YY_DECL TOKEN* yylex __P((void))
     16 
     17 #define FCODE	0xF00DBABE
     18 #define MACRO	0xFEEDBABE
     19 
     20 /* Defined fcode and string. */
     21 struct fcode {
     22 	char *name;
     23 	long num;
     24 	int type;
     25 	struct fcode *l;
     26 	struct fcode *r;
     27 };
     28 
     29 /* macro instruction as separate words */
     30 struct macro {
     31 	char *name;
     32 	char *equiv;
     33 	int type;
     34 	struct macro *l;
     35 	struct macro *r;
     36 };
     37 
     38 /*
     39  * FCode header -- assumes big-endian machine,
     40  *	otherwise the bits need twiddling.
     41  */
     42 struct fcode_header {
     43 	char	header;
     44 	char	format;
     45 	short	checksum;
     46 	int	length;
     47 };
     48 
     49 /* Tokenizer tokens */
     50 enum toktypes {
     51 	TOK_OCTAL = 8,
     52 	TOK_DECIMAL = 10,
     53 	TOK_HEX = 16,
     54 
     55 	TOK_NUMBER,
     56 	TOK_STRING_LIT,
     57 	TOK_C_LIT,
     58 	TOK_PSTRING,
     59 	TOK_TOKENIZE,
     60 	TOK_COMMENT,
     61 	TOK_ENDCOMMENT,
     62 	TOK_COLON,
     63 	TOK_SEMICOLON,
     64 	TOK_TOSTRING,
     65 
     66 	/* These are special */
     67 	TOK_AGAIN,
     68 	TOK_ALIAS,
     69 	TOK_GETTOKEN,
     70 	TOK_ASCII,
     71 	TOK_BEGIN,
     72 	TOK_BUFFER,
     73 	TOK_CASE,
     74 	TOK_CONSTANT,
     75 	TOK_CONTROL,
     76 	TOK_CREATE,
     77 	TOK_DEFER,
     78 	TOK_DO,
     79 	TOK_ELSE,
     80 	TOK_ENDCASE,
     81 	TOK_ENDOF,
     82 	TOK_EXTERNAL,
     83 	TOK_FIELD,
     84 	TOK_HEADERLESS,
     85 	TOK_HEADERS,
     86 	TOK_IF,
     87 	TOK_LEAVE,
     88 	TOK_LOOP,
     89 	TOK_OF,
     90 	TOK_REPEAT,
     91 	TOK_THEN,
     92 	TOK_TO,
     93 	TOK_UNTIL,
     94 	TOK_VALUE,
     95 	TOK_VARIABLE,
     96 	TOK_WHILE,
     97 	TOK_OFFSET16,
     98 
     99 	/* Tokenizer directives */
    100 	TOK_BEGTOK,
    101 	TOK_EMIT_BYTE,
    102 	TOK_ENDTOK,
    103 	TOK_FLOAD,
    104 
    105 	TOK_OTHER
    106 };
    107