|
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 "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 * Header LEXICAL.H |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __LEXICAL_H__ |
|
21 #define __LEXICAL_H__ |
|
22 |
|
23 #if defined(__VC32__) && !defined(__MSVCDOTNET__) |
|
24 #pragma warning( disable : 4511 ) // copy constructor could not be generated |
|
25 #pragma warning( disable : 4512 ) // assignment operator could not be generated |
|
26 #pragma warning( disable : 4514 ) // unreferenced inline function has been removed |
|
27 #pragma warning( disable : 4699 ) // Note: Using precompiled header %s |
|
28 #pragma warning( disable : 4710 ) // function not inlined |
|
29 #endif |
|
30 |
|
31 #include "STRNG.H" |
|
32 #include <stdlib.h> |
|
33 |
|
34 #if defined(__VC32__) && !defined(__MSVCDOTNET__) |
|
35 #include <iostream.h> |
|
36 #include <fstream.h> |
|
37 #else //!__VC32__ || __MSVCDOTNET__ |
|
38 #include <iostream> |
|
39 #include <fstream> |
|
40 using namespace std; |
|
41 #endif //!__VC32__ || __MSVCDOTNET__ |
|
42 |
|
43 #include "GDR.H" |
|
44 /** |
|
45 @publishedAll |
|
46 WARNING:Enum for internal use ONLY. Compatibility is not guaranteed in future releases. |
|
47 */ |
|
48 enum LexType |
|
49 { |
|
50 ELexEOF, // end of file |
|
51 ELexNL, // newline (newlines, white-space and comments stripped) |
|
52 ELexNumber, // integer (no optional plus or minus) |
|
53 ELexIdent, // identifier beginning with a..z, A..Z, or _ and continuing with 0..9 |
|
54 ELexString, // string delimited at start by " |
|
55 ELexOperator // any other single character |
|
56 }; |
|
57 |
|
58 class Lexical |
|
59 /** |
|
60 @publishedAll |
|
61 WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. |
|
62 */ |
|
63 { |
|
64 public: |
|
65 Lexical(); |
|
66 Lexical(const Lexical& aLex); |
|
67 Lexical& operator = (const Lexical& aLex); |
|
68 int CovertStringToHex(); |
|
69 private: |
|
70 int HexDigit(char aDigit, int& decimalEquivalent); |
|
71 public: |
|
72 LexType iType; |
|
73 int iNumber; // for ELexNumber |
|
74 char iText[MaxLineLen + 1]; // for ELexIdent, ELexString, ELexOperator |
|
75 friend ostream& operator << (ostream& out, Lexical& aLex); |
|
76 }; |
|
77 |
|
78 class LexAnal |
|
79 /** |
|
80 @publishedAll |
|
81 WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases. |
|
82 */ |
|
83 { |
|
84 public: |
|
85 LexAnal(const char* aFilename); |
|
86 Lexical Read(); // read next lexical into iLex |
|
87 Lexical ReadNextLine(); // read first lex on next line |
|
88 void Report(); |
|
89 ~LexAnal(); |
|
90 public: |
|
91 ifstream iFin; |
|
92 Lexical iLex; |
|
93 int iLineNo; |
|
94 char iLine[MaxLineLen + 1]; |
|
95 char* iLexPtr; // Position in current lexical |
|
96 char* iCurPtr; // Position of current lexical in line |
|
97 private: |
|
98 void GetNextLex(); |
|
99 void GetNextLine(); |
|
100 void PurgeLastCR(char *aLine); |
|
101 Lexical ReadEOF(); |
|
102 Lexical ReadNewLine(); |
|
103 Lexical ReadNumber(); |
|
104 Lexical ReadIdent(); |
|
105 Lexical ReadString(); |
|
106 Lexical ReadOperator(); |
|
107 String iFilename; |
|
108 }; |
|
109 |
|
110 #endif |