MimIR
0.1
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
print.cpp
Go to the documentation of this file.
1
#include "
mim/util/print.h
"
2
3
namespace
mim
{
4
5
std::ostream&
print
(std::ostream& os,
const
char
* s) {
6
while
(*s) {
7
auto
next = s + 1;
8
9
switch
(*s) {
10
case
'{'
:
11
if
(detail::match2nd(os, next, s,
'{'
))
continue
;
12
while
(*s && *s !=
'}'
) s++;
13
assert(*s !=
'}'
&&
"invalid format string for 'streamf': missing argument(s)"
);
14
fe::unreachable();
15
break
;
16
case
'}'
:
17
if
(detail::match2nd(os, next, s,
'}'
))
continue
;
18
assert(
false
&&
"unmatched/unescaped closing brace '}' in format string"
);
19
fe::unreachable();
20
default
: os << *s++;
21
}
22
}
23
return
os;
24
}
25
26
namespace
detail {
27
28
bool
match2nd(std::ostream& os,
const
char
* next,
const
char
*& s,
const
char
c) {
29
if
(*next == c) {
30
os << c;
31
s += 2;
32
return
true
;
33
}
34
return
false
;
35
}
36
37
}
// namespace detail
38
39
}
// namespace mim
mim
Definition
cfg.h:11
mim::print
std::ostream & print(std::ostream &os, const char *s)
Base case.
Definition
print.cpp:5
print.h
src
mim
util
print.cpp
Generated by
1.12.0