/* Copyright (C) 2001 Michael Leonhard
 * Mike Leonhard
 * mike at tamale dot net
 * http://tamale.net/
 */

enum {	/* assembler types */
	subtype,
	inttype,
	floattype,
	stringtype
	};
	
enum {	/* parser build a tree with these types */
	vitaminc,
	statementblock,
	statement,
	definition,
	assign,

	expression,
	or,
	xor,
	lsh,
	rsh,
	gt,
	lt,
	equal,
	subtract,
	add,
	multiply,
	divide,
	
	/* tokenizer produces these types */
	tokenlist,
	identifier,
	subkeyword,
	returnkeyword,
	intkeyword,
	floatkeyword,
	stringkeyword,
	integer,
	floatingpoint,
	string,
	colonsymbol,
	assignsymbol,
	semicolonsymbol,
	leftparensymbol,
	rightparensymbol, 
	orsymbol,
	xorsymbol,
	lshsymbol,
	rshsymbol,
	gtsymbol,
	ltsymbol,
	equalsymbol,
	subtractsymbol,
	addsymbol,
	multiplysymbol,
	dividesymbol,
	endline
	};

struct Particle {
	int type, place;
	void *data;
	struct Particle **child;
	int childnum, childspace;
	};

struct Symbol {
	int type;
	char *name;
	int place, consume, produce;
	};

struct SymbolList {
	struct Symbol **list;
	int num, space;
	};

struct Ascorbic {
	char *filename, *source;
	void *out;
	
	char *errortext;
	int place;
	
	struct Particle *list, *tree;
	int i;
	struct SymbolList *symbols;
	int defncount, numdefns, frameheight;
	};

/* ascorbic.c */
int Ascorbic_Error( struct Ascorbic *asc, char *text );
int Ascorbic_ErrorHere( struct Ascorbic *asc, char *here, char *text );
int Ascorbic_ErrorParticle( struct Ascorbic *asc, struct Particle *particle, char *text );
int Ascorbic_PError( struct Ascorbic *asc, char *text );
int Ascorbic_PrintError( struct Ascorbic *asc );
int Ascorbic_PrintErrorOnLine( struct Ascorbic *asc );
int Ascorbic_PrintLine( struct Ascorbic *asc );
int main( int argc, char *argv[] );
int usage();

/* assembly.h */
int Assembly_Write( struct Ascorbic *asc );

/* file.c */
int File_CloseOutput( struct Ascorbic *asc );
int File_OpenOutput( struct Ascorbic *asc, char *outname );
int File_ReadSource( struct Ascorbic *asc );

/* parse.c */
int Parse_CreateTree( struct Ascorbic *asc );

/* particle.c */
void Particle_Add( struct Particle *particle, struct Particle *child );
void Particle_AddNew( struct Particle *parent, int type, int place );
void Particle_Free( struct Particle *particle );
void Particle_FreeChildren( struct Particle *particle );
struct Particle *Particle_New( int type, int place );
void Particle_Print( struct Ascorbic *asc, struct Particle *particle, int depth );

/* tokenize.c */
int Tokenize_Source( struct Ascorbic *asc );
