From da2da43ea7b26c55a3e7013b525c454caf43d4ac Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 30 Oct 2019 07:39:28 +0000 Subject: [PATCH] Core: Fixed column info in CParser git-svn-id: svn://ultimatepp.org/upp/trunk@13661 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Parser.h | 2 +- uppsrc/Core/parser.cpp | 18 ++++++++++++++---- uppsrc/Core/src.tpp/CParser_en-us.tpp | 8 ++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/uppsrc/Core/Parser.h b/uppsrc/Core/Parser.h index 8bf0c33d9..084697e5d 100644 --- a/uppsrc/Core/Parser.h +++ b/uppsrc/Core/Parser.h @@ -93,7 +93,7 @@ public: operator bool() const { return *term; } int GetLine() const { return line; } - int GetColumn(int tabsize) const; + int GetColumn(int tabsize = 4) const; String GetFileName() const { return fn; } static String LineInfoComment(const String& filename, int line = 1, int column = 1); diff --git a/uppsrc/Core/parser.cpp b/uppsrc/Core/parser.cpp index 44ca87baa..03b197350 100644 --- a/uppsrc/Core/parser.cpp +++ b/uppsrc/Core/parser.cpp @@ -83,7 +83,10 @@ bool CParser::Spaces0() { else if(term[0] == '/' && term[1] == '*') count++; - if(*term++ == '\n') line++; + if(*term++ == '\n') { + line++; + lineptr = term; + } } } else { @@ -93,7 +96,10 @@ bool CParser::Spaces0() { term += 2; break; } - if(*term++ == '\n') line++; + if(*term++ == '\n') { + line++; + lineptr = term; + } } } } @@ -481,8 +487,10 @@ String CParser::ReadString(bool chkend) char CParser::GetChar() { char c = *term++; - if(c == '\n') + if(c == '\n') { line++; + lineptr = term; + } return c; } @@ -504,8 +512,10 @@ void CParser::SkipTerm() ReadString('\'', false); else if(*term) { - if(*term == '\n') + if(*term == '\n') { line++; + lineptr = term + 1; + } term++; } DoSpaces(); diff --git a/uppsrc/Core/src.tpp/CParser_en-us.tpp b/uppsrc/Core/src.tpp/CParser_en-us.tpp index c71f45c9b..59606b930 100644 --- a/uppsrc/Core/src.tpp/CParser_en-us.tpp +++ b/uppsrc/Core/src.tpp/CParser_en-us.tpp @@ -1,5 +1,4 @@ topic "CParser"; -[2 $$0,0#00000000000000000000000000000000:Default] [i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] [l288;2 $$2,0#27521748481378242620020725143825:desc] [0 $$3,0#96390100711032703541132217272105:end] @@ -9,6 +8,7 @@ topic "CParser"; [l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] [i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] [b42;2 $$9,9#13035079074754324216151401829390:normal] +[2 $$0,0#00000000000000000000000000000000:Default] [{_} [ {{10000@(113.42.0) [s0;%% [*@7;4 CParser]]}}&] [s3; &] @@ -392,7 +392,7 @@ a different [* CParser].&] [s3; &] [s4; &] [s5;:CParser`:`:GetColumn`(int`)const: [@(0.0.255) int]_[* GetColumn]([@(0.0.255) int]_[*@3 t -absize])_[@(0.0.255) const]&] +absize]_`=_[@3 4])_[@(0.0.255) const]&] [s2;%% Returns the current column, with given [%-*@3 tabsize].&] [s3;%% &] [s4; &] @@ -410,8 +410,8 @@ t]&] CParser, switches filename and line number. This is supposed to help in situations when parsed text is actually a result of e.g. include operations of some original files, to improve error -reporting. Not that such comment is lexically treated as comment. -Comment is created using LINEINFO`_ESC characters begin/end delimiter +reporting. Such comment is lexically treated as comment. Comment +is created using LINEINFO`_ESC characters begin/end delimiter (current value is `'`\2`').&] [s3;%% &] [s4; &]