HyperDbg Debugger
Loading...
Searching...
No Matches
common.h File Reference

Go to the source code of this file.

Classes

struct  _TOKEN
 read tokens from input stored in this structure More...
 
struct  _TOKEN_LIST
 this structure is a dynamic container of TOKENS More...
 

Macros

#define COMMON_H
 
#define SYMBOL_BUFFER_INIT_SIZE   64
 
#define TOKEN_VALUE_MAX_LEN   8
 maximum length of string in the token
 
#define TOKEN_LIST_INIT_SIZE   256
 init size of token list
 

Typedefs

typedef enum TOKEN_TYPE TOKEN_TYPE
 enumerates possible types for token
 
typedef struct _TOKEN TOKEN
 read tokens from input stored in this structure
 
typedef struct _TOKENPTOKEN
 
typedef struct _TOKEN_LIST TOKEN_LIST
 this structure is a dynamic container of TOKENS
 
typedef struct _TOKEN_LISTPTOKEN_LIST
 

Enumerations

enum  TOKEN_TYPE {
  LOCAL_ID , LOCAL_UNRESOLVED_ID , GLOBAL_ID , GLOBAL_UNRESOLVED_ID ,
  DECIMAL , STATE_ID , HEX , OCTAL ,
  BINARY , SPECIAL_TOKEN , KEYWORD , WHITE_SPACE ,
  COMMENT , REGISTER , PSEUDO_REGISTER , NON_TERMINAL ,
  SEMANTIC_RULE , END_OF_STACK , EPSILON , TEMP ,
  STRING , WSTRING , INPUT_VARIABLE_TYPE , HANDLED_VARIABLE_TYPE ,
  FUNCTION_TYPE , FUNCTION_PARAMETER_ID , STACK_TEMP , UNKNOWN
}
 enumerates possible types for token More...
 

Functions

PTOKEN NewUnknownToken (void)
 Allocates a new token.
 
PTOKEN NewToken (TOKEN_TYPE Type, char *Value)
 
void RemoveToken (PTOKEN *Token)
 Removes allocated memory of a token.
 
void PrintToken (PTOKEN Token)
 Prints token @detail prints value and type of token.
 
void AppendByte (PTOKEN Token, char c)
 Appends char to the token value.
 
void AppendWchar (PTOKEN Token, wchar_t c)
 Appends wchar_t to the token value.
 
PTOKEN CopyToken (PTOKEN Token)
 Copies a PTOKEN.
 
PTOKEN NewTemp (PSCRIPT_ENGINE_ERROR_TYPE, PUSER_DEFINED_FUNCTION_NODE)
 Allocates a new temporary variable and returns it.
 
PTOKEN NewStackTemp (PSCRIPT_ENGINE_ERROR_TYPE)
 Allocates a new temporary variable in stack and returns it.
 
void FreeTemp (PTOKEN Temp)
 Frees the memory allocated by Temp.
 
void CleanTempList (void)
 Resets the temporary variables map.
 
void CleanStackTempList (void)
 Resets the stack temporary variables map.
 
PTOKEN_LIST NewTokenList (void)
 
void RemoveTokenList (PTOKEN_LIST TokenList)
 Removes allocated memory of a TOKEN_LIST.
 
void PrintTokenList (PTOKEN_LIST TokenList)
 Prints each Token inside a TokenList.
 
PTOKEN_LIST Push (PTOKEN_LIST TokenList, PTOKEN Token)
 Adds Token to the last empty position of TokenList.
 
PTOKEN Pop (PTOKEN_LIST TokenList)
 Removes last Token of a TokenList and returns it.
 
PTOKEN Top (PTOKEN_LIST TokenList)
 Returns last Token of a TokenList.
 
char IsNoneTerminal (PTOKEN Token)
 Checks whether this Token is noneterminal NoneTerminal token starts with capital letter.
 
char IsSemanticRule (PTOKEN Token)
 Checks whether this Token is semantic rule SemanticRule token starts with '@'.
 
char IsEqual (const PTOKEN Token1, const PTOKEN Token2)
 Checks whether the value and type of Token1 and Token2 are the same.
 
int GetNonTerminalId (PTOKEN Token)
 Gets the Non Terminal Id object.
 
int GetTerminalId (PTOKEN Token)
 Gets the Terminal Id object.
 
int LalrGetNonTerminalId (PTOKEN Token)
 Gets the Non Terminal Id object.
 
int LalrGetTerminalId (PTOKEN Token)
 Gets the Terminal Id object.
 
char IsHex (char c)
 Checks whether input char belongs to hexadecimal digit-set or not.
 
char IsDecimal (char c)
 Checks whether input char belongs to decimal digit-set or not.
 
char IsLetter (char c)
 Checks whether input char belongs to alphabet set or not.
 
char IsUnderscore (char c)
 Checks whether input char is underscore (_) or not.
 
char IsBinary (char c)
 Checks whether input char belongs to binary digit-set or not.
 
char IsOctal (char c)
 Checks whether input char belongs to octal digit-set or not.
 
void SetType (unsigned long long *Val, unsigned char Type)
 Set the Type object.
 
unsigned long long DecimalToInt (char *str)
 Converts an decimal string to a integer.
 
unsigned long long DecimalToSignedInt (char *str)
 Converts an decimal string to a signed integer.
 
unsigned long long HexToInt (char *str)
 Converts an hexadecimal string to integer.
 
unsigned long long OctalToInt (char *str)
 Converts an octal string to integer.
 
unsigned long long BinaryToInt (char *str)
 Converts a binary string to integer.
 
void RotateLeftStringOnce (char *str)
 Rotate a character array to the left by one time.
 
char IsType1Func (PTOKEN Operator)
 Checks whether this Token type is OneOpFunc1.
 
char IsType2Func (PTOKEN Operator)
 Checks whether this Token type is OneOpFunc2.
 
char IsType4Func (PTOKEN Operator)
 Checks whether this Token type is VarArgFunc1.
 
char IsType5Func (PTOKEN Operator)
 Checks whether this Token type is ZeroOpFunc1.
 
char IsType6Func (PTOKEN Operator)
 Checks whether this Token type is TwoOpFunc1.
 
char IsType7Func (PTOKEN Operator)
 Checks whether this Token type is TwoOpFunc2.
 
char IsType8Func (PTOKEN Operator)
 Checks whether this Token type is ThreeOpFunc1.
 
char IsType9Func (PTOKEN Operator)
 Checks whether this Token type is OneOpFunc3.
 
char IsType10Func (PTOKEN Operator)
 Checks whether this Token type is TwoOpFunc3.
 
