Category : Recently Uploaded Files
Archive   : OXCC1432.ZIP
Filename : TOXCC.C

 
Output of file : TOXCC.C contained in archive : OXCC1432.ZIP
/* TOXCC.C -- test program for running oxcc while being compiled */
/*
try: oxcc -r toxcc.c -TRACE=1 >trace
and
oxcc -Gb toxcc.c
bterp toxcc -TRACE=1 >trace
*/

#include
#include
#include "oxcc.h"

typedef void *object;

extern object Compiler;
extern object String;
extern object File;
extern object stdoutStream;

extern int gSeek();
extern int gPosition();
extern int gGets();
extern void *gNew();
extern void gDispose();
extern int gPrintf();
extern int gPuts();

extern void *oxlink_find_bare_symb();
extern void *oxlink_load_bare_symb();

static char *testcode =

"static inline int addfunc(int a, int b)"
"{"
"int q;"
"return a + b;"
"}"
"int func(void)"
"{"
"int x;"
"x = addfunc(1,2);"
"return x;"
"}";


int toxcc(int argc, char **argv)
{
void *instance;
void *is; /* input stream */
void *os; /* output stream */
void *es; /* error stream */
char buf[200];
int err;

printf("toxcc running\n");

/* Dynamic link `oxcc' if it is not already there */
if(!oxlink_find_bare_symb("_oxcc"))
if(!oxlink_load_bare_symb("_oxcc", 1))
{printf("oxcc load failed\n"); return 1;}

/* METHOD 1 -- GET AN INSTANCE OF OXCC USING C CALLS */
printf("Method 1\n");

/*
NOTE: The global calls to `oxcc_' below may have been unresolved until
the dynamic linker loaded it above.
*/
instance = oxcc_open_instance();

is = fopen(testcode, "x"); /* open string as a stream (readonly) */
os = fopen("", "w+UTM"); /* create a Unique Temp file in Memory */
es = fopen("", "w+UTM"); /* create a Unique Temp file in Memory */

/* check the input file */
if(!(err = oxcc_preproc_file(instance, is, os, es, 0, 0)))
{
rewind(os);
if((err = oxcc_parse_file(instance, os, es, "testcode")))
{
oxcc_print_parse_errors(instance, es);
}
else
{
err = oxcc_check_ast_tree(instance, es, "testcode");
}
}
oxcc_cleanup_parse(instance);

/* dump accumulated errors and warnings */
if(ftell(es) > 0)
{
rewind(es);
while(fgets(buf, 199, es))
fputs(buf, stdout);
}
fclose(is);
fclose(os);
fclose(es);
/* could loop here on a new file */

oxcc_close_instance(instance);


/*
NOTE: Using the class method, the `gNew' function would handle the
dynamic linking of `oxcc' if it hadn't been loaded above.
*/
/* METHOD 2 -- GET AN INSTANCE OF OXCC USING THE CLASS METHOD */
gPrintf(stdoutStream, "\nMethod 2\n");

if(!(instance = gNew(Compiler, "cc")))
{gPrintf(stdoutStream, "oxcc class failed\n"); return 1;}

is = gNew(String, testcode); /* or could use gNew(File, testcode, "x") */
os = gNew(File, "", "w+UTM");
es = gNew(File, "", "w+UTM");

/* check the input file */
if(!(err = gPreProc(instance, is, os, es, 0, 0)))
{
gSeek(os, 0);
if((err = gParse(instance, os, es, "testcode")))
{
gPerror(instance, es);
}
else
{
err = gCheckTree(instance, es, "testcode");
}
}
gCleanup(instance);

/* dump accumulated errors and warnings */
if(gPosition(es) > 0)
{
gSeek(es, 0);
while(gGets(es, buf, 199))
gPuts(stdoutStream, buf);
}
gDispose(is);
gDispose(os);
gDispose(es);
/* could loop here on a new file */

gDispose(instance);

return 0;
}


  3 Responses to “Category : Recently Uploaded Files
Archive   : OXCC1432.ZIP
Filename : TOXCC.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/