|
1 /* |
|
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <assert.h> |
|
20 #include <stdio.h> |
|
21 |
|
22 int yylex(); |
|
23 |
|
24 #if defined(__MSVCDOTNET__) || defined(__TOOLS2__) |
|
25 #include <iostream> |
|
26 using std::cout; |
|
27 using std::cerr; |
|
28 using std::endl; |
|
29 #else //!__MSVCDOTNET__ |
|
30 #include <iostream.h> |
|
31 #endif //__MSVCDOTNET__ |
|
32 |
|
33 void yyrestart( FILE *new_file ); |
|
34 extern int yylineno; |
|
35 |
|
36 #include "RCSCAN.H" |
|
37 #include "ERRORHAN.H" |
|
38 #include "MEM.H" |
|
39 #include <stdarg.h> // for va_... used by yyerror |
|
40 #include <stdio.h> // for vsprintf... used by yerror |
|
41 |
|
42 |
|
43 rcscan::rcscan(const FileLineManager& aFileLineHandlerToSet,FILE* aSourceFile): |
|
44 iErrorFound(0), |
|
45 iFileLineHandler(aFileLineHandlerToSet) |
|
46 { |
|
47 yyrestart(aSourceFile); |
|
48 } |
|
49 |
|
50 rcscan& rcscan::operator=(const rcscan& /*scan*/) |
|
51 { |
|
52 assert(0); |
|
53 return *this; |
|
54 } |
|
55 #if defined(__TOOLS2_WINDOWS__) |
|
56 void rcscan::yyerror(char* aCharPtr, __VALIST aList) |
|
57 #else |
|
58 void rcscan::yyerror(char* aCharPtr, va_list aList) |
|
59 #endif |
|
60 { |
|
61 if (yylineno) |
|
62 { |
|
63 MOFF; |
|
64 cerr << iFileLineHandler.GetErrorLine(yylineno) << ") : "; |
|
65 MON; |
|
66 } |
|
67 |
|
68 char buffer[128]; |
|
69 vsprintf(buffer, aCharPtr, aList); |
|
70 |
|
71 cerr << buffer << endl; |
|
72 iErrorFound = 1; |
|
73 } |
|
74 |
|
75 void rcscan::yyerror(char* aCharPtr,...) |
|
76 { |
|
77 if(yylineno) |
|
78 { |
|
79 MOFF; |
|
80 cerr << *iFileLineHandler.GetCurrentFile() << "("; |
|
81 cerr << iFileLineHandler.GetErrorLine(yylineno) << ") : "; |
|
82 MON; |
|
83 } |
|
84 |
|
85 // Format a string that can be sent via the iostream mechanism |
|
86 va_list va; |
|
87 char buffer[128]; |
|
88 va_start(va,aCharPtr); |
|
89 vsprintf(buffer, aCharPtr, va ); |
|
90 va_end(va); |
|
91 |
|
92 cerr << buffer << endl; |
|
93 iErrorFound = 1; |
|
94 } |
|
95 |
|
96 int rcscan::ErrorWasFound() const |
|
97 { |
|
98 return iErrorFound; |
|
99 } |