char IsType11Func (PTOKEN Operator)
 Checks whether this Token type is ThreeOpFunc3.
 
char IsType12Func (PTOKEN Operator)
 Checks whether this Token type is OneOpFunc4.
 
char IsType13Func (PTOKEN Operator)
 Checks whether this Token type is TwoOpFunc4.
 
char IsType14Func (PTOKEN Operator)
 Checks whether this Token type is ThreeOpFunc2.
 
char IsType15Func (PTOKEN Operator)
 Checks whether this Token type is ThreeOpFunc4.
 
char IsTwoOperandOperator (PTOKEN Operator)
 Checks whether this Token type is OperatorsTwoOperandList.
 
char IsOneOperandOperator (PTOKEN Operator)
 Checks whether this Token type is OperatorsOneOperandList.
 
char IsVariableType (PTOKEN Operator)
 Checks whether this Token type is VariableType.
 

Detailed Description

Author
M.H. Gholamrezaei (mh@hy.nosp@m.perd.nosp@m.bg.or.nosp@m.g)

Common routines header

Version
0.1
Date
2020-10-22

Macro Definition Documentation

◆ COMMON_H

#define COMMON_H

◆ SYMBOL_BUFFER_INIT_SIZE

#define SYMBOL_BUFFER_INIT_SIZE   64

initial size of symbol buffer

◆ TOKEN_LIST_INIT_SIZE

#define TOKEN_LIST_INIT_SIZE   256

init size of token list

◆ TOKEN_VALUE_MAX_LEN

#define TOKEN_VALUE_MAX_LEN   8

maximum length of string in the token

Typedef Documentation

◆ PTOKEN

typedef struct _TOKEN * PTOKEN

◆ PTOKEN_LIST

typedef struct _TOKEN_LIST * PTOKEN_LIST

◆ TOKEN

typedef struct _TOKEN TOKEN

read tokens from input stored in this structure

◆ TOKEN_LIST

typedef struct _TOKEN_LIST TOKEN_LIST

this structure is a dynamic container of TOKENS

◆ TOKEN_TYPE

typedef enum TOKEN_TYPE TOKEN_TYPE

enumerates possible types for token

Enumeration Type Documentation

◆ TOKEN_TYPE

enum TOKEN_TYPE

enumerates possible types for token

