-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfsm.h
More file actions
48 lines (43 loc) · 1.64 KB
/
Copy pathfsm.h
File metadata and controls
48 lines (43 loc) · 1.64 KB
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
/**
* @brief Implementation of finite state machine (FSM) functions for syntax and
* semantic analysis.
*
* The FSM is responsible for parsing and validating each line of the code,
* performing syntax analysis, and handling part of the semantic analysis, such
* as checking for valid addressing modes and preventing redeclaration of labels.
*
*/
#ifndef _FSM_H_
#define _FSM_H_
/* ------------------------------- includes ------------------------------- */
#include "setting.h"
#include "utils/text.h"
#include "utils/errors.h"
#include "fileStructures/symbolTable.h"
#include "fileStructures/dataSeg.h"
#include "fileStructures/codeSeg.h"
#include "analysis.h"
/* ------------------------------------------------------------------------- */
/**
* @brief Runs the finite state machine (FSM) to perform syntax and
* semantic analysis on the provided line of assembly code.
*
* @param line Pointer to the LineInfo structure containing information about the line.
* @param symbol_table Pointer to the symbol table.
* @return TRUE if syntax analysis is successful, FALSE otherwise.
*
* @note
* Before passing a line to the FSM, ensure LineInfo is appropriately set up:
*
* - line type correctly set (with str_line / op_line / ent_ext_line /
* data_line / define_line )
*
* - Place the first word after the word that determines the line's type in
* the token buffer. For example:
* CODE: mov STR , DATA[2]
* ~~~
*
* - Make sure LineInfo contains any necessary buffers for FSM analysis.
*/
Bool run_fsm (LineInfo *line, Symbol_Table *symbol_table);
#endif /* _FSM_H_ */