-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathErrorTable.cpp
More file actions
100 lines (77 loc) · 3.05 KB
/
Copy pathErrorTable.cpp
File metadata and controls
100 lines (77 loc) · 3.05 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/***************************************************************************
Error.cpp - description
-------------------
begin : Tue Jun 18 2002
copyright : (C) 2002 by Manuel Astudillo
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/
#include "ErrorTable.h"
ErrorTable::ErrorTable () {
errors.clear();
}
ErrorTable::~ErrorTable () {
for (unsigned short i = 0; i < errors.size(); i++) {
delete errors[i];
}
}
void ErrorTable::clear () {
errors.clear();
}
void ErrorTable::addError (error_type type, error_value value, Symbol *rdc,
Terminal *lastTerminal, vector <wstring> expected,
vector <Symbol*> traceback, integer line, integer col) {
GPError *err = new GPError ();
err->expected = expected;
err->traceback = traceback;
err->line = line;
err->col = col;
err->type = type;
err->value = value;
err->reduction = rdc;
err->lastTerminal = *lastTerminal;
errors.push_back (err);
}
void ErrorTable::addError (error_type type, error_value value, Symbol *rdc,
integer line, integer col) {
GPError *err = new GPError ();
err->line = line;
err->col = col;
err->type = type;
err->value = value;
err->reduction = rdc;
errors.push_back (err);
}
void ErrorTable::print () {
unsigned int i,k;
for (i = 0; i < errors.size(); i++) {
wprintf (L"Error line: %d, col: %d ", errors[i]->line, errors[i]->col);
// wprintf (errors[i]->msg);
wprintf (L"\n");
if (errors[i]->reduction != NULL) {
wprintf (L"Last correct parsed token was: ");
wprintf (errors[i]->reduction->symbol.c_str());
wprintf (L"\n");
}
wprintf (L"Expected Tokens: \n");
for (k = 0; k < errors[i]->expected.size (); k++) {
//wchar_t *a = errors[i]->traceback[k]->symbol;
wprintf (errors[i]->expected[k].c_str());
wprintf (L"\n");
}
wprintf (L"Tokens Traceback: \n");
for (k = 0; k < errors[i]->traceback.size (); k++) {
//wchar_t *a = errors[i]->traceback[k]->symbol;
//if (a != NULL) {
wprintf (errors[i]->traceback[k]->symbol.c_str());
wprintf (L"\n");
//}
}
}
}