Enumerator
LOCAL_ID 
LOCAL_UNRESOLVED_ID 
GLOBAL_ID 
GLOBAL_UNRESOLVED_ID 
DECIMAL 
STATE_ID 
HEX 
OCTAL 
BINARY 
SPECIAL_TOKEN 
KEYWORD 
WHITE_SPACE 
COMMENT 
REGISTER 
PSEUDO_REGISTER 
NON_TERMINAL 
SEMANTIC_RULE 
END_OF_STACK 
EPSILON 
TEMP 
STRING 
WSTRING 
INPUT_VARIABLE_TYPE 
HANDLED_VARIABLE_TYPE 
FUNCTION_TYPE 
FUNCTION_PARAMETER_ID 
STACK_TEMP 
UNKNOWN 
37{
42 DECIMAL,
44 HEX,
45 OCTAL,
46 BINARY,
48 KEYWORD,
50 COMMENT,
56 EPSILON,
57 TEMP,
58 STRING,
59 WSTRING,
TOKEN_TYPE
enumerates possible types for token
Definition common.h:37
@ INPUT_VARIABLE_TYPE
Definition common.h:60
@ END_OF_STACK
Definition common.h:55
@ KEYWORD
Definition common.h:48
@ EPSILON
Definition common.h:56
@ STACK_TEMP
Definition common.h:64
@ TEMP
Definition common.h:57
@ LOCAL_UNRESOLVED_ID
Definition common.h:39
@ FUNCTION_TYPE
Definition common.h:62
@ HANDLED_VARIABLE_TYPE
Definition common.h:61
@ UNKNOWN
Definition common.h:65
@ SEMANTIC_RULE
Definition common.h:54
@ WHITE_SPACE
Definition common.h:49
@ LOCAL_ID
Definition common.h:38
@ PSEUDO_REGISTER
Definition common.h:52
@ WSTRING
Definition common.h:59
@ COMMENT
Definition common.h:50
@ GLOBAL_UNRESOLVED_ID
Definition common.h:41
@ SPECIAL_TOKEN
Definition common.h:47
@ REGISTER
Definition common.h:51
@ OCTAL
Definition common.h:45
@ HEX
Definition common.h:44
@ GLOBAL_ID
Definition common.h:40
@ FUNCTION_PARAMETER_ID
Definition common.h:63
@ BINARY
Definition common.h:46
@ STRING
Definition common.h:58
@ DECIMAL
Definition common.h:42
@ NON_TERMINAL
Definition common.h:53
@ STATE_ID
Definition common.h:43

Function Documentation

◆ AppendByte()

void AppendByte ( PTOKEN Token,
char c )

Appends char to the token value.

Parameters
Token
char
232{
233 //
234 // Check overflow of the string
235 //
236 if (Token->Len >= Token->MaxLen - 1)
237 {
238 //
239 // Double the length of the allocated space for the string
240 //
241 Token->MaxLen *= 2;
242 char * NewValue = (char *)calloc(Token->MaxLen + 1, sizeof(char));
243
244 if (NewValue == NULL)
245 {
246 printf("err, could not allocate buffer");
247 return;
248 }
249
250 //
251 // Free Old buffer and update the pointer
252 //
253 memcpy(NewValue, Token->Value, Token->Len);
254 free(Token->Value);
255 Token->Value = NewValue;
256 }
257
258 //
259 // Append the new character to the string
260 //
261 Token->Value[Token->Len] = c;
262 Token->Len++;
263}
unsigned int Len
Definition common.h:75
unsigned int MaxLen
Definition common.h:76
char * Value
Definition common.h:74

◆ AppendWchar()

void AppendWchar ( PTOKEN Token,
wchar_t c )

Appends wchar_t to the token value.

Parameters
Token
char
273{
274 //
275 // Check overflow of the string
276 //
277 if (Token->Len >= Token->MaxLen - 2)
278 {
279 //
280 // Double the length of the allocated space for the wstring
281 //
282 Token->MaxLen *= 2;
283 char * NewValue = (char *)calloc(Token->MaxLen + 2, sizeof(char));
284
285 if (NewValue == NULL)
286 {
287 printf("err, could not allocate buffer");
288 return;
289 }
290
291 //
292 // Free Old buffer and update the pointer
293 //
294 memcpy(NewValue, Token->Value, Token->Len);
295 free(Token->Value);
296 Token->Value = NewValue;
297 }
298
299 //
300 // Append the new character to the wstring
301 //
302 *((wchar_t *)(Token->Value) + Token->Len / 2) = c;
303 Token->Len += 2;
304}

◆ BinaryToInt()

unsigned long long BinaryToInt ( char * str)

Converts a binary string to integer.

Parameters
str
Returns
unsigned long long
1504{
1505 size_t Len;
1506 unsigned long long Acc = 0;
1507
1508 Len = strlen(str);
1509
1510 for (int i = 0; i < Len; i++)
1511 {
1512 Acc <<= 1;
1513 Acc += (str[i] - '0');
1514 }
1515 return Acc;
1516}

◆ CleanStackTempList()

void CleanStackTempList ( void )

Resets the stack temporary variables map.

724{
725 for (int i = 0; i < MAX_TEMP_COUNT; i++)
726 {
727 StackTempMap[i] = 0;
728 }
729}
#define MAX_TEMP_COUNT
Definition Constants.h:566
char StackTempMap[MAX_TEMP_COUNT]
Definition globals.c:19

◆ CleanTempList()

void CleanTempList ( void )

Resets the temporary variables map.

710{
711 for (int i = 0; i < MAX_TEMP_COUNT; i++)
712 {
713 TempMap[i] = 0;
714 StackTempMap[i] = 0;
715 }
716}
char TempMap[MAX_TEMP_COUNT]
Temp variable map.
Definition globals.c:18

◆ CopyToken()

PTOKEN CopyToken ( PTOKEN Token)

Copies a PTOKEN.

Returns
PTOKEN
313{
314 PTOKEN TokenCopy = (PTOKEN)malloc(sizeof(TOKEN));
315
316 if (TokenCopy == NULL)
317 {
318 //
319 // There was an error allocating buffer
320 //
321 return NULL;
322 }
323
324 TokenCopy->Type = Token->Type;
325 TokenCopy->MaxLen = Token->MaxLen;
326 TokenCopy->Len = Token->Len;
327 TokenCopy->Value = (char *)calloc(strlen(Token->Value) + 1, sizeof(char));
328
329 if (TokenCopy->Value == NULL)
330 {
331 //
332 // There was an error allocating buffer
333 //
334 free(TokenCopy);
335 return NULL;
336 }
337
338 strcpy(TokenCopy->Value, Token->Value);
339
340 return TokenCopy;
341}
NULL()
Definition test-case-generator.py:530
struct _TOKEN * PTOKEN
read tokens from input stored in this structure
Definition common.h:72
TOKEN_TYPE Type
Definition common.h:73

◆ DecimalToInt()

unsigned long long DecimalToInt ( char * str)

Converts an decimal string to a integer.

Parameters
str
Returns
unsigned long long int
1394{
1395 unsigned long long Acc = 0;
1396 size_t Len;
1397
1398 Len = strlen(str);
1399 for (int i = 0; i < Len; i++)
1400 {
1401 Acc *= 10;
1402 Acc += (str[i] - '0');
1403 }
1404 return Acc;
1405}

◆ DecimalToSignedInt()

unsigned long long DecimalToSignedInt ( char * str)

Converts an decimal string to a signed integer.

Parameters
str
Returns
unsigned long long
1415{
1416 long long Acc = 0;
1417 size_t Len;
1418
1419 if (str[0] == '-')
1420 {
1421 Len = strlen(str);
1422 for (int i = 1; i < Len; i++)
1423 {
1424 Acc *= 10;
1425 Acc += (str[i] - '0');
1426 }
1427 return -Acc;
1428 }
1429 else
1430 {
1431 Len = strlen(str);
1432 for (int i = 0; i < Len; i++)
1433 {
1434 Acc *= 10;
1435 Acc += (str[i] - '0');
1436 }
1437 return Acc;
1438 }
1439}

◆ FreeTemp()

void FreeTemp ( PTOKEN Temp)

Frees the memory allocated by Temp.

Parameters
Temp
692{
693 int id = (int)DecimalToInt(Temp->Value);
694 if (Temp->Type == TEMP)
695 {
696 TempMap[id] = 0;
697 }
698 else if (Temp->Type == STACK_TEMP)
699 {
700 StackTempMap[id] = 0;
701 }
702}
unsigned long long DecimalToInt(char *str)
Converts an decimal string to a integer.
Definition common.c:1393

◆ GetNonTerminalId()

int GetNonTerminalId ( PTOKEN Token)

Gets the Non Terminal Id object.

Parameters
Token
Returns
int
1113{
1114 for (int i = 0; i < NONETERMINAL_COUNT; i++)
1115 {
1116 if (!strcmp(Token->Value, NoneTerminalMap[i]))
1117 return i;
1118 }
1119 return INVALID;
1120}
#define INVALID
Definition ScriptEngineCommonDefinitions.h:96
const char * NoneTerminalMap[NONETERMINAL_COUNT]
Definition parse-table.c:629
#define NONETERMINAL_COUNT
Definition parse-table.h:6

◆ GetTerminalId()

int GetTerminalId ( PTOKEN Token)

Gets the Terminal Id object.

Parameters
Token
Returns
int
1130{
1131 for (int i = 0; i < TERMINAL_COUNT; i++)
1132 {
1133 if (Token->Type == HEX)
1134 {
1135 if (!strcmp("_hex", TerminalMap[i]))
1136 return i;
1137 }
1138 else if (Token->Type == GLOBAL_ID || Token->Type == GLOBAL_UNRESOLVED_ID)
1139 {
1140 if (!strcmp("_global_id", TerminalMap[i]))
1141 {
1142 return i;
1143 }
1144 }
1145 else if (Token->Type == LOCAL_ID || Token->Type == LOCAL_UNRESOLVED_ID)
1146 {
1147 if (!strcmp("_local_id", TerminalMap[i]))
1148 {
1149 return i;
1150 }
1151 }
1152 else if (Token->Type == FUNCTION_PARAMETER_ID)
1153 {
1154 if (!strcmp("_function_parameter_id", TerminalMap[i]))
1155 {
1156 return i;
1157 }
1158 }
1159 else if (Token->Type == REGISTER)
1160 {
1161 if (!strcmp("_register", TerminalMap[i]))
1162 {
1163 return i;
1164 }
1165 }
1166 else if (Token->Type == PSEUDO_REGISTER)
1167 {
1168 if (!strcmp("_pseudo_register", TerminalMap[i]))
1169 {
1170 return i;
1171 }
1172 }
1173 else if (Token->Type == DECIMAL)
1174 {
1175 if (!strcmp("_decimal", TerminalMap[i]))
1176 {
1177 return i;
1178 }
1179 }
1180 else if (Token->Type == BINARY)
1181 {
1182 if (!strcmp("_binary", TerminalMap[i]))
1183 {
1184 return i;
1185 }
1186 }
1187 else if (Token->Type == OCTAL)
1188 {
1189 if (!strcmp("_octal", TerminalMap[i]))
1190 {
1191 return i;
1192 }
1193 }
1194 else if (Token->Type == STRING)
1195 {
1196 if (!strcmp("_string", TerminalMap[i]))
1197 {
1198 return i;
1199 }
1200 }
1201 else if (Token->Type == WSTRING)
1202 {
1203 if (!strcmp("_wstring", TerminalMap[i]))
1204 {
1205 return i;
1206 }
1207 }
1208 else // Keyword
1209 {
1210 if (!strcmp(Token->Value, TerminalMap[i]))
1211 return i;
1212 }
1213 }
1214 return INVALID;
1215}
const char * TerminalMap[TERMINAL_COUNT]
Definition parse-table.c:681
#define TERMINAL_COUNT
Definition parse-table.h:5

◆ HexToInt()

unsigned long long HexToInt ( char * str)

Converts an hexadecimal string to integer.

Parameters
str
Returns
unsigned long long
1449{
1450 char temp;
1451 size_t len = strlen(str);
1452 unsigned long long Acc = 0;
1453 for (int i = 0; i < len; i++)
1454 {
1455 Acc <<= 4;
1456 if (str[i] >= '0' && str[i] <= '9')
1457 {
1458 temp = str[i] - '0';
1459 }
1460 else if (str[i] >= 'a' && str[i] <= 'f')
1461 {
1462 temp = str[i] - 'a' + 10;
1463 }
1464 else
1465 {
1466 temp = str[i] - 'A' + 10;
1467 }
1468 Acc += temp;
1469 }
1470
1471 return Acc;
1472}

◆ IsBinary()

char IsBinary ( char c)

Checks whether input char belongs to binary digit-set or not.

Parameters
char
Returns
bool
590{
591 if (c == '0' || c == '1')
592 return 1;
593 else
594 {
595 return 0;
596 }
597}

◆ IsDecimal()

char IsDecimal ( char c)

Checks whether input char belongs to decimal digit-set or not.

Parameters
char
Returns
char
541{
542 if (c >= '0' && c <= '9')
543 return 1;
544 else
545 return 0;
546}

◆ IsEqual()

char IsEqual ( const PTOKEN Token1,
const PTOKEN Token2 )

Checks whether the value and type of Token1 and Token2 are the same.

Parameters
Token1
Token2
Returns
char
1338{
1339 if (Token1->Type == Token2->Type)
1340 {
1341 if (Token1->Type == SPECIAL_TOKEN)
1342 {
1343 if (!strcmp(Token1->Value, Token2->Value))
1344 {
1345 return 1;
1346 }
1347 }
1348 else
1349 {
1350 return 1;
1351 }
1352 }
1353 if (Token1->Type == GLOBAL_ID && Token2->Type == GLOBAL_UNRESOLVED_ID)
1354 {
1355 return 1;
1356 }
1357 if (Token1->Type == GLOBAL_UNRESOLVED_ID && Token2->Type == GLOBAL_ID)
1358 {
1359 return 1;
1360 }
1361
1362 if (Token1->Type == LOCAL_ID && Token2->Type == LOCAL_UNRESOLVED_ID)
1363 {
1364 return 1;
1365 }
1366 if (Token1->Type == LOCAL_UNRESOLVED_ID && Token2->Type == LOCAL_ID)
1367 {
1368 return 1;
1369 }
1370
1371 return 0;
1372}

◆ IsHex()

char IsHex ( char c)

Checks whether input char belongs to hexadecimal digit-set or not.

Parameters
char
Returns
char
526{
527 if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))
528 return 1;
529 else
530 return 0;
531}

