@@ -42,8 +42,8 @@ def create_serial_parse_function(serial_idx, key, v, tag_name="TagName"):
4242 tag_name = f""" { name } ::kTag """
4343
4444 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",
4747 ParseFunctionInputs(false ,calling_depth(), output.last_token_, output.cur_token_),"""
4848 for idx , s_ in enumerate (v ):
4949 assert isinstance (s_ , str )
@@ -83,6 +83,7 @@ def create_serial_parse_function(serial_idx, key, v, tag_name="TagName"):
8383 comments = comments [:- 2 ]
8484
8585 content_op = f"""
86+ { content_type + ">;" }
8687 { content_func_def } );
8788 static_assert(base::kNumberOfElements == 1);
8889 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):
101102 name = camel_case (k )
102103 tag_name = f""" { name } ::kTag """
103104 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(
106107 false,calling_depth() + 1),"""
107108 for s_ in s_v :
108109 assert isinstance (s_ , str )
@@ -117,7 +118,7 @@ def create_serial_in_parallel_function(s_v, k, flg, idx_str, tidx):
117118 break
118119 contents_type += f""" ParseFunction,"""
119120 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 ,
121122 token::details::TokenKind::{ sp_tokens [s ]} ,
122123 diag::DiagKind::{ k .replace ("-" ,"_" )} _expect_{ sp_tokens [s ]} ),"""
123124
@@ -128,9 +129,10 @@ def create_serial_in_parallel_function(s_v, k, flg, idx_str, tidx):
128129 else :
129130 assert s in gram_tree
130131 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 ),"
132133 contents = contents [:- 1 ]
133134 contents_type = contents_type [:- 1 ]
135+ contents = contents_type + ">" + contents
134136 contents_type += ">,"
135137 contents += "),"
136138 return contents , contents_type , flg
@@ -139,11 +141,11 @@ def create_serial_in_parallel_function(s_v, k, flg, idx_str, tidx):
139141def create_parallel_function_normal (v , k , idx , offset , out_name = "output" , type_recursive = False ):
140142 name = camel_case (k )
141143 tag_name = f""" { name } ::kTag """
142- contents_type = f"""ParallelParseFunctions<{ len (v )} , """
144+ contents_type = f"""ParallelParseFunctions<ParseFunctionKind::k { name } , { len (v )} , """
143145 sub_str = f"""parallel_{ idx } """
144146 if type_recursive :
145147 sub_str = f"""recursive_{ idx } """
146- contents_type = f"""RecursiveParseFunctions<"""
148+ contents_type = f"""RecursiveParseFunctions<ParseFunctionKind::k { name } , """
147149 content_func_def = f"""
148150 parallel_funcs_{ idx } (context_,"{ name } _parallel_{ idx } ",ParseFunctionInputs(false,calling_depth(), output.last_token_,output.cur_token_),
149151 """
@@ -234,10 +236,25 @@ def create_parallel_function(serial_idx, key, v):
234236 """ + "\n }\n " + f"""
235237 diag::infos() << basic::str::from({ tag_name } , "into recursive. \\ n");
236238 { content_r_type } { content_r_func_def }
237- { content_r_op } """ + """
238- if(!output.work_){
239+ { content_r_op } """ + f """
240+ if(!output.work_){{
239241 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+
241258 return output;
242259
243260 """
@@ -458,6 +475,7 @@ class NAME : public ParseFunction<N> { \\
458475 if (!this->valid()) {
459476 return output;
460477 }
478+ auto start_token = output.cur_token_;
461479 ___CONTENT_OP___
462480 }
463481 """
0 commit comments