From 40625c16f7573398252ccf040ef49d398d64d5bd Mon Sep 17 00:00:00 2001 From: Alasdair Date: Thu, 13 Aug 2020 11:27:31 +0100 Subject: Preserve file structure through initial check Insert $file_start and $file_end pragmas in the AST, as well as $include_start and $include_end pragmas so we can reconstruct the original file structure later if needed, provided nothing like topological sorting has been done. Have the Lexer produce a list of comments whenever it parses a file, which can the be attached to the nearest nodes in the abstract syntax tree. --- src/splice.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/splice.ml') diff --git a/src/splice.ml b/src/splice.ml index 90488c0a..8ebd5793 100644 --- a/src/splice.ml +++ b/src/splice.ml @@ -40,8 +40,8 @@ let filter_replacements spec_found (Defs defs) = in List.filter not_found defs let splice ast file = - let parsed_ast = Process_file.parse_file file in - let repl_ast = Initial_check.process_ast ~generate:false parsed_ast in + let parsed_ast = Process_file.parse_file file |> snd in + let repl_ast = Initial_check.process_ast ~generate:false (Parse_ast.Defs [(file, parsed_ast)]) in let repl_ast = Rewrites.move_loop_measures repl_ast in let repl_ast = map_defs_annot (fun (l,_) -> l,Type_check.empty_tannot) repl_ast in let repl_ids, repl_specs = scan_defs repl_ast in -- cgit v1.2.3