◆ IsLetter()

char IsLetter ( char c)

Checks whether input char belongs to alphabet set or not.

Parameters
char
Returns
char
556{
557 if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
558 return 1;
559 else
560 {
561 return 0;
562 }
563}

◆ IsNoneTerminal()

char IsNoneTerminal ( PTOKEN Token)

Checks whether this Token is noneterminal NoneTerminal token starts with capital letter.

Parameters
Token
Returns
char
1082{
1083 if (Token->Value[0] >= 'A' && Token->Value[0] <= 'Z')
1084 return 1;
1085 else
1086 return 0;
1087}

◆ IsOctal()

char IsOctal ( char c)

Checks whether input char belongs to octal digit-set or not.

Parameters
char
Returns
char
607{
608 if (c >= '0' && c <= '7')
609 return 1;
610 else
611 return 0;
612}

◆ IsOneOperandOperator()

char IsOneOperandOperator ( PTOKEN Operator)

Checks whether this Token type is OperatorsOneOperandList.

Parameters
Operator
Returns
char
799{
800 unsigned int n = OPERATORS_ONE_OPERAND_LIST_LENGTH;
801 for (unsigned int i = 0; i < n; i++)
802 {
803 if (!strcmp(Operator->Value, OperatorsOneOperandList[i]))
804 {
805 return 1;
806 }
807 }
808 return 0;
809}
const char * OperatorsOneOperandList[]
Definition parse-table.c:952
#define OPERATORS_ONE_OPERAND_LIST_LENGTH
Definition parse-table.h:10

◆ IsSemanticRule()

char IsSemanticRule ( PTOKEN Token)

Checks whether this Token is semantic rule SemanticRule token starts with '@'.

Parameters
Token
Returns
char
1098{
1099 if (Token->Value[0] == '@')
1100 return 1;
1101 else
1102 return 0;
1103}

◆ IsTwoOperandOperator()

char IsTwoOperandOperator ( PTOKEN Operator)

Checks whether this Token type is OperatorsTwoOperandList.

Parameters
Operator
Returns
char
779{
780 unsigned int n = OPERATORS_TWO_OPERAND_LIST_LENGTH;
781 for (unsigned int i = 0; i < n; i++)
782 {
783 if (!strcmp(Operator->Value, OperatorsTwoOperandList[i]))
784 {
785 return 1;
786 }
787 }
788 return 0;
789}
const char * OperatorsTwoOperandList[]
Definition parse-table.c:934
#define OPERATORS_TWO_OPERAND_LIST_LENGTH
Definition parse-table.h:11

◆ IsType10Func()

char IsType10Func ( PTOKEN Operator)

Checks whether this Token type is TwoOpFunc3.

