-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebugPPTokenStream.h
77 lines (61 loc) · 1.4 KB
/
DebugPPTokenStream.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// (C) 2013 CPPGM Foundation. All Rights Reserved. www.cppgm.org
#pragma once
#include "IPPTokenStream.h"
struct DebugPPTokenStream : IPPTokenStream
{
void emit_whitespace_sequence()
{
cout << "whitespace-sequence 0 " << endl;
}
void emit_new_line()
{
cout << "new-line 0 " << endl;
}
void emit_header_name(const string& data)
{
write_token("header-name", data);
}
void emit_identifier(const string& data)
{
write_token("identifier", data);
}
void emit_pp_number(const string& data)
{
write_token("pp-number", data);
}
void emit_character_literal(const string& data)
{
write_token("character-literal", data);
}
void emit_user_defined_character_literal(const string& data)
{
write_token("user-defined-character-literal", data);
}
void emit_string_literal(const string& data)
{
write_token("string-literal", data);
}
void emit_user_defined_string_literal(const string& data)
{
write_token("user-defined-string-literal", data);
}
void emit_preprocessing_op_or_punc(const string& data)
{
write_token("preprocessing-op-or-punc", data);
}
void emit_non_whitespace_char(const string& data)
{
write_token("non-whitespace-character", data);
}
void emit_eof()
{
cout << "eof" << endl;
}
private:
void write_token(const string& type, const string& data)
{
cout << type << " " << data.size() << " ";
cout.write(data.data(), data.size());
cout << endl;
}
};