diff libinterp/parse-tree/lex.h @ 27766:0ca7f17de041

use file position object to track line and column info in lexer and parser * filepos.h: New file. * libinterp/parse-tree/module.mk: Update. * lex.h, lex.ll (lexical_feedback::m_filepos): New member variable for tracking file position. (lexical_feedback::m_input_line_number, lexical_feedback::m_current_input_column): Delete. Replace all uses with operations on m_filepos.
author John W. Eaton <jwe@octave.org>
date Mon, 02 Dec 2019 18:20:28 -0600
parents bd80e14f268a
children d6701f835496
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h	Mon Dec 02 15:23:01 2019 -0600
+++ b/libinterp/parse-tree/lex.h	Mon Dec 02 18:20:28 2019 -0600
@@ -31,6 +31,7 @@
 #include <stack>
 
 #include "comment-list.h"
+#include "filepos.h"
 #include "input.h"
 #include "symscope.h"
 #include "token.h"
@@ -286,8 +287,6 @@
         m_reading_script_file (false),
         m_reading_classdef_file (false),
         m_buffer_function_text (false),
-        m_input_line_number (1),
-        m_current_input_column (1),
         m_bracketflag (0),
         m_braceflag (0),
         m_looping (0),
@@ -296,6 +295,7 @@
         m_block_comment_nesting_level (0),
         m_command_arg_paren_count (0),
         m_token_count (0),
+        m_filepos (),
         m_current_input_line (),
         m_comment_text (),
         m_help_text (),
@@ -437,12 +437,6 @@
     // parsing.
     bool m_buffer_function_text;
 
-    // the current input line number.
-    int m_input_line_number;
-
-    // the column of the current token.
-    int m_current_input_column;
-
     // square bracket level count.
     int m_bracketflag;
 
@@ -468,6 +462,9 @@
     // since the last reset.
     size_t m_token_count;
 
+    // The current position in the file (line and column).
+    filepos m_filepos;
+
     // The current line of input.
     std::string m_current_input_line;