Parameters
Operator
Returns
char
939{
940 unsigned int n = TWOOPFUNC3_LENGTH;
941 for (unsigned int i = 0; i < n; i++)
942 {
943 if (!strcmp(Operator->Value, TwoOpFunc3[i]))
944 {
945 return 1;
946 }
947 }
948 return 0;
949}
const char * TwoOpFunc3[]
Definition parse-table.c:1010
#define TWOOPFUNC3_LENGTH
Definition parse-table.h:22

◆ IsType11Func()

char IsType11Func ( PTOKEN Operator)

Checks whether this Token type is ThreeOpFunc3.

Parameters
Operator
Returns
char
959{
960 unsigned int n = THREEOPFUNC3_LENGTH;
961 for (unsigned int i = 0; i < n; i++)
962 {
963 if (!strcmp(Operator->Value, ThreeOpFunc3[i]))
964 {
965 return 1;
966 }
967 }
968 return 0;
969}
const char * ThreeOpFunc3[]
Definition parse-table.c:1013
#define THREEOPFUNC3_LENGTH
Definition parse-table.h:23

◆ IsType12Func()

char IsType12Func ( PTOKEN Operator)

Checks whether this Token type is OneOpFunc4.

Parameters
Operator
Returns
char
979{
980 unsigned int n = ONEOPFUNC4_LENGTH;
981 for (unsigned int i = 0; i < n; i++)
982 {
983 if (!strcmp(Operator->Value, OneOpFunc4[i]))
984 {
985 return 1;
986 }
987 }
988 return 0;
989}
const char * OneOpFunc4[]
Definition parse-table.c:1020
#define ONEOPFUNC4_LENGTH
Definition parse-table.h:25

◆ IsType13Func()

char IsType13Func ( PTOKEN Operator)

Checks whether this Token type is TwoOpFunc4.

Parameters
Operator
Returns
char
999{
1000 unsigned int n = TWOOPFUNC4_LENGTH;
1001 for (unsigned int i = 0; i < n; i++)
1002 {
1003 if (!strcmp(Operator->Value, TwoOpFunc4[i]))
1004 {
1005 return 1;
1006 }
1007 }
1008 return 0;
1009}
const char * TwoOpFunc4[]
Definition parse-table.c:1023
#define TWOOPFUNC4_LENGTH
Definition parse-table.h:26

◆ IsType14Func()

char IsType14Func ( PTOKEN Operator)

Checks whether this Token type is ThreeOpFunc2.

Parameters
Operator
Returns
char
1019{
1020 unsigned int n = THREEOPFUNC2_LENGTH;
1021 for (unsigned int i = 0; i < n; i++)
1022 {
1023 if (!strcmp(Operator->Value, ThreeOpFunc2[i]))
1024 {
1025 return 1;
1026 }
1027 }
1028 return 0;
1029}
const char * ThreeOpFunc2[]
Definition parse-table.c:961
#define THREEOPFUNC2_LENGTH
Definition parse-table.h:16

◆ IsType15Func()

char IsType15Func ( PTOKEN Operator)

Checks whether this Token type is ThreeOpFunc4.

Parameters
Operator
Returns
char
1039{
1040 unsigned int n = THREEOPFUNC4_LENGTH;
1041 for (unsigned int i = 0; i < n; i++)
1042 {
1043 if (!strcmp(Operator->Value, ThreeOpFunc4[i]))
1044 {
1045 return 1;
1046 }
1047 }
1048 return 0;
1049}
const char * ThreeOpFunc4[]
Definition parse-table.c:1017
#define THREEOPFUNC4_LENGTH
Definition parse-table.h:24

◆ IsType1Func()

char IsType1Func ( PTOKEN Operator)

Checks whether this Token type is OneOpFunc1.

Parameters
Operator
Returns
char
739{
740 unsigned int n = ONEOPFUNC1_LENGTH;
741 for (unsigned int i = 0; i < n; i++)
742 {
743 if (!strcmp(Operator->Value, OneOpFunc1[i]))
744 {
745 return 1;
746 }
747 }
748 return 0;
749}
const char * OneOpFunc1[]
Definition parse-table.c:976
#define ONEOPFUNC1_LENGTH
Definition parse-table.h:19

◆ IsType2Func()

char IsType2Func ( PTOKEN Operator)

Checks whether this Token type is OneOpFunc2.

Parameters
Operator
Returns
char
759{
760 unsigned int n = ONEOPFUNC2_LENGTH;
761 for (unsigned int i = 0; i < n; i++)
762 {
763 if (!strcmp(Operator->Value, OneOpFunc2[i]))
764 {
765 return 1;
766 }
767 }
768 return 0;
769}
const char * OneOpFunc2[]
Definition parse-table.c:996
#define ONEOPFUNC2_LENGTH
Definition parse-table.h:20

◆ IsType4Func()

char IsType4Func ( PTOKEN Operator)

Checks whether this Token type is VarArgFunc1.

Parameters
Operator
Returns
char
819{
820 unsigned int n = VARARGFUNC1_LENGTH;
821 for (unsigned int i = 0; i < n; i++)
822 {
823 if (!strcmp(Operator->Value, VarArgFunc1[i]))
824 {
825 return 1;
826 }
827 }
828 return 0;
829}
const char * VarArgFunc1[]
Definition parse-table.c:1035
#define VARARGFUNC1_LENGTH
Definition parse-table.h:28

◆ IsType5Func()

char IsType5Func ( PTOKEN Operator)

Checks whether this Token type is ZeroOpFunc1.

Parameters
Operator
Returns
char
839{
840 unsigned int n = ZEROOPFUNC1_LENGTH;
841 for (unsigned int i = 0; i < n; i++)
842 {
843 if (!strcmp(Operator->Value, ZeroOpFunc1[i]))
844 {
845 return 1;
846 }
847 }
848 return 0;
849}
const char * ZeroOpFunc1[]
Definition parse-table.c:1026
#define ZEROOPFUNC1_LENGTH
Definition parse-table.h:27

◆ IsType6Func()

char IsType6Func ( PTOKEN Operator)

Checks whether this Token type is TwoOpFunc1.

Parameters
Operator
Returns
char
859{
860 unsigned int n = TWOOPFUNC1_LENGTH;
861 for (unsigned int i = 0; i < n; i++)
862 {
863 if (!strcmp(Operator->Value, TwoOpFunc1[i]))
864 {
865 return 1;
866 }
867 }
868 return 0;
869}
const char * TwoOpFunc1[]
Definition parse-table.c:965
#define TWOOPFUNC1_LENGTH
Definition parse-table.h:17

