mirror of
https://github.com/ZDoom/acc.git
synced 2025-02-16 08:31:48 +00:00
- add .gitattributes
- add BT_RUN
This commit is contained in:
parent
2c3ca7f022
commit
33fdfcc46d
2 changed files with 1469 additions and 1468 deletions
636
acc.c
636
acc.c
|
@ -1,318 +1,318 @@
|
||||||
|
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
//**
|
//**
|
||||||
//** acc.c
|
//** acc.c
|
||||||
//**
|
//**
|
||||||
//**************************************************************************
|
//**************************************************************************
|
||||||
|
|
||||||
// HEADER FILES ------------------------------------------------------------
|
// HEADER FILES ------------------------------------------------------------
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "token.h"
|
#include "token.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "pcode.h"
|
#include "pcode.h"
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
|
|
||||||
// MACROS ------------------------------------------------------------------
|
// MACROS ------------------------------------------------------------------
|
||||||
|
|
||||||
#define VERSION_TEXT "1.58"
|
#define VERSION_TEXT "1.58"
|
||||||
#define COPYRIGHT_YEARS_TEXT "1995"
|
#define COPYRIGHT_YEARS_TEXT "1995"
|
||||||
|
|
||||||
// TYPES -------------------------------------------------------------------
|
// TYPES -------------------------------------------------------------------
|
||||||
|
|
||||||
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
||||||
|
|
||||||
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
||||||
|
|
||||||
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
|
||||||
|
|
||||||
static void Init(void);
|
static void Init(void);
|
||||||
static void DisplayBanner(void);
|
static void DisplayBanner(void);
|
||||||
static void DisplayUsage(void);
|
static void DisplayUsage(void);
|
||||||
static void OpenDebugFile(char *name);
|
static void OpenDebugFile(char *name);
|
||||||
static void ProcessArgs(void);
|
static void ProcessArgs(void);
|
||||||
|
|
||||||
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
// EXTERNAL DATA DECLARATIONS ----------------------------------------------
|
||||||
|
|
||||||
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
// PUBLIC DATA DEFINITIONS -------------------------------------------------
|
||||||
|
|
||||||
boolean acs_BigEndianHost;
|
boolean acs_BigEndianHost;
|
||||||
boolean acs_VerboseMode;
|
boolean acs_VerboseMode;
|
||||||
boolean acs_DebugMode;
|
boolean acs_DebugMode;
|
||||||
FILE *acs_DebugFile;
|
FILE *acs_DebugFile;
|
||||||
char acs_SourceFileName[MAX_FILE_NAME_LENGTH];
|
char acs_SourceFileName[MAX_FILE_NAME_LENGTH];
|
||||||
|
|
||||||
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
// PRIVATE DATA DEFINITIONS ------------------------------------------------
|
||||||
|
|
||||||
static int ArgCount;
|
static int ArgCount;
|
||||||
static char **ArgVector;
|
static char **ArgVector;
|
||||||
static char ObjectFileName[MAX_FILE_NAME_LENGTH];
|
static char ObjectFileName[MAX_FILE_NAME_LENGTH];
|
||||||
|
|
||||||
// CODE --------------------------------------------------------------------
|
// CODE --------------------------------------------------------------------
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// main
|
// main
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
ArgCount = argc;
|
ArgCount = argc;
|
||||||
ArgVector = argv;
|
ArgVector = argv;
|
||||||
DisplayBanner();
|
DisplayBanner();
|
||||||
Init();
|
Init();
|
||||||
TK_OpenSource(acs_SourceFileName);
|
TK_OpenSource(acs_SourceFileName);
|
||||||
PC_OpenObject(ObjectFileName, DEFAULT_OBJECT_SIZE, 0);
|
PC_OpenObject(ObjectFileName, DEFAULT_OBJECT_SIZE, 0);
|
||||||
PA_Parse();
|
PA_Parse();
|
||||||
PC_CloseObject();
|
PC_CloseObject();
|
||||||
TK_CloseSource();
|
TK_CloseSource();
|
||||||
|
|
||||||
MS_Message(MSG_NORMAL, "\n\"%s\":\n %d line%s (%d included)\n",
|
MS_Message(MSG_NORMAL, "\n\"%s\":\n %d line%s (%d included)\n",
|
||||||
acs_SourceFileName, tk_Line, tk_Line == 1 ? "" : "s",
|
acs_SourceFileName, tk_Line, tk_Line == 1 ? "" : "s",
|
||||||
tk_IncludedLines);
|
tk_IncludedLines);
|
||||||
MS_Message(MSG_NORMAL, " %d function%s\n %d script%s\n",
|
MS_Message(MSG_NORMAL, " %d function%s\n %d script%s\n",
|
||||||
pc_FunctionCount, pc_FunctionCount == 1 ? "" : "s",
|
pc_FunctionCount, pc_FunctionCount == 1 ? "" : "s",
|
||||||
pa_ScriptCount, pa_ScriptCount == 1 ? "" : "s");
|
pa_ScriptCount, pa_ScriptCount == 1 ? "" : "s");
|
||||||
for (i = 0; pa_TypedScriptCounts[i].TypeName; i++)
|
for (i = 0; pa_TypedScriptCounts[i].TypeName; i++)
|
||||||
{
|
{
|
||||||
if (pa_TypedScriptCounts[i].TypeCount > 0)
|
if (pa_TypedScriptCounts[i].TypeCount > 0)
|
||||||
{
|
{
|
||||||
MS_Message(MSG_NORMAL, "%5d %s\n",
|
MS_Message(MSG_NORMAL, "%5d %s\n",
|
||||||
pa_TypedScriptCounts[i].TypeCount,
|
pa_TypedScriptCounts[i].TypeCount,
|
||||||
pa_TypedScriptCounts[i].TypeName);
|
pa_TypedScriptCounts[i].TypeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MS_Message(MSG_NORMAL, " %d global variable%s\n"
|
MS_Message(MSG_NORMAL, " %d global variable%s\n"
|
||||||
" %d world variable%s\n"
|
" %d world variable%s\n"
|
||||||
" %d map variable%s\n"
|
" %d map variable%s\n"
|
||||||
" %d global array%s\n"
|
" %d global array%s\n"
|
||||||
" %d world array%s\n",
|
" %d world array%s\n",
|
||||||
pa_GlobalVarCount, pa_GlobalVarCount == 1 ? "" : "s",
|
pa_GlobalVarCount, pa_GlobalVarCount == 1 ? "" : "s",
|
||||||
pa_WorldVarCount, pa_WorldVarCount == 1 ? "" : "s",
|
pa_WorldVarCount, pa_WorldVarCount == 1 ? "" : "s",
|
||||||
pa_MapVarCount, pa_MapVarCount == 1 ? "" : "s",
|
pa_MapVarCount, pa_MapVarCount == 1 ? "" : "s",
|
||||||
pa_GlobalArrayCount, pa_GlobalArrayCount == 1 ? "" : "s",
|
pa_GlobalArrayCount, pa_GlobalArrayCount == 1 ? "" : "s",
|
||||||
pa_WorldArrayCount, pa_WorldArrayCount == 1 ? "" : "s"
|
pa_WorldArrayCount, pa_WorldArrayCount == 1 ? "" : "s"
|
||||||
);
|
);
|
||||||
MS_Message(MSG_NORMAL, " object \"%s\": %d bytes\n",
|
MS_Message(MSG_NORMAL, " object \"%s\": %d bytes\n",
|
||||||
ObjectFileName, pc_Address);
|
ObjectFileName, pc_Address);
|
||||||
ERR_RemoveErrorFile();
|
ERR_RemoveErrorFile();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// DisplayBanner
|
// DisplayBanner
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void DisplayBanner(void)
|
static void DisplayBanner(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\nOriginal ACC Version 1.10 by Ben Gokey\n");
|
fprintf(stderr, "\nOriginal ACC Version 1.10 by Ben Gokey\n");
|
||||||
fprintf(stderr, "Copyright (c) "COPYRIGHT_YEARS_TEXT
|
fprintf(stderr, "Copyright (c) "COPYRIGHT_YEARS_TEXT
|
||||||
" Raven Software, Corp.\n\n");
|
" Raven Software, Corp.\n\n");
|
||||||
fprintf(stderr, "This is version "VERSION_TEXT" ("__DATE__")\n");
|
fprintf(stderr, "This is version "VERSION_TEXT" ("__DATE__")\n");
|
||||||
fprintf(stderr, "This software is not supported by Raven Software or Activision\n");
|
fprintf(stderr, "This software is not supported by Raven Software or Activision\n");
|
||||||
fprintf(stderr, "ZDoom changes and language extensions by Randy Heit\n");
|
fprintf(stderr, "ZDoom changes and language extensions by Randy Heit\n");
|
||||||
fprintf(stderr, "Further changes by Brad Carney\n");
|
fprintf(stderr, "Further changes by Brad Carney\n");
|
||||||
fprintf(stderr, "Even more changes by James Bentler\n");
|
fprintf(stderr, "Even more changes by James Bentler\n");
|
||||||
fprintf(stderr, "Some additions by Michael \"Necromage\" Weber\n");
|
fprintf(stderr, "Some additions by Michael \"Necromage\" Weber\n");
|
||||||
fprintf(stderr, "Error reporting improvements and limit expansion by Ty Halderman\n");
|
fprintf(stderr, "Error reporting improvements and limit expansion by Ty Halderman\n");
|
||||||
fprintf(stderr, "Include paths added by Pascal vd Heiden\n");
|
fprintf(stderr, "Include paths added by Pascal vd Heiden\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Init
|
// Init
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void Init(void)
|
static void Init(void)
|
||||||
{
|
{
|
||||||
short endianTest = 1;
|
short endianTest = 1;
|
||||||
|
|
||||||
if (*(char *)&endianTest)
|
if (*(char *)&endianTest)
|
||||||
acs_BigEndianHost = NO;
|
acs_BigEndianHost = NO;
|
||||||
else
|
else
|
||||||
acs_BigEndianHost = YES;
|
acs_BigEndianHost = YES;
|
||||||
acs_VerboseMode = YES;
|
acs_VerboseMode = YES;
|
||||||
acs_DebugMode = NO;
|
acs_DebugMode = NO;
|
||||||
acs_DebugFile = NULL;
|
acs_DebugFile = NULL;
|
||||||
TK_Init();
|
TK_Init();
|
||||||
SY_Init();
|
SY_Init();
|
||||||
STR_Init();
|
STR_Init();
|
||||||
ProcessArgs();
|
ProcessArgs();
|
||||||
MS_Message(MSG_NORMAL, "Host byte order: %s endian\n",
|
MS_Message(MSG_NORMAL, "Host byte order: %s endian\n",
|
||||||
acs_BigEndianHost ? "BIG" : "LITTLE");
|
acs_BigEndianHost ? "BIG" : "LITTLE");
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// ProcessArgs
|
// ProcessArgs
|
||||||
//
|
//
|
||||||
// Pascal 12/11/08
|
// Pascal 12/11/08
|
||||||
// Allowing space after options (option parameter as the next argument)
|
// Allowing space after options (option parameter as the next argument)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void ProcessArgs(void)
|
static void ProcessArgs(void)
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char *text;
|
char *text;
|
||||||
char option;
|
char option;
|
||||||
|
|
||||||
while(i < ArgCount)
|
while(i < ArgCount)
|
||||||
{
|
{
|
||||||
text = ArgVector[i];
|
text = ArgVector[i];
|
||||||
|
|
||||||
if(*text == '-')
|
if(*text == '-')
|
||||||
{
|
{
|
||||||
// Option
|
// Option
|
||||||
text++;
|
text++;
|
||||||
if(*text == 0)
|
if(*text == 0)
|
||||||
{
|
{
|
||||||
DisplayUsage();
|
DisplayUsage();
|
||||||
}
|
}
|
||||||
option = toupper(*text++);
|
option = toupper(*text++);
|
||||||
switch(option)
|
switch(option)
|
||||||
{
|
{
|
||||||
case 'I':
|
case 'I':
|
||||||
if((i + 1) < ArgCount)
|
if((i + 1) < ArgCount)
|
||||||
{
|
{
|
||||||
TK_AddIncludePath(ArgVector[++i]);
|
TK_AddIncludePath(ArgVector[++i]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
acs_DebugMode = YES;
|
acs_DebugMode = YES;
|
||||||
acs_VerboseMode = YES;
|
acs_VerboseMode = YES;
|
||||||
if(*text != 0)
|
if(*text != 0)
|
||||||
{
|
{
|
||||||
OpenDebugFile(text);
|
OpenDebugFile(text);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'H':
|
case 'H':
|
||||||
pc_NoShrink = TRUE;
|
pc_NoShrink = TRUE;
|
||||||
pc_HexenCase = TRUE;
|
pc_HexenCase = TRUE;
|
||||||
pc_EnforceHexen = toupper(*text) != 'H';
|
pc_EnforceHexen = toupper(*text) != 'H';
|
||||||
pc_WarnNotHexen = toupper(*text) == 'H';
|
pc_WarnNotHexen = toupper(*text) == 'H';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DisplayUsage();
|
DisplayUsage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Input/output file
|
// Input/output file
|
||||||
count++;
|
count++;
|
||||||
switch(count)
|
switch(count)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
strcpy(acs_SourceFileName, text);
|
strcpy(acs_SourceFileName, text);
|
||||||
MS_SuggestFileExt(acs_SourceFileName, ".acs");
|
MS_SuggestFileExt(acs_SourceFileName, ".acs");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
strcpy(ObjectFileName, text);
|
strcpy(ObjectFileName, text);
|
||||||
MS_SuggestFileExt(ObjectFileName, ".o");
|
MS_SuggestFileExt(ObjectFileName, ".o");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DisplayUsage();
|
DisplayUsage();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next arg
|
// Next arg
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count == 0)
|
if(count == 0)
|
||||||
{
|
{
|
||||||
DisplayUsage();
|
DisplayUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
TK_AddIncludePath(".");
|
TK_AddIncludePath(".");
|
||||||
#ifdef unix
|
#ifdef unix
|
||||||
TK_AddIncludePath("/usr/local/share/acc/");
|
TK_AddIncludePath("/usr/local/share/acc/");
|
||||||
#endif
|
#endif
|
||||||
TK_AddProgramIncludePath(ArgVector[0]);
|
TK_AddProgramIncludePath(ArgVector[0]);
|
||||||
|
|
||||||
if(count == 1)
|
if(count == 1)
|
||||||
{
|
{
|
||||||
strcpy(ObjectFileName, acs_SourceFileName);
|
strcpy(ObjectFileName, acs_SourceFileName);
|
||||||
MS_StripFileExt(ObjectFileName);
|
MS_StripFileExt(ObjectFileName);
|
||||||
MS_SuggestFileExt(ObjectFileName, ".o");
|
MS_SuggestFileExt(ObjectFileName, ".o");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// DisplayUsage
|
// DisplayUsage
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void DisplayUsage(void)
|
static void DisplayUsage(void)
|
||||||
{
|
{
|
||||||
puts("\nUsage: ACC [options] source[.acs] [object[.o]]\n");
|
puts("\nUsage: ACC [options] source[.acs] [object[.o]]\n");
|
||||||
puts("-i [path] Add include path to find include files");
|
puts("-i [path] Add include path to find include files");
|
||||||
puts("-d[file] Output debugging information");
|
puts("-d[file] Output debugging information");
|
||||||
puts("-h Create pcode compatible with Hexen and old ZDooms");
|
puts("-h Create pcode compatible with Hexen and old ZDooms");
|
||||||
puts("-hh Like -h, but use of new features is only a warning");
|
puts("-hh Like -h, but use of new features is only a warning");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// OpenDebugFile
|
// OpenDebugFile
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
static void OpenDebugFile(char *name)
|
static void OpenDebugFile(char *name)
|
||||||
{
|
{
|
||||||
if((acs_DebugFile = fopen(name, "w")) == NULL)
|
if((acs_DebugFile = fopen(name, "w")) == NULL)
|
||||||
{
|
{
|
||||||
ERR_Exit(ERR_CANT_OPEN_DBGFILE, NO, "File: \"%s\".", name);
|
ERR_Exit(ERR_CANT_OPEN_DBGFILE, NO, "File: \"%s\".", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// OptionExists
|
// OptionExists
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static boolean OptionExists(char *name)
|
static boolean OptionExists(char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *arg;
|
char *arg;
|
||||||
|
|
||||||
for(i = 1; i < ArgCount; i++)
|
for(i = 1; i < ArgCount; i++)
|
||||||
{
|
{
|
||||||
arg = ArgVector[i];
|
arg = ArgVector[i];
|
||||||
if(*arg == '-')
|
if(*arg == '-')
|
||||||
{
|
{
|
||||||
arg++;
|
arg++;
|
||||||
if(MS_StrCmp(name, arg) == 0)
|
if(MS_StrCmp(name, arg) == 0)
|
||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue