-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.cpp
More file actions
42 lines (41 loc) · 1.18 KB
/
example.cpp
File metadata and controls
42 lines (41 loc) · 1.18 KB
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
#include <bits/stdc++.h>
using namespace std;
#include "regex.h"
int main() {
Lexer lexer;
string src;
cin >> src;
lexer.feed("[0-9][0-9]*",
[&](string raw) {
printf("match number: %s\n", raw.c_str());
})
.feed("[_a-zA-Z][_a-zA-Z0-9]*",
[&](string raw) {
printf("match identify: %s\n", raw.c_str());
})
.feed("\\:\\=",
[&](string raw) {
printf("match assign: %s\n", raw.c_str());
})
.feed("\\<\\=",
[&](string raw) {
printf("match <=\n");
})
.feed("\\>\\=",
[&](string raw) {
printf("match >=\n");
})
.feed("[!?:;.,#<=>+-\\*/\\(\\)]",
[&](string raw) {
printf("match symbol: %s\n", raw.c_str());
})
.feed("\\{[\f\n\r\t\v -z|~]*\\}",
[&](string raw) {
printf("match annotation: %s\n", raw.c_str());
})
.feed("[ \f\n\r\t\v][ \f\n\r\t\v]*",
[&](string raw) {
printf("just space\n");
})
.match(src);
}