]> git.mdlowis.com Git - archive/parse-utils.git/commitdiff
Fixed line and column counting code in lexer
authorMike D. Lowis <mike@mdlowis.com>
Tue, 29 May 2012 16:34:18 +0000 (12:34 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Tue, 29 May 2012 16:34:18 +0000 (12:34 -0400)
source/lexer/ilexer.cpp
source/lexer/llnlexer/llnlexer.cpp

index 66e8645f9658f5467cad88ae1bda4fe495260de8..f3e684c6e6878217c0af925e49c099e671517c36 100644 (file)
@@ -3,7 +3,7 @@
 
 using namespace std;
 
-ILexer::ILexer(istream& in) : line(-1), column(-1), in_stream(in)
+ILexer::ILexer(istream& in) : line(1), column(0), in_stream(in)
 {
 }
 
index 9b265630f4008da9a6731dc2eeb44c0768b9236b..ce26d84a32b90a973149b7d9135e25f6e3090752 100644 (file)
@@ -11,12 +11,23 @@ LLNLexer::~LLNLexer()
 
 void LLNLexer::consume(void)
 {
+    if( la_buffer.at(cur_idx) == '\n' )
+    {
+        line++;
+        column = 0;
+    }
+    else
+    {
+        column++;
+    }
+
     cur_idx++;
     if(cur_idx >= la_buffer.size())
     {
         cur_idx = 0;
         la_buffer.clear();
     }
+
     sync(1);
 }