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/parser.mly | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/parser.mly') diff --git a/src/parser.mly b/src/parser.mly index 70f6f225..6c90e463 100644 --- a/src/parser.mly +++ b/src/parser.mly @@ -224,7 +224,7 @@ let rec desugar_rchain chain s e = %type typ_eof %type exp_eof %type def_eof -%type file +%type file %% @@ -1480,18 +1480,14 @@ defs_list: | def { [$1] } | def defs_list - { $1::$2 } + { $1 :: $2 } def_eof: | def Eof { $1 } -defs: - | defs_list - { (Defs $1) } - file: - | defs Eof + | defs_list Eof { $1 } | Eof - { (Defs []) } + { [] } -- cgit v1.2.3