File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Original file line number Diff line number Diff line change @@ -898,22 +898,24 @@ def output_templates(self, f):
898
898
# parser_body_fields remembers the fields passed in to the
899
899
# previous call to parser_body. this is used for an awful hack.
900
900
parser_body_fields = ()
901
- def parser_body (prototype , * fields , declarations = '' ):
901
+ def parser_body (
902
+ prototype : str ,
903
+ * fields : str ,
904
+ declarations : str = ''
905
+ ) -> str :
902
906
nonlocal parser_body_fields
903
907
add , output = text_accumulator ()
904
908
add (prototype )
905
909
parser_body_fields = fields
906
910
907
- fields = list (fields )
908
- fields .insert (0 , normalize_snippet ("""
911
+ preamble = normalize_snippet ("""
909
912
{{
910
913
{return_value_declaration}
911
914
{parser_declarations}
912
915
{declarations}
913
916
{initializers}
914
- """ ) + "\n " )
915
- # just imagine--your code is here in the middle
916
- fields .append (normalize_snippet ("""
917
+ """ ) + "\n "
918
+ finale = normalize_snippet ("""
917
919
{modifications}
918
920
{return_value} = {c_basename}_impl({impl_arguments});
919
921
{return_conversion}
@@ -923,8 +925,8 @@ def parser_body(prototype, *fields, declarations=''):
923
925
{cleanup}
924
926
return return_value;
925
927
}}
926
- """ ) )
927
- for field in fields :
928
+ """ )
929
+ for field in preamble , * fields , finale :
928
930
add ('\n ' )
929
931
add (field )
930
932
return linear_format (output (), parser_declarations = declarations )
You can’t perform that action at this time.
0 commit comments