-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparam_validation.h
48 lines (36 loc) · 2.01 KB
/
param_validation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*********************************FILE__HEADER*********************************\
* File: param_validation.h
* Authors: Daniel Brodsky & Lior Katav
* Date: August-2023
* Description: This header file provides the declarations for a suite of
* functions designed for validating various parameters and
* operands in an assembly language program. It aids in
* checking the validity of labels, registers, numbers,
* and instructions, checks their presence in the program
* state, and assists in determining the type of a given
* operand.
\******************************************************************************/
#ifndef PARAM_VALIDATION_H
#define PARAM_VALIDATION_H
#include "utils.h"
#include "program_constants.h"
/* Function that checks if a given string is a label in the program state */
int isLabel(const char *str, ProgramState *programState);
/* Function that returns the index of a given label in the program state */
int getLabelIndex(const char *str, ProgramState *programState);
/* Function that checks if a given label exists in the program state and isn't external */
Boolean isLabelExists(char *label, ProgramState *programState);
/* Function that checks if a given string is a number */
int isNumber(const char *str);
/* Function that checks if a given string is a register */
int isRegister(const char *str);
/* Function that finds the index of a given instruction in the instruction list */
int findInstruction(const char *instruction);
/* Function that finds the index of a given command in the commands list */
int findCommand(char *command);
/* Function that validates if a given parameter is of the expected type */
int
isValidParam(char *param, OperandType expectedType, ProgramState *programState);
/* Function that determines the type of a given operand */
int findParameterType(char *operand, ProgramState *programState);
#endif