◆ IsType7Func()

char IsType7Func ( PTOKEN Operator)

Checks whether this Token type is TwoOpFunc2.

Parameters
Operator
Returns
char
879{
880 unsigned int n = TWOOPFUNC2_LENGTH;
881 for (unsigned int i = 0; i < n; i++)
882 {
883 if (!strcmp(Operator->Value, TwoOpFunc2[i]))
884 {
885 return 1;
886 }
887 }
888 return 0;
889}
const char * TwoOpFunc2[]
Definition parse-table.c:972
#define TWOOPFUNC2_LENGTH
Definition parse-table.h:18

◆ IsType8Func()

char IsType8Func ( PTOKEN Operator)

Checks whether this Token type is ThreeOpFunc1.

Parameters
Operator
Returns
char
899{
900 unsigned int n = THREEOPFUNC1_LENGTH;
901 for (unsigned int i = 0; i < n; i++)
902 {
903 if (!strcmp(Operator->Value, ThreeOpFunc1[i]))
904 {
905 return 1;
906 }
907 }
908 return 0;
909}
const char * ThreeOpFunc1[]
Definition parse-table.c:958
#define THREEOPFUNC1_LENGTH
Definition parse-table.h:15

◆ IsType9Func()

char IsType9Func ( PTOKEN Operator)

Checks whether this Token type is OneOpFunc3.

Parameters
Operator
Returns
char
919{
920 unsigned int n = ONEOPFUNC3_LENGTH;
921 for (unsigned int i = 0; i < n; i++)
922 {
923 if (!strcmp(Operator->Value, OneOpFunc3[i]))
924 {
925 return 1;
926 }
927 }
928 return 0;
929}
const char * OneOpFunc3[]
Definition parse-table.c:1007
#define ONEOPFUNC3_LENGTH
Definition parse-table.h:21

◆ IsUnderscore()

char IsUnderscore ( char c)

Checks whether input char is underscore (_) or not.

Parameters
char
Returns
char
573{
574 if (c >= '_')
575 return 1;
576 else
577 {
578 return 0;
579 }
580}

◆ IsVariableType()

char IsVariableType ( PTOKEN Operator)

Checks whether this Token type is VariableType.

Parameters
Operator
Returns
char
1060{
1061 unsigned int n = VARIABLETYPE_LENGTH;
1062 for (unsigned int i = 0; i < n; i++)
1063 {
1064 if (!strcmp(Operator->Value, VARIABLETYPE[i]))
1065 {
1066 return 1;
1067 }
1068 }
1069
1070 return 0;
1071}
const char * VARIABLETYPE[]
Definition parse-table.c:1038
#define VARIABLETYPE_LENGTH
Definition parse-table.h:29

◆ LalrGetNonTerminalId()

int LalrGetNonTerminalId ( PTOKEN Token)

Gets the Non Terminal Id object.

Parameters
Token
Returns
int
1225{
1226 for (int i = 0; i < LALR_NONTERMINAL_COUNT; i++)
1227 {
1228 if (!strcmp(Token->Value, LalrNoneTerminalMap[i]))
1229 return i;
1230 }
1231 return INVALID;
1232}
const char * LalrNoneTerminalMap[NONETERMINAL_COUNT]
Definition parse-table.c:1598
#define LALR_NONTERMINAL_COUNT
Definition parse-table.h:61

◆ LalrGetTerminalId()

int LalrGetTerminalId ( PTOKEN Token)

Gets the Terminal Id object.

Parameters
Token
Returns
int
1242{
1243 for (int i = 0; i < LALR_TERMINAL_COUNT; i++)
1244 {
1245 if (Token->Type == HEX)
1246 {
1247 if (!strcmp("_hex", LalrTerminalMap[i]))
1248 return i;
1249 }
1250 else if (Token->Type == GLOBAL_ID || Token->Type == GLOBAL_UNRESOLVED_ID)
1251 {
1252 if (!strcmp("_global_id", LalrTerminalMap[i]))
1253 {
1254 return i;
1255 }
1256 }
1257 else if (Token->Type == LOCAL_ID || Token->Type == LOCAL_UNRESOLVED_ID)
1258 {
1259 if (!strcmp("_local_id", LalrTerminalMap[i]))
1260 {
1261 return i;
1262 }
1263 }
1264 else if (Token->Type == FUNCTION_PARAMETER_ID)
1265 {
1266 if (!strcmp("_function_parameter_id", LalrTerminalMap[i]))
1267 {
1268 return i;
1269 }
1270 }
1271 else if (Token->Type == REGISTER)
1272 {
1273 if (!strcmp("_register", LalrTerminalMap[i]))
1274 {
1275 return i;
1276 }
1277 }
1278 else if (Token->Type == PSEUDO_REGISTER)
1279 {
1280 if (!strcmp("_pseudo_register", LalrTerminalMap[i]))
1281 {
1282 return i;
1283 }
1284 }
1285 else if (Token->Type == DECIMAL)
1286 {
1287 if (!strcmp("_decimal", LalrTerminalMap[i]))
1288 {
1289 return i;
1290 }
1291 }
1292 else if (Token->Type == BINARY)
1293 {
1294 if (!strcmp("_binary", LalrTerminalMap[i]))
1295 {
1296 return i;
1297 }
1298 }
1299 else if (Token->Type == OCTAL)
1300 {
1301 if (!strcmp("_octal", LalrTerminalMap[i]))
1302 {
1303 return i;
1304 }
1305 }
1306 else if (Token->Type == STRING)
1307 {
1308 if (!strcmp("_string", LalrTerminalMap[i]))
1309 {
1310 return i;
1311 }
1312 }
1313 else if (Token->Type == WSTRING)
1314 {
1315 if (!strcmp("_wstring", LalrTerminalMap[i]))
1316 {
1317 return i;
1318 }
1319 }
1320 else // Keyword
1321 {
1322 if (!strcmp(Token->Value, LalrTerminalMap[i]))
1323 return i;
1324 }
1325 }
1326 return INVALID;
1327}
const char * LalrTerminalMap[TERMINAL_COUNT]
Definition parse-table.c:1620
#define LALR_TERMINAL_COUNT
Definition parse-table.h:60

◆ NewStackTemp()

PTOKEN NewStackTemp ( PSCRIPT_ENGINE_ERROR_TYPE Error)

Allocates a new temporary variable in stack and returns it.

