SBSPSS/Utils/Scripter/main.cpp

107 lines
1.8 KiB
C++
Raw Normal View History

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-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();
printf("Generated %d bytes of code\n",byteCount*2);
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
}
return ret;
}
2000-12-11 21:28:41 +01:00
2000-12-08 22:18:35 +01:00
/*===========================================================================
end */