// compile-h-s.txt
// header file for som-in-som project
//	public release som-v2 30 December 2004

// sequence of loading files
//
// lib.txt
// string-s.txt
// compile-h-s.txt
// list-s.txt
// symtab5-s.txt
// token-s.txt
// parse-h-s.txt
// stmt-s.txt
// parse.som
// icode-s.txt
// gencode-s.txt
// eval-s.txt		not loaded, use eval-c instead
// main-s.txt

enum
	0 NIL MARK BMARK					   // marker
enum
	0 SP OPER NUM GNAME LNAME CNAME STRING // atom
enum
	1 icAdd icSub icMul icDiv icBand icBor icBxor
	icNot icEq icNe icLt icLe icGe icGt icShl icShr icMod
	icLdx icStx icRet icR1 icArray icEnd icGet icPut
	icLd icSt icJmp icJt icJf icLit icCall icR2
	icInc icDec icSys icCase icFun icCalli icBreak
enum
	14 tkIDEN tkNUMBER tkSTRING tkEOF	   // tokentype
enum
	50 tkSTAR tkSLASH tkMINUS tkPLUS tkEQ tkEQEQ
	tkAND tkBAR tkCARET tkMOD tkNOT tkNE tkLT tkLE
	tkLTLT tkGT tkGE tkGTGT tkCOLON tkLPAREN tkRPAREN
	tkLBRACKET tkRBRACKET tkBB tkBE tkTO tkIF tkELSE
	tkWHILE tkFOR tkBREAK tkARRAY tkCASE tkENUM tkSYSCALL
enum
	6 tyFUNC tyLOCAL tyGVAR tyENUM tyKEY   // symbol type

enum
	5678920 OBJ_SOMv2

//  memory model
//  M [ MAXMEM  ]		 declared in C
//
//  M[1..MAXSYS]  		 system area (in eval-s)
//
//  CS[MAXCS]    		 code segment
//       ^
//       CP
//
//  SS[MAXSS]	         stack segment  (in eval-c)
//      ^  ^			 not used, as we use SS in C
//      fp sp
//
//  ystack[MAXYSTK]		 parser stack
//           ^
//          ysp
//
//  cell[MAXCELL]		 store list (parse-tree)

//enum
//	100 MAXSYS		// size of system area
//enum
//	5000 MAXSS		// size of user stack
//enum
//	2000 MAXDS		// size of data segment

enum
	10000 MAXCS		// size of code segment
enum
	1000 MAXYSTK	// size of parser stack

to initSom =
	M = 0				// base of M, alias with C M[]
	CS = array MAXCS	// code segment
	CP = 3  			// code pointer
//	DS = array MAXDS	// data segment use eval-C
//	DP = 1				// free data pointer
//	SS = array MAXSS	// use eval-C and its SS
//	sp = 1
//	fp = 1
//	ip = 1
	ystack = array MAXYSTK  // parser stack
	ysp = 0
	currentf = 0		// current fn idx
	Lo = 0				// range of case label
	Hi = 0				//
	nenum = 0			// enum number
	userDS = 0			// beginning of user DS
	verbose = 1			// control compiler message
	noeval = 0			// control eval

// when no line number is available (gencode, eval, etc.)
to error x =
	prints "error: " prints x nl
	syscall {7}			// exit

// error during parsing
to seterror s =
	prints "line " print line space
	prints s nl
	syscall {7}

to warning nm mess =
	if verbose
		prints "Warning: "
		if nm != 0 prints nm space
		prints mess nl

// End