Parameters
Error
Returns
PTOKEN
661{
662 static unsigned int TempID = 0;
663 int i;
664 for (i = 0; i < MAX_TEMP_COUNT; i++)
665 {
666 if (StackTempMap[i] == 0)
667 {
668 TempID = i;
669 StackTempMap[i] = 1;
670 break;
671 }
672 }
673 if (i == MAX_TEMP_COUNT)
674 {
676 }
677 PTOKEN Temp = NewUnknownToken();
678 char TempValue[8];
679 sprintf(TempValue, "%d", TempID);
680 strcpy(Temp->Value, TempValue);
681 Temp->Type = STACK_TEMP;
682 return Temp;
683}
PTOKEN NewUnknownToken()
Allocates a new token.
Definition common.c:20
@ SCRIPT_ENGINE_ERROR_TEMP_LIST_FULL
Definition script-engine.h:58

◆ NewTemp()

PTOKEN NewTemp ( PSCRIPT_ENGINE_ERROR_TYPE Error,
PUSER_DEFINED_FUNCTION_NODE CurrentFunctionSymbol )

Allocates a new temporary variable and returns it.

Parameters
Error
Returns
PTOKEN
622{
623 if (CurrentFunctionSymbol)
624 {
625 return NewStackTemp(Error);
626 }
627 else
628 {
629 static unsigned int TempID = 0;
630 int i;
631 for (i = 0; i < MAX_TEMP_COUNT; i++)
632 {
633 if (TempMap[i] == 0)
634 {
635 TempID = i;
636 TempMap[i] = 1;
637 break;
638 }
639 }
640 if (i == MAX_TEMP_COUNT)
641 {
643 }
644 PTOKEN Temp = NewUnknownToken();
645 char TempValue[8];
646 sprintf(TempValue, "%d", TempID);
647 strcpy(Temp->Value, TempValue);
648 Temp->Type = TEMP;
649 return Temp;
650 }
651}
PTOKEN NewStackTemp(PSCRIPT_ENGINE_ERROR_TYPE Error)
Allocates a new temporary variable in stack and returns it.
Definition common.c:660

◆ NewToken()

PTOKEN NewToken ( TOKEN_TYPE Type,
char * Value )
61{
62 //
63 // Allocate memory for token]
64 //
65 PTOKEN Token = (PTOKEN)malloc(sizeof(TOKEN));
66
67 if (Token == NULL)
68 {
69 //
70 // There was an error allocating buffer
71 //
72 return NULL;
73 }
74
75 //
76 // Init fields
77 //
78 unsigned int Len = (unsigned int)strlen(Value);
79 Token->Type = Type;
80 Token->Len = Len;
81 Token->MaxLen = Len;
82 Token->Value = (char *)calloc(Token->MaxLen + 1, sizeof(char));
83
84 if (Token->Value == NULL)
85 {
86 //
87 // There was an error allocating buffer
88 //
89 free(Token);
90 return NULL;
91 }
92
93 strcpy(Token->Value, Value);
94
95 return Token;
96}
RequestedActionOfThePacket Value(0x1) 00000000

◆ NewTokenList()

PTOKEN_LIST NewTokenList ( void )

allocates a new TOKEN_LIST

Returns
TOKEN_LIST
350{
351 PTOKEN_LIST TokenList = NULL;
352
353 //
354 // Allocation of memory for TOKEN_LIST structure
355 //
356 TokenList = (PTOKEN_LIST)malloc(sizeof(*TokenList));
357
358 if (TokenList == NULL)
359 {
360 //
361 // There was an error allocating buffer
362 //
363 return NULL;
364 }
365
366 //
367 // Initialize fields of TOKEN_LIST
368 //
369 TokenList->Pointer = 0;
370 TokenList->Size = TOKEN_LIST_INIT_SIZE;
371
372 //
373 // Allocation of memory for TOKEN_LIST buffer
374 //
375 TokenList->Head = (PTOKEN *)malloc(TokenList->Size * sizeof(PTOKEN));
376
377 return TokenList;
378}
struct _TOKEN_LIST * PTOKEN_LIST
#define TOKEN_LIST_INIT_SIZE
init size of token list
Definition common.h:31
this structure is a dynamic container of TOKENS
Definition common.h:83
unsigned int Pointer
Definition common.h:85
unsigned int Size
Definition common.h:86
PTOKEN * Head
Definition common.h:84

◆ NewUnknownToken()

PTOKEN NewUnknownToken ( void )

Allocates a new token.

Returns
Token
21{
22 PTOKEN Token;
23
24 //
25 // Allocate memory for token and its value
26 //
27 Token = (PTOKEN)malloc(sizeof(TOKEN));
28
29 if (Token == NULL)
30 {
31 //
32 // There was an error allocating buffer
33 //
34 return NULL;
35 }
36
37 Token->Value = (char *)calloc(TOKEN_VALUE_MAX_LEN + 1, sizeof(char));
38
39 if (Token->Value == NULL)
40 {
41 //
42 // There was an error allocating buffer
43 //
44 free(Token);
45 return NULL;
46 }
47
48 //
49 // Init fields
50 //
51 strcpy(Token->Value, "");
52 Token->Type = UNKNOWN;
53 Token->Len = 0;
55
56 return Token;
57}
#define TOKEN_VALUE_MAX_LEN
maximum length of string in the token
Definition common.h:26

◆ OctalToInt()

unsigned long long OctalToInt ( char * str)

Converts an octal string to integer.

Parameters
str
Returns
unsigned long long
1482{
1483 size_t Len;
1484 unsigned long long Acc = 0;
1485
1486 Len = strlen(str);
1487
1488 for (int i = 0; i < Len; i++)
1489 {
1490 Acc <<= 3;
1491 Acc += (str[i] - '0');
1492 }
1493 return Acc;
1494}

◆ Pop()

PTOKEN Pop ( PTOKEN_LIST TokenList)

Removes last Token of a TokenList and returns it.

Parameters
TokenList@
Returns
Token
486{
487 //
488 // Calculate address to read most recent token
489 //
490 if (TokenList->Pointer > 0)
491 TokenList->Pointer--; // not consider what if the token's type is string or wstring
492 uintptr_t Head = (uintptr_t)TokenList->Head;
493 uintptr_t Pointer = (uintptr_t)TokenList->Pointer;
494 PTOKEN * ReadAddr = (PTOKEN *)(Head + Pointer * sizeof(PTOKEN));
495
496 return *ReadAddr;
497}

◆ PrintToken()

void PrintToken ( PTOKEN Token)

Prints token @detail prints value and type of token.

