changeset 30202:c2c11605fa7a

save file position info in more parse tree elements * oct-parse.yy (base_parser::make_else_clause): Pass else_tok line and column info to tree_if_clause constructor. (base_parser::finish_function): Pass line and column info to tree_function_def constructor.
author John W. Eaton <jwe@octave.org>
date Wed, 22 Sep 2021 23:13:36 -0400
parents 501fe2c8a880
children 75fb18f0469a
files libinterp/parse-tree/oct-parse.yy
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.yy	Wed Sep 22 23:09:12 2021 -0400
+++ b/libinterp/parse-tree/oct-parse.yy	Wed Sep 22 23:13:36 2021 -0400
@@ -3542,6 +3542,8 @@
   {
     maybe_warn_assign_as_truth_value (expr);
 
+    // Line and column will be set in finish_if_command.
+
     tree_if_clause *t = new tree_if_clause (expr, list);
 
     return new tree_if_command_list (t);
@@ -3604,10 +3606,13 @@
   }
 
   tree_if_clause *
-  base_parser::make_else_clause (token */*else_tok*/, comment_list *lc,
+  base_parser::make_else_clause (token *else_tok, comment_list *lc,
                                  tree_statement_list *list)
   {
-    return new tree_if_clause (list, lc);
+    int l = else_tok->line ();
+    int c = else_tok->column ();
+
+    return new tree_if_clause (list, lc, l, c);
   }
 
   tree_if_command_list *
@@ -4154,7 +4159,7 @@
                 m_lexer.m_buffer_function_text = false;
               }
 
-            retval = new tree_function_def (fcn);
+            retval = new tree_function_def (fcn, l, c);
           }
       }