@@ -42,8 +42,8 @@ def create_serial_parse_function(serial_idx, key, v, tag_name="TagName"):
42
42
tag_name = f""" { name } ::kTag """
43
43
44
44
content_init = ""
45
- content_type = f"using parse_func_type = SerialParseFunctions<"
46
- content_func_def = f"""SerialParseFunctions serial_funcs(context_,"{ name } _serial",
45
+ content_type = f"using parse_func_type = SerialParseFunctions<ParseFunctionKind::k { name } , "
46
+ content_func_def = f"""parse_func_type serial_funcs(context_,"{ name } _serial",
47
47
ParseFunctionInputs(false ,calling_depth(), output.last_token_, output.cur_token_),"""
48
48
for idx , s_ in enumerate (v ):
49
49
assert isinstance (s_ , str )
@@ -83,6 +83,7 @@ def create_serial_parse_function(serial_idx, key, v, tag_name="TagName"):
83
83
comments = comments [:- 2 ]
84
84
85
85
content_op = f"""
86
+ { content_type + ">;" }
86
87
{ content_func_def } );
87
88
static_assert(base::kNumberOfElements == 1);
88
89
serial_funcs.executed_mask( decltype(serial_funcs)::base::bitset_type(this->executed_mask_.value() ) );
@@ -101,8 +102,8 @@ def create_serial_in_parallel_function(s_v, k, flg, idx_str, tidx):
101
102
name = camel_case (k )
102
103
tag_name = f""" { name } ::kTag """
103
104
assert isinstance (s_v , list )
104
- contents_type = f"SerialParseFunctions<"
105
- contents = f"""SerialParseFunctions (context_, "{ name } _{ idx_str } _serial_{ tidx } ", ParseFunctionInputs(
105
+ contents_type = f"SerialParseFunctions<ParseFunctionKind::k { name } , "
106
+ contents = f"""(context_, "{ name } _{ idx_str } _serial_{ tidx } ", ParseFunctionInputs(
106
107
false,calling_depth() + 1),"""
107
108
for s_ in s_v :
108
109
assert isinstance (s_ , str )
@@ -117,7 +118,7 @@ def create_serial_in_parallel_function(s_v, k, flg, idx_str, tidx):
117
118
break
118
119
contents_type += f""" ParseFunction,"""
119
120
contents += f"""ParseFunction::
120
- create_single_token_check(context_, { opt_str } ,calling_depth() + 2 ,
121
+ create_single_token_check(context_, { opt_str } ,calling_depth() + 1 ,
121
122
token::details::TokenKind::{ sp_tokens [s ]} ,
122
123
diag::DiagKind::{ k .replace ("-" ,"_" )} _expect_{ sp_tokens [s ]} ),"""
123
124
@@ -128,9 +129,10 @@ def create_serial_in_parallel_function(s_v, k, flg, idx_str, tidx):
128
129
else :
129
130
assert s in gram_tree
130
131
contents_type += f"{ camel_case (s )} ,"
131
- contents += f"{ camel_case (s )} (context_, { opt_str } , calling_depth() + 2 ),"
132
+ contents += f"{ camel_case (s )} (context_, { opt_str } , calling_depth() + 1 ),"
132
133
contents = contents [:- 1 ]
133
134
contents_type = contents_type [:- 1 ]
135
+ contents = contents_type + ">" + contents
134
136
contents_type += ">,"
135
137
contents += "),"
136
138
return contents , contents_type , flg
@@ -139,11 +141,11 @@ def create_serial_in_parallel_function(s_v, k, flg, idx_str, tidx):
139
141
def create_parallel_function_normal (v , k , idx , offset , out_name = "output" , type_recursive = False ):
140
142
name = camel_case (k )
141
143
tag_name = f""" { name } ::kTag """
142
- contents_type = f"""ParallelParseFunctions<{ len (v )} , """
144
+ contents_type = f"""ParallelParseFunctions<ParseFunctionKind::k { name } , { len (v )} , """
143
145
sub_str = f"""parallel_{ idx } """
144
146
if type_recursive :
145
147
sub_str = f"""recursive_{ idx } """
146
- contents_type = f"""RecursiveParseFunctions<"""
148
+ contents_type = f"""RecursiveParseFunctions<ParseFunctionKind::k { name } , """
147
149
content_func_def = f"""
148
150
parallel_funcs_{ idx } (context_,"{ name } _parallel_{ idx } ",ParseFunctionInputs(false,calling_depth(), output.last_token_,output.cur_token_),
149
151
"""
@@ -234,10 +236,25 @@ def create_parallel_function(serial_idx, key, v):
234
236
""" + "\n }\n " + f"""
235
237
diag::infos() << basic::str::from({ tag_name } , "into recursive. \\ n");
236
238
{ content_r_type } { content_r_func_def }
237
- { content_r_op } """ + """
238
- if(!output.work_){
239
+ { content_r_op } """ + f """
240
+ if(!output.work_){{
239
241
return non_recursive_output;
240
- }
242
+ }}
243
+ const auto* p_start = &context_->token_lists().at(start_token);
244
+ const auto* p_end = &context_->token_lists().at(output.cur_token_);
245
+ Line line{{
246
+ p_start,
247
+ p_end,
248
+ this->kind(),
249
+ token::details::TokenKind::unknown,
250
+ token::TokenLists::len(p_start, p_end),
251
+ this->calling_depth(),
252
+ Line::segments_type()
253
+ }};
254
+ line.segments_.append(non_recursive_output.line_);
255
+ line.segments_.append(output.line_);
256
+ output.line_ = context_->paint(line);
257
+
241
258
return output;
242
259
243
260
"""
@@ -458,6 +475,7 @@ class NAME : public ParseFunction<N> { \\
458
475
if (!this->valid()) {
459
476
return output;
460
477
}
478
+ auto start_token = output.cur_token_;
461
479
___CONTENT_OP___
462
480
}
463
481
"""
0 commit comments