- Added NecroMage's submission for bitwise/shift assignment operators for ACS.

SVN r261 (trunk)
This commit is contained in:
Christoph Oelckers 2006-07-16 20:13:24 +00:00
parent 4c94a58e95
commit a4879364bb
6 changed files with 134 additions and 7 deletions

3
acc.c
View file

@ -22,7 +22,7 @@
// MACROS ------------------------------------------------------------------
#define VERSION_TEXT "1.40"
#define VERSION_TEXT "1.42"
#define COPYRIGHT_YEARS_TEXT "1995"
// TYPES -------------------------------------------------------------------
@ -125,6 +125,7 @@ static void DisplayBanner(void)
fprintf(stderr, "ZDoom changes and language extensions by Randy Heit\n");
fprintf(stderr, "Further changes by Brad Carney\n");
fprintf(stderr, "Even more changes by James Bentler\n");
fprintf(stderr, "Some additions by Michael \"Necromage\" Weber\n");
fprintf(stderr, "Error reporting improvements and limit expansion by Ty Halderman\n");
}

18
parse.c
View file

@ -310,6 +310,11 @@ static tokenType_t AssignOps[] =
TK_MULASSIGN,
TK_DIVASSIGN,
TK_MODASSIGN,
TK_ANDASSIGN,
TK_EORASSIGN,
TK_ORASSIGN,
TK_LSASSIGN,
TK_RSASSIGN,
TK_NONE
};
@ -2906,21 +2911,28 @@ static pcd_t GetAssignPCD(tokenType_t token, symbolType_t symbol)
static tokenType_t tokenLookup[] =
{
TK_ASSIGN, TK_ADDASSIGN, TK_SUBASSIGN,
TK_MULASSIGN, TK_DIVASSIGN, TK_MODASSIGN
TK_MULASSIGN, TK_DIVASSIGN, TK_MODASSIGN,
TK_ANDASSIGN, TK_EORASSIGN, TK_ORASSIGN,
TK_LSASSIGN, TK_RSASSIGN
};
static symbolType_t symbolLookup[] =
{
SY_SCRIPTVAR, SY_MAPVAR, SY_WORLDVAR, SY_GLOBALVAR, SY_MAPARRAY,
SY_WORLDARRAY, SY_GLOBALARRAY
};
static pcd_t assignmentLookup[6][7] =
static pcd_t assignmentLookup[11][7] =
{
{ PCD_ASSIGNSCRIPTVAR, PCD_ASSIGNMAPVAR, PCD_ASSIGNWORLDVAR, PCD_ASSIGNGLOBALVAR, PCD_ASSIGNMAPARRAY, PCD_ASSIGNWORLDARRAY, PCD_ASSIGNGLOBALARRAY },
{ PCD_ADDSCRIPTVAR, PCD_ADDMAPVAR, PCD_ADDWORLDVAR, PCD_ADDGLOBALVAR, PCD_ADDMAPARRAY, PCD_ADDWORLDARRAY, PCD_ADDGLOBALARRAY },
{ PCD_SUBSCRIPTVAR, PCD_SUBMAPVAR, PCD_SUBWORLDVAR, PCD_SUBGLOBALVAR, PCD_SUBMAPARRAY, PCD_SUBWORLDARRAY, PCD_SUBGLOBALARRAY },
{ PCD_MULSCRIPTVAR, PCD_MULMAPVAR, PCD_MULWORLDVAR, PCD_MULGLOBALVAR, PCD_MULMAPARRAY, PCD_MULWORLDARRAY, PCD_MULGLOBALARRAY },
{ PCD_DIVSCRIPTVAR, PCD_DIVMAPVAR, PCD_DIVWORLDVAR, PCD_DIVGLOBALVAR, PCD_DIVMAPARRAY, PCD_DIVWORLDARRAY, PCD_DIVGLOBALARRAY },
{ PCD_MODSCRIPTVAR, PCD_MODMAPVAR, PCD_MODWORLDVAR, PCD_MODGLOBALVAR, PCD_MODMAPARRAY, PCD_MODWORLDARRAY, PCD_MODGLOBALARRAY }
{ PCD_MODSCRIPTVAR, PCD_MODMAPVAR, PCD_MODWORLDVAR, PCD_MODGLOBALVAR, PCD_MODMAPARRAY, PCD_MODWORLDARRAY, PCD_MODGLOBALARRAY },
{ PCD_ANDSCRIPTVAR, PCD_ANDMAPVAR, PCD_ANDWORLDVAR, PCD_ANDGLOBALVAR, PCD_ANDMAPARRAY, PCD_ANDWORLDARRAY, PCD_ANDGLOBALARRAY },
{ PCD_EORSCRIPTVAR, PCD_EORMAPVAR, PCD_EORWORLDVAR, PCD_EORGLOBALVAR, PCD_EORMAPARRAY, PCD_EORWORLDARRAY, PCD_EORGLOBALARRAY },
{ PCD_ORSCRIPTVAR, PCD_ORMAPVAR, PCD_ORWORLDVAR, PCD_ORGLOBALVAR, PCD_ORMAPARRAY, PCD_ORWORLDARRAY, PCD_ORGLOBALARRAY },
{ PCD_LSSCRIPTVAR, PCD_LSMAPVAR, PCD_LSWORLDVAR, PCD_LSGLOBALVAR, PCD_LSMAPARRAY, PCD_LSWORLDARRAY, PCD_LSGLOBALARRAY },
{ PCD_RSSCRIPTVAR, PCD_RSMAPVAR, PCD_RSWORLDVAR, PCD_RSGLOBALVAR, PCD_RSMAPARRAY, PCD_RSWORLDARRAY, PCD_RSGLOBALARRAY }
};
for(i = 0; i < ARRAY_SIZE(tokenLookup); ++i)

37
pcode.c
View file

@ -399,6 +399,43 @@ static char *PCDNames[PCODE_COMMAND_COUNT] =
"PCD_THINGCOUNTNAME",
"PCD_SPAWNSPOTFACING",
"PCD_PLAYERCLASS",
//[MW] start my p-codes
"PCD_ANDSCRIPTVAR",
"PCD_ANDMAPVAR",
"PCD_ANDWORLDVAR",
"PCD_ANDGLOBALVAR",
"PCD_ANDMAPARRAY",
"PCD_ANDWORLDARRAY",
"PCD_ANDGLOBALARRAY",
"PCD_EORSCRIPTVAR",
"PCD_EORMAPVAR",
"PCD_EORWORLDVAR",
"PCD_EORGLOBALVAR",
"PCD_EORMAPARRAY",
"PCD_EORWORLDARRAY",
"PCD_EORGLOBALARRAY",
"PCD_ORSCRIPTVAR",
"PCD_ORMAPVAR",
"PCD_ORWORLDVAR",
"PCD_ORGLOBALVAR",
"PCD_ORMAPARRAY",
"PCD_ORWORLDARRAY",
"PCD_ORGLOBALARRAY",
"PCD_LSSCRIPTVAR",
"PCD_LSMAPVAR",
"PCD_LSWORLDVAR",
"PCD_LSGLOBALVAR",
"PCD_LSMAPARRAY",
"PCD_LSWORLDARRAY",
"PCD_LSGLOBALARRAY",
"PCD_RSSCRIPTVAR",
"PCD_RSMAPVAR",
"PCD_RSWORLDVAR",
"PCD_RSGLOBALVAR",
"PCD_RSMAPARRAY",
"PCD_RSWORLDARRAY",
"PCD_RSGLOBALARRAY",
//[MW] end my p-codes
};

37
pcode.h
View file

@ -349,6 +349,43 @@ typedef enum
PCD_THINGCOUNTNAME,
PCD_SPAWNSPOTFACING,
PCD_PLAYERCLASS,
//[MW] start my p-codes
PCD_ANDSCRIPTVAR,
PCD_ANDMAPVAR,
PCD_ANDWORLDVAR,
PCD_ANDGLOBALVAR,
PCD_ANDMAPARRAY,
PCD_ANDWORLDARRAY,
PCD_ANDGLOBALARRAY,
PCD_EORSCRIPTVAR,
PCD_EORMAPVAR,
PCD_EORWORLDVAR,
PCD_EORGLOBALVAR,
PCD_EORMAPARRAY,
PCD_EORWORLDARRAY,
PCD_EORGLOBALARRAY,
PCD_ORSCRIPTVAR,
PCD_ORMAPVAR,
PCD_ORWORLDVAR,
PCD_ORGLOBALVAR,
PCD_ORMAPARRAY,
PCD_ORWORLDARRAY,
PCD_ORGLOBALARRAY,
PCD_LSSCRIPTVAR,
PCD_LSMAPVAR,
PCD_LSWORLDVAR,
PCD_LSGLOBALVAR,
PCD_LSMAPARRAY,
PCD_LSWORLDARRAY,
PCD_LSGLOBALARRAY,
PCD_RSSCRIPTVAR,
PCD_RSMAPVAR,
PCD_RSWORLDVAR,
PCD_RSGLOBALVAR,
PCD_RSMAPARRAY,
PCD_RSWORLDARRAY,
PCD_RSGLOBALARRAY,
//[MW] end my p-codes
PCODE_COMMAND_COUNT
} pcd_t;

41
token.c
View file

@ -1056,8 +1056,17 @@ static void ProcessSpecialToken(void)
}
else if(Chr == '<')
{
tk_Token = TK_LSHIFT;
NextChr();
if(Chr == '=')
{
tk_Token = TK_LSASSIGN;
NextChr();
}
else
{
tk_Token = TK_LSHIFT;
}
}
else
{
@ -1072,8 +1081,16 @@ static void ProcessSpecialToken(void)
}
else if(Chr == '>')
{
tk_Token = TK_RSHIFT;
NextChr();
if(Chr == '=')
{
tk_Token = TK_RSASSIGN;
NextChr();
}
else
{
tk_Token = TK_RSHIFT;
}
}
else
{
@ -1097,6 +1114,11 @@ static void ProcessSpecialToken(void)
tk_Token = TK_ANDLOGICAL;
NextChr();
}
else if(Chr == '=')
{
tk_Token = TK_ANDASSIGN;
NextChr();
}
else
{
tk_Token = TK_ANDBITWISE;
@ -1108,6 +1130,11 @@ static void ProcessSpecialToken(void)
tk_Token = TK_ORLOGICAL;
NextChr();
}
else if(Chr == '=')
{
tk_Token = TK_ORASSIGN;
NextChr();
}
else
{
tk_Token = TK_ORBITWISE;
@ -1147,7 +1174,15 @@ static void ProcessSpecialToken(void)
tk_Token = TK_NUMBERSIGN;
break;
case '^':
tk_Token = TK_EORBITWISE;
if(Chr == '=')
{
tk_Token = TK_EORASSIGN;
NextChr();
}
else
{
tk_Token = TK_EORBITWISE;
}
break;
case '~':
tk_Token = TK_TILDE;

View file

@ -122,6 +122,11 @@ typedef enum
TK_DISCONNECT, // 'disconnect'
TK_UNLOADING, // 'unloading'
TK_STATIC, // 'static'
TK_ANDASSIGN, // '&='
TK_ORASSIGN, // '|='
TK_EORASSIGN, // '^='
TK_LSASSIGN, // '<<='
TK_RSASSIGN, // '>>='
} tokenType_t;
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------