- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample-2.cpp
More file actions
Latest commit
37 lines (30 loc) · 711 Bytes
/
Copy pathsample-2.cpp
File metadata and controls
37 lines (30 loc) · 711 Bytes
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
#include<iostream>
#include<string>
#include<boost/lexical_cast.hpp>
#include<boost/function.hpp>
#include"peg.hpp"
namespacefusion= boost::fusion;
usingnamespacepeg;
usingnamespacestd;
typedef fusion::vector<digit, rep<alpha>, digit, alpha, digit, eoi> data;
voidtest(const string& s)
{
cout << s << " ---> ";
parser<data> parser;
data v;
if (!parser.parse(v, s.begin(), s.end())) {
cout << "parse error" << endl;
} else {
usingnamespacefusion;
cout << at_c<0>(v) << "(" << at_c<1>(v) << ")" << at_c<2>(v)
<< "(" << at_c<3>(v) << ")" << at_c<4>(v) << endl;
}
}
intmain()
{
test("1hoge2x3");
test("12x3");
test("123");
test("1hoge3");
return0;
}