00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028
00029 #include <iostream>
00030 #include "ucloc.h"
00031
00032 using std::strcmp;
00033 using std::strcpy;
00034 using std::strlen;
00035 using std::cout;
00036 using std::endl;
00037
00038
00039 std::vector<char *> Uc_location::source_names;
00040 char *Uc_location::cur_source = 0;
00041 int Uc_location::cur_line = 0;
00042 int Uc_location::num_errors = 0;
00043
00044
00045
00046
00047
00048 void Uc_location::set_cur
00049 (
00050 const char *s,
00051 int l
00052 )
00053 {
00054 cur_line = l;
00055 cur_source = 0;
00056 for (std::vector<char *>::const_iterator it = source_names.begin();
00057 it != source_names.end(); it++)
00058 if (strcmp(s, *it) == 0)
00059 {
00060 cur_source = *it;
00061 break;
00062 }
00063 if (!cur_source)
00064 {
00065 int len = strlen(s);
00066 cur_source = new char[len + 1];
00067 strcpy(cur_source, s);
00068 source_names.push_back(cur_source);
00069 }
00070 }
00071
00072
00073
00074
00075
00076 void Uc_location::error
00077 (
00078 char *s
00079 )
00080 {
00081 cout << source << ':' << line + 1 << ": " << s << endl;
00082 num_errors++;
00083 }
00084
00085
00086
00087
00088
00089 void Uc_location::yyerror
00090 (
00091 char *s
00092 )
00093 {
00094 cout << cur_source << ':' << cur_line + 1 << ": " << s << endl;
00095 num_errors++;
00096 }