Parameters
Token
120{
121 //
122 // Prints value of the Token
123 //
124 if (Token->Type == WHITE_SPACE)
125 {
126 printf("< :");
127 }
128 else
129 {
130 printf("<'%s' : ", Token->Value);
131 }
132
133 //
134 // Prints type of the Token
135 //
136 switch (Token->Type)
137 {
138 case GLOBAL_ID:
139 printf(" GLOBAL_ID>\n");
140 break;
142 printf(" GLOBAL_UNRESOLVED_ID>\n");
143 break;
144 case LOCAL_ID:
145 printf(" LOCAL_ID>\n");
146 break;
148 printf(" LOCAL_UNRESOLVED_ID>\n");
149 break;
150 case STATE_ID:
151 printf(" STATE_ID>\n");
152 break;
153 case DECIMAL:
154 printf(" DECIMAL>\n");
155 break;
156 case HEX:
157 printf(" HEX>\n");
158 break;
159 case OCTAL:
160 printf(" OCTAL>\n");
161 break;
162 case BINARY:
163 printf(" BINARY>\n");
164 break;
165 case SPECIAL_TOKEN:
166 printf(" SPECIAL_TOKEN>\n");
167 break;
168 case KEYWORD:
169 printf(" KEYWORD>\n");
170 break;
171 case WHITE_SPACE:
172 printf(" WHITE_SPACE>\n");
173 break;
174 case COMMENT:
175 printf(" COMMENT>\n");
176 break;
177 case REGISTER:
178 printf(" REGISTER>\n");
179 break;
180 case PSEUDO_REGISTER:
181 printf(" PSEUDO_REGISTER>\n");
182 break;
183 case SEMANTIC_RULE:
184 printf(" SEMANTIC_RULE>\n");
185 break;
186 case NON_TERMINAL:
187 printf(" NON_TERMINAL>\n");
188 break;
189 case END_OF_STACK:
190 printf(" END_OF_STACK>\n");
191 break;
192 case STRING:
193 printf(" STRING>\n");
194 break;
195 case WSTRING:
196 printf(" WSTRING>\n");
197 break;
198 case TEMP:
199 printf(" TEMP>\n");
200 break;
201 case UNKNOWN:
202 printf(" UNKNOWN>\n");
203 break;
205 printf(" INPUT_VARIABLE_TYPE>\n");
206 break;
208 printf(" HANDLED_VARIABLE_TYPE>\n");
209 break;
210 case FUNCTION_TYPE:
211 printf(" FUNCTION_TYPE>\n");
212 break;
214 printf(" FUNCTION_PARAMETER_ID>\n");
215 break;
216 case STACK_TEMP:
217 printf(" STACK_TEMP>\n");
218 default:
219 printf(" ERROR>\n");
220 break;
221 }
222}

◆ PrintTokenList()

void PrintTokenList ( PTOKEN_LIST TokenList)

Prints each Token inside a TokenList.

Parameters
TokenList
407{
408 PTOKEN Token;
409 for (uintptr_t i = 0; i < TokenList->Pointer; i++)
410 {
411 Token = *(TokenList->Head + i);
412 PrintToken(Token);
413 }
414}
void PrintToken(PTOKEN Token)
Prints token @detail prints value and type of token.
Definition common.c:119

◆ Push()

PTOKEN_LIST Push ( PTOKEN_LIST TokenList,
PTOKEN Token )

Adds Token to the last empty position of TokenList.

Parameters
Token
TokenList
Returns
TokenList
425{
426 //
427 // Calculate address to write new token
428 //
429 uintptr_t Head = (uintptr_t)TokenList->Head;
430 uintptr_t Pointer = (uintptr_t)TokenList->Pointer;
431 PTOKEN * WriteAddr = (PTOKEN *)(Head + Pointer * sizeof(PTOKEN));
432
433 //
434 // Write Token to appropriate address in TokenList
435 //
436 *WriteAddr = Token;
437
438 //
439 // Update Pointer
440 //
441 TokenList->Pointer++;
442
443 //
444 // Handle overflow
445 //
446 if (Pointer == TokenList->Size - 1)
447 {
448 //
449 // Allocate a new buffer for string list with doubled length
450 //
451 PTOKEN * NewHead = (PTOKEN *)malloc(2 * TokenList->Size * sizeof(PTOKEN));
452
453 if (NewHead == NULL)
454 {
455 printf("err, could not allocate buffer");
456 return NULL;
457 }
458
459 //
460 // Copy old buffer to new buffer
461 //
462 memcpy(NewHead, TokenList->Head, TokenList->Size * sizeof(PTOKEN));
463
464 //
465 // Free old buffer
466 //
467 free(TokenList->Head);
468
469 //
470 // Update Head and size of TokenList
471 //
472 TokenList->Size = TokenList->Size * 2;
473 TokenList->Head = NewHead;
474 }
475
476 return TokenList;
477}

◆ RemoveToken()

void RemoveToken ( PTOKEN * Token)

Removes allocated memory of a token.

Parameters
Token
105{
106 free((*Token)->Value);
107 free(*Token);
108 *Token = NULL;
109 return;
110}

◆ RemoveTokenList()

void RemoveTokenList ( PTOKEN_LIST TokenList)

Removes allocated memory of a TOKEN_LIST.

Parameters
TokenList
387{
388 PTOKEN Token;
389 for (uintptr_t i = 0; i < TokenList->Pointer; i++)
390 {
391 Token = *(TokenList->Head + i);
392 RemoveToken(&Token);
393 }
394 free(TokenList->Head);
395 free(TokenList);
396
397 return;
398}
void RemoveToken(PTOKEN *Token)
Removes allocated memory of a token.
Definition common.c:104

◆ RotateLeftStringOnce()

void RotateLeftStringOnce ( char * str)

Rotate a character array to the left by one time.

Parameters
str
1525{
1526 int length = (int)strlen(str);
1527 char temp = str[0];
1528 for (int i = 0; i < (length - 1); i++)
1529 {
1530 str[i] = str[i + 1];
1531 }
1532 str[length - 1] = temp;
1533}

◆ SetType()

void SetType ( unsigned long long * Val,
unsigned char Type )

Set the Type object.

Parameters
Val
Type
1382{
1383 *Val = (unsigned long long int)Type;
1384}

◆ Top()

PTOKEN Top ( PTOKEN_LIST TokenList)

Returns last Token of a TokenList.

Parameters
TokenList
Returns
Token
507{
508 //
509 // Calculate address to read most recent pushed token
510 //
511 uintptr_t Head = (uintptr_t)TokenList->Head;
512 uintptr_t Pointer = (uintptr_t)TokenList->Pointer - 1;
513 PTOKEN * ReadAddr = (PTOKEN *)(Head + Pointer * sizeof(PTOKEN));
514
515 return *ReadAddr;
516}