-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLexicalParser.h
63 lines (59 loc) · 1.48 KB
/
CLexicalParser.h
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
#pragma once
#include "stdafx.h"
#include "IdentType.h"
class CLexicalParser
{
// declaration of classes
public:
struct SymbolInfo
{
std::wstring sym_name;
};
protected:
struct TextCursor
{
TextCursor();
inline void append(size_t);
inline void feed();
inline void reset();
size_t line;
size_t col;
size_t lastCol;
};
public:
CLexicalParser(std::wistream *);
bool Next();
bool MakeErrorMessageInfo(std::wstring& strErrorMessage) const;
// properties:
public:
const SymbolType GetSymbolType() const;
const __int64 GetInteger() const;
const double GetDecimal() const;
const wchar_t * GetSymbol() const;
size_t GetCurrentLineNo() const;
size_t GetCurrentColumnNo() const;
protected:
wchar_t m_curCh;
SymbolType m_curSymbolType;
__int64 m_curSymbolInt;
double m_curSymbolDec;
std::wstring m_wstrCurSymbol;
std::set <std::wstring> m_setReserved;
std::map <wchar_t, SymbolType> m_msSym;
std::map <std::wstring, SymbolType> m_mwSym;
std::wistream *m_isInput;
TextCursor textcur;
TextCursor lastTextCur;
bool m_bInLineComment;
bool m_bInBlockComment;
// helpers
private:
int __replace(std::wstring & strContent, const std::wstring & strReplace, const std::wstring & strDest) const;
inline void insertKeyWords(const std::wstring &, SymbolType);
void _makeError();
inline void resetvalues();
void getnextc();
void putbackCh(wchar_t);
void putbackCur(wchar_t);
void __getnext();
};