From e4c81ee70cfa37b4360b2deca355bd125da98365 Mon Sep 17 00:00:00 2001 From: Mark Long Date: Mon, 24 Oct 2016 22:52:58 -0500 Subject: [PATCH] Fixed bug with formatter --- src/applesoftfile/applesoftformatter.cxx | 25 ++++++++++++++++++++---- src/applesoftfile/applesoftformatter.h | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/applesoftfile/applesoftformatter.cxx b/src/applesoftfile/applesoftformatter.cxx index 485ab25..da58564 100644 --- a/src/applesoftfile/applesoftformatter.cxx +++ b/src/applesoftfile/applesoftformatter.cxx @@ -47,13 +47,31 @@ QString ApplesoftFormatter::formatText() firstToken = false; } - //TODO: Move this to the parser... + //TODO: Move this to the parser. + //TODO: This doesn't yet handle: ON expr GOTO/GOSUB n1,n2,n3,... if (previousToken.getTokenId() == ApplesoftToken::ASGoto || previousToken.getTokenId() == ApplesoftToken::ASGosub || previousToken.getTokenId() == ApplesoftToken::ASThen) { - isFlowTarget = true; - m_flowTargets.append(line.linenum); + isFlowTarget = false; + if (previousToken.getTokenId() == ApplesoftToken::ASGoto || + previousToken.getTokenId() == ApplesoftToken::ASGosub) + { + isFlowTarget = true; + } + else if (previousToken.getTokenId() == ApplesoftToken::ASThen && + token.getTokenId() == ApplesoftToken::IntegerTokenVal) + { + isFlowTarget = true; + } + + if (isFlowTarget) + { + QPair pair; + pair.first = line.linenum; + pair.second = token.getWordValue(); + m_flowTargets.append(pair); + } } if (m_format_options.testFlag(ShowIntsAsHex)) { @@ -61,7 +79,6 @@ QString ApplesoftFormatter::formatText() { bool okToConvert = !isFlowTarget; - if (okToConvert) { quint32 ui32val = token.getIntegerValue(); diff --git a/src/applesoftfile/applesoftformatter.h b/src/applesoftfile/applesoftformatter.h index 66111a0..209a12e 100644 --- a/src/applesoftfile/applesoftformatter.h +++ b/src/applesoftfile/applesoftformatter.h @@ -33,6 +33,7 @@ public: QString formatText(); + QList > flowTargets() const { return m_flowTargets; } signals: void newFile(ApplesoftFile *file); @@ -41,7 +42,7 @@ public slots: private: FormatOptions m_format_options; - QList m_flowTargets; + QList > m_flowTargets; ApplesoftFile *m_file;