/**************************************************************/ /* Tiny 1.6 */ /**************************************************************/ /* This compiler is the result of a translation and a remake from a tutorial written by J. Cranshow. This version could be considered an alpha release. I don't warrant anything. Click here to start from main. */ #define DOS 1 #if DOS #include#include #else #include #endif #ifndef TRUE #define TRUE 1 #define FALSE 0 #define X 1 /* file concesso in esecuzione */ #define W 2 /* file concesso in scrittura */ #define R 4 /* file concesso in lettura */ #define O_APPEND 8 /* scrivi a fine file */ #define O_CREAT 16 /* crea un nuovo file */ #define O_TRUNC 32 /* tronca il file a zero */ #define O_EXCL 64 /* open esclusiva */ #endif #define TAB 9 #define CR 13 #if DOS #define LF 10 #else #define LF 11 #endif #define MAXENTRY 100 #define NKW 23 #define NKW1 24 #define SYMBOLSIZE 9 #define MaxParam 10 #define OPCOM '\255' /*--------------------------------------------------------------*/ /* Type Declarations */ typedef char symbol[SYMBOLSIZE]; typedef symbol symtab[1000]; typedef symtab *tabptr; typedef char boolean; struct TinyIMP { int lcount; /* Label Counter */ int nentry; char look; /* Lookahead Character */ char tempchar; /* Temporary Character */ char token; /* Encoded Token */ char value[17]; /* Unencoded Token */ char MessageString[50]; /* buffer lungo */ char bufchar[2]; /* buffer corto */ symbol st[MAXENTRY]; /* Symbol Table */ char stype[MAXENTRY+1]; /* Symbols Type */ symbol kwlist[NKW]; /* Keywords List */ char kwcode[NKW1+1]; /* Keywords Shortcut */ symbol params[MaxParam]; /* Parameter Table */ char paramtyp[MaxParam]; /* Parameters Type */ int parampos[MaxParam]; /* Parameters Offset */ int numparams,base,lastparam; /* Counters */ boolean mul32set, div32set; #if DOS FILE *fdin, *fdout; /* descrittori file i/o */ #else int fdin, fdout; /* descrittori file i/o */ #endif }; typedef struct TinyIMP TIMP; /*--------------------------------------------------------------*/ /* Main Program */ #if DOS void main(argc,argv) #else void tiny (argc,argv) #endif int argc; char **argv; { TIMP e; init(&e,argc,argv); header(&e); topdecls(&e); if typeof(&e, "MAIN") != 'p') expected(&e, "main"); epilog(&e); } /* --------------------------------------------------------------- */ /* input output error */ /* --------------------------------------------------------------- */ int topencl(a,b) char *a; int b; { #if !DOS @ trap #2 #endif } int topen(path,flag,mode) char *path; int flag,mode; { return topencl(path,flag+(mode%256)*256); } int treadcl(a,b) int a; char *b; { #if !DOS @ trap #0 #endif } int tread(fd,buf,nbyte) int fd; char *buf; int nbyte; { return treadcl(fd+nbyte*256,buf); } int twritecl(a,b) int a; char *b; { #if !DOS @ trap #1 #endif } int twrite(fd,buf,nbyte) #if DOS FILE *fd; #else int fd; #endif char *buf; int nbyte; { #if DOS for (nbyte=0; buf[nbyte]; nbyte++) if (buf[nbyte]==11) buf[nbyte] = 0; if (fd != NULL) fprintf(fd, "", buf); else printf("",buf); return 1; #else return twritecl(fd+nbyte*256,buf); #endif } /*--------------------------------------------------------------*/ /* Read New Character From Input Stream */ char readch(e) TIMP *e; { char c; #if DOS if (e->fdin) c = getc(e->fdin); else { c = getch(); printf("