blob: 180187aa75f73d5b81875d77cc6874450a9ca5dc (
plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
// file : tests/compiler/cxx-indenter/driver.cxx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
#include <fstream>
#include <iostream>
#include <cutl/compiler/code-stream.hxx>
#include <cutl/compiler/cxx-indenter.hxx>
using namespace std;
using namespace cutl::compiler;
int
main ()
{
//std::wostream& os (wcout);
//ostream_filter<cxx_indenter, wchar_t> filt (os);
std::ostream& os (cout);
ostream_filter<cxx_indenter, char> filt (os);
os << "if (true)"
<< "{"
<< "// Hello there" << endl
<< "//" << endl
<< "a ();"
<< "}"
<< "else"
<< "{"
<< "b ();"
<< "}";
os << "if (false)"
<< "{"
<< "if (true)"
<< "{"
<< "// test" << endl
<< "}"
<< "else"
<< "{"
<< "// test" << endl
<< "b ();"
<< "}"
<< "}";
os << "namespace a"
<< "{"
<< "void f ();"
<< "}"
<< "#if defined(__HP_aCC) && __HP_aCC <= 39999" << endl
<< "#include <foo.h>" << endl
<< "#endif" << endl
<< endl
<< "namespace b"
<< "{"
<< "void f ();"
<< "}";
// Test do-while handling.
//
os << "do" << endl
<< "f ();"
<< "while (false);"
<< endl;
os << "do"
<< "{"
<< "f ();"
<< "}"
<< "while (false);"
<< endl;
os << "do"
<< "{"
<< "if (f ())"
<< "{"
<< "g ();"
<< "}"
<< "}"
<< "while (false);"
<< endl;
os << "do"
<< "{"
<< "do" << endl
<< "f ();"
<< "while (false);"
<< "}"
<< "while (false);"
<< endl;
os << "do"
<< "{"
<< "do"
<< "{"
<< "f ();"
<< "}"
<< "while (false);"
<< "}"
<< "while (false);"
<< endl;
os << "{"
<< "f (\"CREATE TABLE \\\"test\\\" (\"" << endl
<< "\"'id',\"" << endl
<< "\"'name')\");"
<< "}";
}
|