// TinC - Tiny, in C

// tinc13.h


#define COMPILER "TinC v1.3\n\n"


/*--------------------------------------------------------------*/
/* A clutch of constants */

#define FALSE        	0

#define TRUE         	-1

#define EXIT_SUCCESS 	0

#define EXIT_FAIL    	1

#define STRTMPSIZE   	256


#define TAB             '\t'

#define CR              '\015'

#define LF              '\n'


#define MAXSYMSIZE	16

#define MAXGLOBALS      1000

#define MAXLOCALS	64

#define MAXSTAGE	128000

#define MAXDEFS		5000

#define MAXLINESIZE	80

#define MAXPARAMS	16

#define MAXCONSTS	100

#define MAXCONSTSIZE    80

#define MAXINCL		9



/*--------------------------------------------------------------*/
/* Register control and data type bits */

#define DT_UCHAR	1

#define DT_CHAR		2

#define DT_INT		4

#define DT_UINT		8

#define DT_CPTR		16

#define DT_IPTR		32

#define DT_UCPTR	64

#define DT_UIPTR	128

#define DT_PROCEDURE	256

#define DT_INTERRUPT	512


#define DT_XCHAR	DT_CHAR | DT_UCHAR

#define DT_XINT		DT_INT | DT_UINT

#define DT_XCPTR	DT_CPTR | DT_UCPTR

#define DT_XIPTR	DT_IPTR | DT_UIPTR

#define DT_XPTR		DT_XCPTR | DT_XIPTR


#define DT_ALL		DT_XCHAR | DT_XINT | DT_XPTR


#define TYPEDESCSIZE	10



/*--------------------------------------------------------------*/
/* Definition of Token Types, etc */

typedef char  Symbol[MAXSYMSIZE+1];

#define NKW             20

#define NKW1            21


static Symbol KWlist[NKW] =    {"if", "else", "endif", "while",
				"endwhile", "char", "end",
				"int", "#define", "unsigned",
				"#inline", "#ifdef", "#endif",
				"program", "procedure", "begin",
				"interrupt", "#include", "for",
				"endfor"
			       };

#define TOK_IDENTIFIER		'x'

#define TOK_IF			'i'

#define TOK_ELSE		'l'

#define TOK_ENDIF		'e'

#define TOK_WHILE		'w'

#define TOK_ENDWHILE		'e'

#define TOK_CHARDEF		'C'

#define TOK_END			'e'

#define TOK_NUM			'N'

#define TOK_INTDEF		'I'

#define TOK_DEFINE		'd'

#define TOK_UNSIGNED		'U'

#define TOK_INLINE		'a'

#define TOK_IFDEF		0x03

#define TOK_ENDIFDEF		0x04

#define TOK_PROGRAM		'P'

#define TOK_PROCEDURE		'R'

#define TOK_BEGIN		'B'

#define TOK_INTERRUPT		'S'

#define TOK_INCLUDE		'E'

#define TOK_FOR			'f'

#define TOK_ENDFOR		'e'


#define TOK_HEX			'H'

#define TOK_DIRECTIVE		'#'

#define TOK_BLOCK_COMMENT	0x01

#define TOK_LINE_COMMENT	0x02

#define TOK_UCHARDEF		'D'

#define TOK_UINTDEF		'J'


static char KWcode[NKW1 + 1] = {TOK_IDENTIFIER, TOK_IF, TOK_ELSE,
				TOK_ENDIF, TOK_WHILE, TOK_ENDWHILE,
				TOK_CHARDEF, TOK_END,TOK_INTDEF,
				TOK_DEFINE, TOK_UNSIGNED, TOK_INLINE,
				TOK_IFDEF, TOK_ENDIFDEF, TOK_PROGRAM,
				TOK_PROCEDURE, TOK_BEGIN, TOK_INTERRUPT,
				TOK_INCLUDE, TOK_FOR, TOK_ENDFOR
				};


/*--------------------------------------------------------------*/
/* return codes for WhatIs() */

#define UNKNOWN		0

#define PARAM		1

#define LOCAL		2

#define GLOBAL		3



/*--------------------------------------------------------------*/
/* pcode definitions - DO NOT CHANGE */

#define PC_GETREG		 1

#define PC_FREEREG		 2


#define PC_FIRST_REAL		 3


#define PC_LABEL                 3

#define PC_BRANCH                4

#define PC_BRANCH_FALSE          5

#define PC_HEADER                6

#define PC_PROLOG                7

#define PC_EPILOG                8

#define PC_ALLOCATE              9

#define PC_GROWSTACK	        10

#define PC_SHRINKSTACK	        11

#define PC_MOVE_REG		12

#define PC_ADD_REG		13

#define PC_SUB_REG		14

#define PC_MOVE_VAR_REG         15

#define PC_MOVE_LVAR_REG        16

#define PC_MOVE_REG_VAR         17

#define PC_MOVE_REG_LVAR        18

#define PC_MUL_REG		19

#define PC_DIV_REG		20

#define PC_CLEAR_REG		21

#define PC_COMPARE_REG		22

#define PC_AND_REG		23

#define PC_OR_REG		24

#define PC_XOR_REG		25

#define PC_NOT_REG		26

#define PC_MOVE_A_REG           27

#define PC_MOVE_AL_REG          28

#define PC_MOVE_I_REG           29

#define PC_ADJUST_REG           30

#define PC_MOVE_REG_I           31

#define PC_MOVE_CONST_REG	32

#define PC_SET_REG_EQ           33

#define PC_SET_REG_NE           34

#define PC_SET_REG_LT           35

#define PC_SET_REG_GT           36

#define PC_SET_REG_GE           37

#define PC_SET_REG_LE           38

#define PC_INLINE		39

#define PC_SHIFTRIGHT		40

#define PC_SHIFTLEFT		41

#define PC_SETFP		42

#define PC_PUSHFP		43

#define PC_POPFP		44

#define PC_DOCALL		45

#define PC_CALLRET		46

#define PC_INTRET		47

#define PC_MOVE_PVAR_REG        48

#define PC_MOVE_REG_PVAR        49

#define PC_MOVE_AP_REG          50

#define PC_PUSH_REG		51

#define PC_PROGSEC		52

#define PC_DATASEC		53

#define PC_CONST		54


#define PC_OPTSTART		55


#include "tinct13.h"