-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLT.cpp
63 lines (56 loc) · 1.2 KB
/
LT.cpp
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "LT.h"
#include "stdafx.h"
#include "Error.h"
#include "Parm.h"
#include "Log.h"
using namespace Log;
using namespace std;
namespace LT
{
LexTable Create(int size)
{
LexTable* Table = new LexTable;
if (size > LT_MAXSIZE)
throw ERROR_THROW(120);
Table->maxsize = size;
Table->size = 0;
Table->table = new Entry[size];
return *Table;
}
void Add(LexTable& lextable, Entry entry)
{
if (lextable.size + 1 > lextable.maxsize)
throw ERROR_THROW(121);
lextable.table[lextable.size] = entry;
lextable.size += 1;
}
Entry GetEntry(LexTable& lextable, int n)
{
return lextable.table[n];
}
void Delete(LexTable& lextable)
{
delete[] lextable.table;
}
Entry writeEntry(Entry& entry, char lexema, int indx, int line)
{
entry.lexema = lexema;
entry.idxTI = indx;
entry.sn = line;
return entry;
}
void showTable(LexTable lextable, Parm::PARM parm) // âûâîä òàáëèöû ëåêñåì
{
ofstream out(parm.out);
for (int i = 0; i < lextable.size; i++)
{
if (lextable.table[i].lexema == ';')
{
out << lextable.table[i].lexema << endl;
}
else
out << lextable.table[i].lexema;
}
out.close();
}
}