-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser.hpp.re
57 lines (43 loc) · 1.53 KB
/
parser.hpp.re
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
#pragma once
#include <cstdio>
#include <string>
struct A {
std::string aaa;
std::string bbb;
};
const char *lex(const char *p, const char *pe, A *a) {
printf("start\n");
const char *YYMARKER;
int s = 0, c = 0;
char yych;
std::string *buf;
/*!types:re2c*/
/*!stags:re2c format = 'const char *@@;'; */
/*!re2c
re2c:define:YYCTYPE = char;
re2c:define:YYCURSOR = p;
re2c:define:YYLIMIT = pe;
re2c:define:YYGETSTATE = "s";
re2c:define:YYGETSTATE:naked = 1;
re2c:define:YYSETSTATE = "s = @@;";
re2c:define:YYSETSTATE:naked = 1;
re2c:define:YYGETCONDITION = "c";
re2c:define:YYGETCONDITION:naked = 1;
re2c:define:YYSETCONDITION = "c = @@;";
re2c:define:YYSETCONDITION:naked = 1;
re2c:define:YYFILL = "void(@@);";
re2c:define:YYFILL:naked = 1;
ws = [ \t\n\r];
<init> ws* "{" { goto yyc_inobject; }
<init> * { printf("err\n"); return p; }
<inobject> "aaa" ws* ":" ws* { buf = &a->aaa; goto yyc_string; }
<inobject> "bbb" ws* ":" ws* { buf = &a->bbb; goto yyc_string; }
<inobject> "}" { return 0; }
<inobject> ws+ { goto yyc_inobject; }
<inobject> * { printf("err: inobject \n"); return p; }
<string> ["] { goto yyc_string_body; }
<string> * { printf("err: string \n"); return p; }
<string_body> ["] { buf = nullptr; goto yyc_inobject; }
<string_body> * { *buf += yych; goto yyc_string_body; }
*/
}