-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.cc
37 lines (30 loc) · 985 Bytes
/
errors.cc
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
#include "errors.h"
#include <iostream>
#include <sstream>
#include <stdarg.h>
#include <stdio.h>
using namespace std;
int ReportError::numErrors = 0;
void ReportError::UntermString(yyltype *loc, const char *ident) {
numErrors++;
cout << "Error: unterminated string" << endl;
cout << "Line number " << loc->first_line << ":" << loc->first_column << " " << ident << endl;
}
void ReportError::UnrecogChar(yyltype *loc, char ch) {
numErrors++;
cout << "Error: unrecognized character" << endl;
cout << "Line number " << loc->first_line << ":" << loc->first_column << " " << ch << endl;
}
void ReportError::LongIdentifier(yyltype *loc, const char *ident) {
cout << "Error: Identifier too long: \"" << ident << "\"" << endl;
}
void ReportError::UntermBrack() {
numErrors++;
cout << "Error: unterminated brackets" << endl;
}
int ReportError::findNumErrors() {
return numErrors;
}
void yyerror (char const *s) {
fprintf (stderr, "%s\n", s);
}