2000-12-08 22:18:35 +01:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
main.cpp
|
|
|
|
|
|
|
|
Author: PKG
|
|
|
|
Created:
|
|
|
|
Project: Spongebob
|
|
|
|
Purpose:
|
|
|
|
|
|
|
|
Copyright (c) 2000 Climax Development Ltd
|
|
|
|
|
|
|
|
===========================================================================*/
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Includes
|
|
|
|
-------- */
|
|
|
|
|
|
|
|
#include "main.h"
|
2000-12-12 17:29:42 +01:00
|
|
|
|
|
|
|
#ifndef _LEXER_H
|
2000-12-11 21:28:41 +01:00
|
|
|
#include "lexer.h"
|
2000-12-12 17:29:42 +01:00
|
|
|
#endif
|
2000-12-11 21:28:41 +01:00
|
|
|
|
|
|
|
#ifndef __CODEGEN_H__
|
|
|
|
#include "codegen.h"
|
|
|
|
#endif
|
2000-12-08 22:18:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
/* Std Lib
|
|
|
|
------- */
|
|
|
|
|
2000-12-11 21:28:41 +01:00
|
|
|
#include <yacc.h>
|
|
|
|
|
|
|
|
|
2000-12-08 22:18:35 +01:00
|
|
|
/* Data
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Tyepdefs && Defines
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Structure defintions
|
|
|
|
-------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function Prototypes
|
|
|
|
------------------- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Vars
|
|
|
|
---- */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------
|
|
|
|
Function:
|
|
|
|
Purpose:
|
|
|
|
Params:
|
|
|
|
Returns:
|
|
|
|
---------------------------------------------------------------------- */
|
|
|
|
extern int main(int argc, char *argv[])
|
|
|
|
{
|
2000-12-11 21:28:41 +01:00
|
|
|
int ret;
|
2000-12-08 22:18:35 +01:00
|
|
|
|
|
|
|
if(argc!=3)
|
|
|
|
{
|
|
|
|
printf("Script compiler thingy\n");
|
|
|
|
printf("Usage: yl infile outfile\n");
|
|
|
|
printf("So there..\n\n");
|
2000-12-11 21:28:41 +01:00
|
|
|
ret=-1;
|
2000-12-08 22:18:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-12-11 21:28:41 +01:00
|
|
|
char *infile;
|
|
|
|
char *outfile;
|
|
|
|
|
|
|
|
infile=argv[1];
|
|
|
|
outfile=argv[2];
|
2000-12-08 22:18:35 +01:00
|
|
|
|
2000-12-18 17:58:33 +01:00
|
|
|
printf("Scripter attempting to compile %s..\n",infile);
|
2000-12-11 21:28:41 +01:00
|
|
|
if(parseFile(infile,s_baseTreeNode)==YYEXIT_SUCCESS&&s_baseTreeNode)
|
2000-12-08 22:18:35 +01:00
|
|
|
{
|
2000-12-11 21:28:41 +01:00
|
|
|
if(openOutputFile(outfile))
|
2000-12-08 22:18:35 +01:00
|
|
|
{
|
2000-12-11 21:28:41 +01:00
|
|
|
int byteCount;
|
|
|
|
byteCount=s_baseTreeNode->generateCode(true);
|
|
|
|
closeOutputFile();
|
2000-12-18 17:58:33 +01:00
|
|
|
printf("Generated %d bytes of code in %s\n",byteCount*2,outfile);
|
2000-12-11 21:28:41 +01:00
|
|
|
ret=0;
|
2000-12-08 22:18:35 +01:00
|
|
|
}
|
2000-12-11 21:28:41 +01:00
|
|
|
else
|
2000-12-08 22:18:35 +01:00
|
|
|
{
|
2000-12-11 21:28:41 +01:00
|
|
|
ret=-1;
|
2000-12-08 22:18:35 +01:00
|
|
|
}
|
|
|
|
}
|
2000-12-11 21:28:41 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ret=-1;
|
|
|
|
}
|
2000-12-08 22:18:35 +01:00
|
|
|
}
|
|
|
|
|
2001-01-05 20:25:07 +01:00
|
|
|
printf("\n");
|
2000-12-08 22:18:35 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-12-11 21:28:41 +01:00
|
|
|
|
2000-12-08 22:18:35 +01:00
|
|
|
/*===========================================================================
|
|
|
|
end */
|