src
Main Page
Namespaces
Classes
Files
File List
File Members
codegen
input_api.cc
Go to the documentation of this file.
1
#include <sstream>
2
3
#include "
src/codegen/input_api.h
"
4
#include "
src/codegen/indent.h
"
5
#include "
src/conf/opt.h
"
6
#include "
src/globals.h
"
7
8
namespace
re2c
9
{
10
11
InputAPI::InputAPI
()
12
: type_ (DEFAULT)
13
{}
14
15
InputAPI::type_t
InputAPI::type
()
const
16
{
17
return
type_;
18
}
19
20
void
InputAPI::set
(
type_t
t)
21
{
22
type_ = t;
23
}
24
25
std::string
InputAPI::expr_peek
()
const
26
{
27
std::string s;
28
switch
(type_)
29
{
30
case
DEFAULT
:
31
s =
"*"
+
opts
->
yycursor
;
32
break
;
33
case
CUSTOM
:
34
s =
opts
->
yypeek
+
" ()"
;
35
break
;
36
}
37
return
s;
38
}
39
40
std::string
InputAPI::expr_peek_save
()
const
41
{
42
return
opts
->
yych
+
" = "
+
opts
.
yychConversion
() +
expr_peek
();
43
}
44
45
std::string
InputAPI::stmt_peek
(uint32_t ind)
const
46
{
47
return
indent
(ind) +
expr_peek_save
() +
";\n"
;
48
}
49
50
std::string
InputAPI::stmt_skip
(uint32_t ind)
const
51
{
52
std::string s;
53
switch
(type_)
54
{
55
case
DEFAULT
:
56
s =
"++"
+
opts
->
yycursor
;
57
break
;
58
case
CUSTOM
:
59
s =
opts
->
yyskip
+
" ()"
;
60
break
;
61
}
62
return
indent
(ind) + s +
";\n"
;
63
}
64
65
std::string
InputAPI::stmt_backup
(uint32_t ind)
const
66
{
67
std::string s;
68
switch
(type_)
69
{
70
case
DEFAULT
:
71
s =
opts
->
yymarker
+
" = "
+
opts
->
yycursor
;
72
break
;
73
case
CUSTOM
:
74
s =
opts
->
yybackup
+
" ()"
;
75
break
;
76
}
77
return
indent
(ind) + s +
";\n"
;
78
}
79
80
std::string
InputAPI::stmt_backupctx
(uint32_t ind)
const
81
{
82
std::string s;
83
switch
(type_)
84
{
85
case
DEFAULT
:
86
s =
opts
->
yyctxmarker
+
" = "
+
opts
->
yycursor
;
87
break
;
88
case
CUSTOM
:
89
s =
opts
->
yybackupctx
+
" ()"
;
90
break
;
91
}
92
return
indent
(ind) + s +
";\n"
;
93
}
94
95
std::string
InputAPI::stmt_restore
(uint32_t ind)
const
96
{
97
std::string s;
98
switch
(type_)
99
{
100
case
DEFAULT
:
101
s =
opts
->
yycursor
+
" = "
+
opts
->
yymarker
;
102
break
;
103
case
CUSTOM
:
104
s =
opts
->
yyrestore
+
" ()"
;
105
break
;
106
}
107
return
indent
(ind) + s +
";\n"
;
108
}
109
110
std::string
InputAPI::stmt_restorectx
(uint32_t ind)
const
111
{
112
std::string s;
113
switch
(type_)
114
{
115
case
DEFAULT
:
116
s =
indent
(ind) +
opts
->
yycursor
+
" = "
+
opts
->
yyctxmarker
+
";\n"
;
117
break
;
118
case
CUSTOM
:
119
s =
indent
(ind) +
opts
->
yyrestorectx
+
" ();\n"
;
120
break
;
121
}
122
return
s;
123
}
124
125
std::string
InputAPI::stmt_skip_peek
(uint32_t ind)
const
126
{
127
return
type_ ==
DEFAULT
128
?
indent
(ind) +
opts
->
yych
+
" = "
+
opts
.
yychConversion
() +
"*++"
+
opts
->
yycursor
+
";\n"
129
:
stmt_skip
(ind) +
stmt_peek
(ind);
130
}
131
132
std::string
InputAPI::stmt_skip_backup
(uint32_t ind)
const
133
{
134
return
type_ ==
DEFAULT
135
?
indent
(ind) +
opts
->
yymarker
+
" = ++"
+
opts
->
yycursor
+
";\n"
136
:
stmt_skip
(ind) +
stmt_backup
(ind);
137
}
138
139
std::string
InputAPI::stmt_backup_peek
(uint32_t ind)
const
140
{
141
return
type_ ==
DEFAULT
142
?
indent
(ind) +
opts
->
yych
+
" = "
+
opts
.
yychConversion
() +
"*("
+
opts
->
yymarker
+
" = "
+
opts
->
yycursor
+
");\n"
143
:
stmt_backup
(ind) +
stmt_peek
(ind);
144
}
145
146
std::string
InputAPI::stmt_skip_backup_peek
(uint32_t ind)
const
147
{
148
return
type_ ==
DEFAULT
149
?
indent
(ind) +
opts
->
yych
+
" = "
+
opts
.
yychConversion
() +
"*("
+
opts
->
yymarker
+
" = ++"
+
opts
->
yycursor
+
");\n"
150
:
stmt_skip
(ind) +
stmt_backup
(ind) +
stmt_peek
(ind);
151
}
152
153
std::string
InputAPI::expr_lessthan_one
()
const
154
{
155
return
type_ ==
DEFAULT
156
?
opts
->
yylimit
+
" <= "
+
opts
->
yycursor
157
:
expr_lessthan
(1);
158
}
159
160
std::string
InputAPI::expr_lessthan
(
size_t
n)
const
161
{
162
std::ostringstream s;
163
switch
(type_)
164
{
165
case
DEFAULT
:
166
s <<
"("
<<
opts
->
yylimit
<<
" - "
<<
opts
->
yycursor
<<
") < "
<< n;
167
break
;
168
case
CUSTOM
:
169
s <<
opts
->
yylessthan
<<
" ("
<< n <<
")"
;
170
break
;
171
}
172
return
s.str ();
173
}
174
175
}
// end namespace re2c
re2c::opt_t::yyrestore
std::string yyrestore
Definition:
opt.h:118
re2c::InputAPI::expr_peek
std::string expr_peek() const
Definition:
input_api.cc:25
re2c::indent
std::string indent(uint32_t ind)
Definition:
indent.h:11
re2c::InputAPI::stmt_restorectx
std::string stmt_restorectx(uint32_t ind) const
Definition:
input_api.cc:110
re2c::opt_t::yyskip
std::string yyskip
Definition:
opt.h:118
re2c::opt_t::yylimit
std::string yylimit
Definition:
opt.h:118
re2c::opt_t::yych
std::string yych
Definition:
opt.h:118
opt.h
re2c::InputAPI::stmt_skip_backup
std::string stmt_skip_backup(uint32_t ind) const
Definition:
input_api.cc:132
re2c::opt_t::yybackup
std::string yybackup
Definition:
opt.h:118
re2c::InputAPI::expr_peek_save
std::string expr_peek_save() const
Definition:
input_api.cc:40
re2c::InputAPI::stmt_restore
std::string stmt_restore(uint32_t ind) const
Definition:
input_api.cc:95
globals.h
re2c::opt_t::yycursor
std::string yycursor
Definition:
opt.h:118
re2c::InputAPI::expr_lessthan_one
std::string expr_lessthan_one() const
Definition:
input_api.cc:153
re2c::opt_t::yylessthan
std::string yylessthan
Definition:
opt.h:118
re2c::InputAPI::stmt_backup_peek
std::string stmt_backup_peek(uint32_t ind) const
Definition:
input_api.cc:139
re2c::Opt::yychConversion
std::string yychConversion()
Definition:
opt.h:193
re2c::opt_t::yypeek
std::string yypeek
Definition:
opt.h:118
re2c::InputAPI::CUSTOM
Definition:
input_api.h:15
re2c::InputAPI::InputAPI
InputAPI()
Definition:
input_api.cc:11
re2c::InputAPI::set
void set(type_t t)
Definition:
input_api.cc:20
re2c::InputAPI::stmt_skip
std::string stmt_skip(uint32_t ind) const
Definition:
input_api.cc:50
re2c::InputAPI::stmt_skip_peek
std::string stmt_skip_peek(uint32_t ind) const
Definition:
input_api.cc:125
re2c::opt_t::yybackupctx
std::string yybackupctx
Definition:
opt.h:118
re2c::InputAPI::stmt_backupctx
std::string stmt_backupctx(uint32_t ind) const
Definition:
input_api.cc:80
re2c::InputAPI::stmt_backup
std::string stmt_backup(uint32_t ind) const
Definition:
input_api.cc:65
re2c::opts
Opt opts
Definition:
opt.cc:7
re2c::InputAPI::type_t
type_t
Definition:
input_api.h:13
re2c::InputAPI::type
type_t type() const
Definition:
input_api.cc:15
re2c::opt_t::yyrestorectx
std::string yyrestorectx
Definition:
opt.h:118
re2c::InputAPI::stmt_peek
std::string stmt_peek(uint32_t ind) const
Definition:
input_api.cc:45
re2c::opt_t::yyctxmarker
std::string yyctxmarker
Definition:
opt.h:118
re2c::opt_t::yymarker
std::string yymarker
Definition:
opt.h:118
re2c::InputAPI::expr_lessthan
std::string expr_lessthan(size_t n) const
Definition:
input_api.cc:160
re2c
Definition:
bitmap.cc:10
input_api.h
indent.h
re2c::InputAPI::stmt_skip_backup_peek
std::string stmt_skip_backup_peek(uint32_t ind) const
Definition:
input_api.cc:146
re2c::InputAPI::DEFAULT
Definition:
input_api.h:14
Generated by
1.8.10