Modernized some code, cleaned up inline initialization, and moved from QVector to QList

This commit is contained in:
Mark Long
2025-09-28 20:22:05 -05:00
parent 6a7e81b6b8
commit 961cf6e8fd
28 changed files with 436 additions and 481 deletions
+9 -7
View File
@@ -1,4 +1,7 @@
#include "ApplesoftFile.h"
#include "ApplesoftLine.h"
#include "ApplesoftToken.h"
#include "ApplesoftRetokenizer.h"
#include "Util.h"
#include <QDebug>
@@ -6,10 +9,10 @@
#include <QRegularExpressionMatch>
#include <QRegularExpressionMatchIterator>
#include <QList>
#include <QPair>
ApplesoftFile::ApplesoftFile(QByteArray data) : GenericFile(data)
{
m_retokenizer = Q_NULLPTR;
m_data_end = data.length();
if (!data.isEmpty())
@@ -23,8 +26,7 @@ void ApplesoftFile::setData(QByteArray data)
{
if (!m_retokenizer)
{
m_retokenizer = new ApplesoftRetokenizer();
}
m_retokenizer = std::make_unique<ApplesoftRetokenizer>(); }
GenericFile::setData(data);
@@ -41,7 +43,7 @@ void ApplesoftFile::setData(QByteArray data)
m_flowTargets = m_retokenizer->getFlowTargets();
}
QByteArray ApplesoftFile::rawData() {
QByteArray ApplesoftFile::rawData() const {
QByteArray retval;
retval.append(m_length % 255);
retval.append(m_length / 255);
@@ -49,12 +51,12 @@ QByteArray ApplesoftFile::rawData() {
return retval;
}
QStringList ApplesoftFile::extraDataHexValues() {
QStringList ApplesoftFile::extraDataHexValues() const {
QStringList retval;
QString debugline = "";
int count = 0;
foreach (quint8 val, extraData()) {
for (const auto& val : extraData()) {
debugline.append(QString("%1").arg(val,2,16,QChar('0')).toUpper());
count++;
if (count == 16) {
@@ -71,7 +73,7 @@ QStringList ApplesoftFile::extraDataHexValues() {
return retval;
}
QByteArray ApplesoftFile::extraData()
QByteArray ApplesoftFile::extraData() const
{
return m_data.mid(m_data_end);
}
+18 -16
View File
@@ -1,38 +1,40 @@
#pragma once
#include "ApplesoftLine.h"
#include "GenericFile.h"
#include "ApplesoftToken.h"
#include "ApplesoftRetokenizer.h"
#include "ApplesoftLine.h"
#include <QByteArray>
#include <QStringList>
#include <QMap>
#include <QVector>
#include <QList>
#include <memory>
class ApplesoftToken;
class ApplesoftRetokenizer;
class ApplesoftFile : public GenericFile
{
public:
ApplesoftFile(QByteArray data = QByteArray());
explicit ApplesoftFile(QByteArray data = {});
~ApplesoftFile() override = default;
void setData(QByteArray data);
QByteArray extraData();
QStringList extraDataHexValues();
QByteArray extraData() const;
QStringList extraDataHexValues() const;
QVector<ApplesoftLine> getLines() const { return m_lines; }
const QList<ApplesoftLine>& getLines() const { return m_lines; }
quint16 length() const { return m_length; }
QByteArray rawData();
QByteArray rawData() const;
private:
QVector<ApplesoftLine> m_lines;
int m_data_end;
quint16 m_length;
QList<ApplesoftLine> m_lines;
int m_data_end{0};
quint16 m_length{0};
ApplesoftRetokenizer *m_retokenizer;
QList<QPair<quint16, quint16> > m_flowTargets;
std::unique_ptr<ApplesoftRetokenizer> m_retokenizer{nullptr};
QList<QPair<quint16, quint16>> m_flowTargets;
};
+6 -4
View File
@@ -1,8 +1,10 @@
#include "ApplesoftFormatter.h"
#include "ApplesoftFile.h"
#include "Util.h"
#include <QTextCursor>
#include <QTextCharFormat>
#include <QTextDocument>
#include <QChar>
#define HEXPREFIX "0x"
@@ -10,7 +12,7 @@
ApplesoftFormatter::ApplesoftFormatter(QObject *parent) :
QObject(parent)
{
m_file = Q_NULLPTR;
m_file = nullptr;
}
void ApplesoftFormatter::setFile(ApplesoftFile *file)
@@ -29,7 +31,7 @@ void ApplesoftFormatter::formatDocument(QTextDocument *doc)
bool synhl = (m_format_options.testFlag(SyntaxHighlighting));
foreach (ApplesoftLine line, m_file->getLines())
for (const auto& line : m_file->getLines())
{
QString linestring = QString("%1 ").arg(line.linenum,5,10,QChar(' '));
@@ -43,7 +45,7 @@ void ApplesoftFormatter::formatDocument(QTextDocument *doc)
cursor.insertText(linestring,ApplesoftToken::defaultTextFormat());
}
QVectorIterator<ApplesoftToken>tokenIt(line.tokens);
QListIterator<ApplesoftToken> tokenIt(line.tokens);
bool isBranchTarget = false;
while (tokenIt.hasNext())
{
@@ -146,7 +148,7 @@ void ApplesoftFormatter::formatDocument(QTextDocument *doc)
ApplesoftToken::ControlCharTokenVal);
foreach (QChar ch, tokenstr)
for (const auto& ch : tokenstr)
{
if (ch == QChar(0x7f))
{
+12 -14
View File
@@ -1,26 +1,28 @@
#pragma once
#include "ApplesoftFile.h"
#include <QObject>
#include <QFlags>
#include <QTextDocument>
#include <QSharedPointer>
#include "ApplesoftFile.h"
#include "ApplesoftToken.h"
// Forward declarations
class QTextDocument;
class ApplesoftFormatter : public QObject
{
Q_OBJECT
public:
enum FormatOption {
NoOptions = 0x00,
enum FormatOption
{
NoOptions = 0x00,
SyntaxHighlighting = 0x01,
ShowCtrlChars = 0x02,
BreakAfterReturn = 0x04,
ReindentCode = 0x08,
ShowIntsAsHex = 0x10,
ShowCtrlChars = 0x02,
BreakAfterReturn = 0x04,
ReindentCode = 0x08,
ShowIntsAsHex = 0x10,
AllFlags = 0xffffffff
};
@@ -42,11 +44,7 @@ public slots:
private:
FormatOptions m_format_options;
ApplesoftFile *m_file;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(ApplesoftFormatter::FormatOptions)
+5 -5
View File
@@ -1,15 +1,15 @@
#pragma once
#include <QtGlobal>
#include <QVector>
#include <QList>
class ApplesoftToken;
struct ApplesoftLine {
qint16 address;
quint16 next_address;
quint16 linenum;
QVector<ApplesoftToken> tokens;
qint16 address{0};
quint16 next_address{0};
quint16 linenum{0};
QList<ApplesoftToken> tokens;
};
+6 -5
View File
@@ -1,9 +1,11 @@
#include "ApplesoftRetokenizer.h"
#include "ApplesoftLine.h"
#include "ApplesoftToken.h"
#include "Util.h"
#include <QDebug>
#include <QRegularExpression>
#include <QPair>
ApplesoftRetokenizer::ApplesoftRetokenizer()
{
@@ -25,7 +27,6 @@ void ApplesoftRetokenizer::parse(quint16 start_address)
return;
}
//TODO: This could be changed to search for hidden space between applesoft lines
int idx = 0;
quint8 val = 0;
m_retokenized_lines.clear();
@@ -69,16 +70,16 @@ void ApplesoftRetokenizer::parse(quint16 start_address)
void ApplesoftRetokenizer::retokenizeLinesForFormatting()
{
QVector<ApplesoftLine> retLines;
QList<ApplesoftLine> retLines;
foreach(ApplesoftLine line, m_retokenized_lines)
for (ApplesoftLine line : m_retokenized_lines)
{
int indentlevel = 1;
// quint16 linenum = line.linenum;
bool firstToken = true;
ApplesoftToken previousToken;
QMutableVectorIterator<ApplesoftToken> tokenIt(line.tokens);
QMutableListIterator<ApplesoftToken> tokenIt(line.tokens);
while (tokenIt.hasNext())
{
ApplesoftToken token = tokenIt.next();
@@ -426,7 +427,7 @@ QList<ApplesoftToken> ApplesoftRetokenizer::retokenizeNumbers(QList<ApplesoftTok
QString parsestring;
// Parse the tokens to find assist
for (int idx = 0; idx < tmptokens.count();idx++)
for (int idx = 0; idx < tmptokens.size();idx++)
{
token = tmptokens.at(idx);
+6 -6
View File
@@ -3,10 +3,11 @@
#include "ApplesoftLine.h"
#include <QByteArray>
#include <QVector>
#include <QList>
#include <QPair>
class ApplesoftToken;
class ApplesoftRetokenizer
{
public:
@@ -17,14 +18,13 @@ public:
quint16 getEndOfDataOffset() const { return m_data_end; }
QVector<ApplesoftLine> getRetokenizedLines() { return m_retokenized_lines; }
QList<ApplesoftLine> getRetokenizedLines() { return m_retokenized_lines; }
QList<QPair<quint16, quint16> > getFlowTargets() const { return m_flowTargets; }
private:
void retokenizeLinesForFormatting();
void retokenizeLine(ApplesoftLine &line);
QList<ApplesoftToken> retokenizeRems(QList<ApplesoftToken> &datatokens);
QList<ApplesoftToken> retokenizeStrings(QList<ApplesoftToken> &datatokens);
@@ -35,12 +35,12 @@ private:
QList<ApplesoftToken> retokenizeNegativeNumbers(QList<ApplesoftToken> &datatokens);
QVector<ApplesoftLine> m_retokenized_lines;
QList<ApplesoftLine> m_retokenized_lines;
QByteArray m_data;
quint16 m_data_end;
quint16 m_data_end{0};
bool m_isParsed;
bool m_isParsed{false};
QList<QPair<quint16, quint16> > m_flowTargets;
+69 -214
View File
@@ -1,22 +1,17 @@
#include "ApplesoftToken.h"
QMap<quint16, QString> ApplesoftToken::m_tokens = QMap<quint16, QString>();
ApplesoftToken::ApplesoftToken()
{
if (m_tokens.size() == 0) { initializeTokenTable(); }
setTokenId(DefaultTokenVal);
}
ApplesoftToken::ApplesoftToken(quint16 id)
{
if (m_tokens.size() == 0) { initializeTokenTable(); }
setTokenId(id);
}
ApplesoftToken::ApplesoftToken(quint16 id, QVariant payload)
{
if (m_tokens.size() == 0) { initializeTokenTable(); }
setTokenId(id);
setValue(payload);
}
@@ -24,65 +19,65 @@ ApplesoftToken::ApplesoftToken(quint16 id, QVariant payload)
void ApplesoftToken::setTokenId(quint16 id)
{
m_token_id = id;
m_token_type = UNKNOWN_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::Unknown;
m_command_type = CommandType::None;
if (id <= 0x7f) {
if (id <= MaxAsciiChar) {
setValue(id);
m_token_type = ASCIICHAR_TOKEN;
m_command_type = NONE;
} else if (id <= 0xC7) {
m_token_type = TokenType::AsciiChar;
m_command_type = CommandType::None;
} else if (id <= MaxApplesoftCommand) {
setValue(id);
m_token_type = APPLESOFT_TOKEN;
m_command_type = COMMAND;
} else if (id <= 0xD1) {
m_token_type = TokenType::ApplesoftToken;
m_command_type = CommandType::Command;
} else if (id <= MaxApplesoftOperator) {
setValue(id);
m_token_type = APPLESOFT_TOKEN;
m_command_type = OPERATOR;
} else if (id <= 0xEA) {
m_token_type = TokenType::ApplesoftToken;
m_command_type = CommandType::Operator;
} else if (id <= MaxApplesoftFunction) {
setValue(id);
m_token_type = APPLESOFT_TOKEN;
m_command_type = FUNCTION;
} else if (id <= 0xFF) {
m_token_type = TokenType::ApplesoftToken;
m_command_type = CommandType::Function;
} else if (id <= MaxApplesoftToken) {
setValue(id);
m_token_type = UNDEFINED_APPLESOFT_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::UndefinedApplesoft;
m_command_type = CommandType::None;
} else if (id == StringTokenVal) {
m_token_type = STRING_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::String;
m_command_type = CommandType::None;
} else if (id == RemStringTokenVal) {
m_token_type = REM_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::Rem;
m_command_type = CommandType::None;
} else if (id == DataStringTokenVal) {
m_token_type = DATASTRING_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::DataString;
m_command_type = CommandType::None;
} else if (id == IntegerTokenVal) {
m_token_type = INTEGER_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::Integer;
m_command_type = CommandType::None;
} else if (id == FloatTokenVal) {
m_token_type = FLOAT_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::Float;
m_command_type = CommandType::None;
} else if (id == IntVarTokenVal) {
m_token_type = INT_VARIABLE_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::IntVariable;
m_command_type = CommandType::None;
} else if (id == IntAryVarTokenVal) {
m_token_type = INT_ARY_VARIABLE_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::IntAryVariable;
m_command_type = CommandType::None;
} else if (id == FloatVarTokenVal) {
m_token_type = FLOAT_VARIABLE_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::FloatVariable;
m_command_type = CommandType::None;
} else if (id == FloatAryVarTokenVal) {
m_token_type = FLOAT_ARY_VARIABLE_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::FloatAryVariable;
m_command_type = CommandType::None;
} else if (id == StringVarTokenVal) {
m_token_type = STRING_VARIABLE_TOKEN;
m_command_type = NONE;
m_token_type = TokenType::StringVariable;
m_command_type = CommandType::None;
} else if (id == StringAryVarTokenVal) {
m_token_type = STRING_ARY_VARIABLE_TOKEN;
m_command_type = NONE;
} else if (id >= 0xe000 && id < 0xf000) {
m_token_type = OPTIONAL_FORMAT_TOKEN;
m_command_type = OPTIONAL_FORMAT;
m_token_type = TokenType::StringAryVariable;
m_command_type = CommandType::None;
} else if (id >= OptFmtRangeStart && id < OptFmtRangeEnd) {
m_token_type = TokenType::OptionalFormat;
m_command_type = CommandType::OptionalFormat;
}
}
@@ -91,17 +86,37 @@ void ApplesoftToken::setValue(QVariant value)
m_payload = value;
}
QString ApplesoftToken::getStringValue() const
{
QString str = m_payload.toString();
// Remove trailing NUL character if present
if (!str.isEmpty() && str.back() == QChar(0)) {
str.chop(1);
}
return str;
}
QTextCharFormat ApplesoftToken::textFormat()
{
return textFormat(m_token_id);
}
QString ApplesoftToken::getStringForToken(quint8 token)
{
return m_tokens.value(token);
}
QString ApplesoftToken::getRawPrintableString() const
{
if (m_token_id == DefaultTokenVal) {
return "";
} else if (m_token_id == 0x00) {
} else if (m_token_id == NullChar) {
return "";
} else if (m_token_id <= 0x7f) {
return QString((m_token_id));
} else if (m_token_id <= 0xff) {
} else if (m_token_id <= MaxAsciiChar) {
return QString(static_cast<char>(m_token_id));
} else if (m_token_id <= MaxApplesoftToken) {
return m_tokens[m_token_id];
} else if (m_token_id == StringTokenVal) {
return getStringValue();
@@ -125,7 +140,7 @@ QString ApplesoftToken::getRawPrintableString() const
return getStringValue();
} else if (m_token_id == StringAryVarTokenVal) {
return getStringValue();
} else if (m_token_id >= 0xe000 && m_token_id < 0xf000) {
} else if (m_token_id >= OptFmtRangeStart && m_token_id < OptFmtRangeEnd) {
return "";
} else {
return "[temp undefined]";
@@ -151,11 +166,11 @@ QTextCharFormat ApplesoftToken::textFormat(quint16 tokenType)
{
QTextCharFormat tf = defaultTextFormat();
if (tokenType < 0x80) // Ascii
if (tokenType < MaxAsciiChar + 1) // Ascii
{
tf.setForeground(Qt::black);
}
else if (tokenType < 0x100) // Applesoft Tokens
else if (tokenType < StringTokenVal) // Applesoft Tokens
{
tf.setForeground(Qt::black);
}
@@ -198,163 +213,3 @@ QTextCharFormat ApplesoftToken::textFormat(quint16 tokenType)
return tf;
}
void ApplesoftToken::makeTextCharFormats()
{
// TCFDefault,
// TCFCtrlChar,
// TCFAscii,
// TCFFunction,
// TCFOperator,
// TCFUnusedToken,
// TCFNumber,
// TCFString,
// TCFVariable,
// TCFDataString,
// TCFRemString,
// TCFUnknown
}
void ApplesoftToken::initializeTokenTable()
{
m_tokens[ASEnd] = " END "; m_tokens[ASFor] = " FOR ";
m_tokens[ASNext] = " NEXT "; m_tokens[ASData] = " DATA ";
m_tokens[ASInput] = " INPUT "; m_tokens[ASDel] = " DEL ";
m_tokens[ASDim] = " DIM "; m_tokens[ASRead] = " READ ";
m_tokens[ASGr] = " GR "; m_tokens[ASText] = " TEXT ";
m_tokens[ASPr] = " PR# "; m_tokens[ASIn] = " IN# ";
m_tokens[ASCall] = " CALL "; m_tokens[ASPlot] = " PLOT ";
m_tokens[ASHlin] = " HLIN "; m_tokens[ASVlin] = " VLIN ";
m_tokens[ASHgr2] = " HGR2 "; m_tokens[ASHgr] = " HGR ";
m_tokens[ASHcolor] = " HCOLOR= "; m_tokens[ASHplot] = " HPLOT ";
m_tokens[ASDraw] = " DRAW "; m_tokens[ASXdraw] = " XDRAW ";
m_tokens[ASHtab] = " HTAB "; m_tokens[ASHome] = " HOME ";
m_tokens[ASRot] = " ROT= "; m_tokens[ASScale] = " SCALE= ";
m_tokens[ASShload] = " SHLOAD "; m_tokens[ASTrace] = " TRACE ";
m_tokens[ASNotrace] = " NOTRACE "; m_tokens[ASNormal] = " NORMAL ";
m_tokens[ASInverse] = " INVERSE "; m_tokens[ASFlash] = " FLASH ";
m_tokens[ASColor] = " COLOR= "; m_tokens[ASPop] = " POP ";
m_tokens[ASVtab] = " VTAB "; m_tokens[ASHimem] = " HIMEM: ";
m_tokens[ASLomem] = " LOMEM: "; m_tokens[ASOnerr] = " ONERR ";
m_tokens[ASResume] = " RESUME "; m_tokens[ASRecall] = " RECALL ";
m_tokens[ASStore] = " STORE "; m_tokens[ASSpeed] = " SPEED= ";
m_tokens[ASLet] = " LET "; m_tokens[ASGoto] = " GOTO ";
m_tokens[ASRun] = " RUN "; m_tokens[ASIf] = " IF ";
m_tokens[ASRestore] = " RESTORE "; m_tokens[ASAMP] = " & ";
m_tokens[ASGosub] = " GOSUB "; m_tokens[ASReturn] = " RETURN ";
m_tokens[ASRem] = " REM "; m_tokens[ASStop] = " STOP ";
m_tokens[ASOn] = " ON "; m_tokens[ASWait] = " WAIT ";
m_tokens[ASLoad] = " LOAD "; m_tokens[ASSave] = " SAVE ";
m_tokens[ASDef] = " DEF "; m_tokens[ASPoke] = " POKE ";
m_tokens[ASPrint] = " PRINT "; m_tokens[ASCont] = " CONT ";
m_tokens[ASList] = " LIST "; m_tokens[ASClear] = " CLEAR ";
m_tokens[ASGet] = " GET "; m_tokens[ASNew] = " NEW ";
m_tokens[ASTab] = " TAB("; m_tokens[ASTo] = " TO ";
m_tokens[ASFn] = " FN "; m_tokens[ASSpc] = " SPC( ";
m_tokens[ASThen] = " THEN "; m_tokens[ASAt] = " AT ";
m_tokens[ASNot] = " NOT "; m_tokens[ASStep] = " STEP ";
m_tokens[ASPLUS] = " + "; m_tokens[ASMINUS] = " - ";
m_tokens[ASASTERISK] = " * "; m_tokens[ASSLASH] = " / ";
m_tokens[ASCARET] = " ^ "; m_tokens[ASAnd] = " AND ";
m_tokens[ASOr] = " OR "; m_tokens[ASGREATER] = " > ";
m_tokens[ASEQUAL] = " = "; m_tokens[ASLESS] = " < ";
m_tokens[ASSgn] = " SGN"; m_tokens[ASInt] = " INT";
m_tokens[ASAbs] = " ABS"; m_tokens[ASUsr] = " USR";
m_tokens[ASFre] = " FRE"; m_tokens[ASScrn] = " SCRN( ";
m_tokens[ASPdl] = " PDL"; m_tokens[ASPos] = " POS";
m_tokens[ASSqr] = " SQR"; m_tokens[ASRnd] = " RND";
m_tokens[ASLog] = " LOG"; m_tokens[ASExp] = " EXP";
m_tokens[ASCos] = " COS"; m_tokens[ASSin] = " SIN";
m_tokens[ASTan] = " TAN"; m_tokens[ASAtn] = " ATN";
m_tokens[ASPeek] = " PEEK"; m_tokens[ASLen] = " LEN";
m_tokens[ASStr] = " STR$"; m_tokens[ASVal] = " VAL";
m_tokens[ASAsc] = " ASC"; m_tokens[ASChr] = " CHR$";
m_tokens[ASLeft] = " LEFT$ "; m_tokens[ASRight] = " RIGHT$ ";
m_tokens[ASMid] = " MID$ ";
m_tokens[AS_EB] = "{Token 0xEB} "; m_tokens[AS_EC] = "{Token 0xEC} ";
m_tokens[AS_ED] = "{Token 0xED} "; m_tokens[AS_EE] = "{Token 0xEE} ";
m_tokens[AS_EF] = "{Token 0xEF} "; m_tokens[AS_F0] = "{Token 0xF0} ";
m_tokens[AS_F1] = "{Token 0xF1} "; m_tokens[AS_F2] = "{Token 0xF2} ";
m_tokens[AS_F3] = "{Token 0xF3} "; m_tokens[AS_F4] = "{Token 0xF4} ";
m_tokens[AS_F5] = "{Token 0xF5} "; m_tokens[AS_F6] = "{Token 0xF6} ";
m_tokens[AS_F7] = "{Token 0xF7} "; m_tokens[AS_F8] = "{Token 0xF8} ";
m_tokens[AS_F9] = "{Token 0xF9} "; m_tokens[AS_FA] = "{Token 0xFA} ";
m_tokens[AS_FB] = "{Token 0xFB} "; m_tokens[AS_FC] = "{Token 0xFC} ";
m_tokens[AS_FD] = "{Token 0xFD} "; m_tokens[AS_FE] = "{Token 0xFE} ";
m_tokens[AS_FF] = "{Token 0xFF} ";
}
const quint16 ApplesoftToken::ASEnd = 0x80; const quint16 ApplesoftToken::ASFor = 0x81;
const quint16 ApplesoftToken::ASNext = 0x82; const quint16 ApplesoftToken::ASData = 0x83;
const quint16 ApplesoftToken::ASInput = 0x84; const quint16 ApplesoftToken::ASDel = 0x85;
const quint16 ApplesoftToken::ASDim = 0x86; const quint16 ApplesoftToken::ASRead = 0x87;
const quint16 ApplesoftToken::ASGr = 0x88; const quint16 ApplesoftToken::ASText = 0x89;
const quint16 ApplesoftToken::ASPr = 0x8A; const quint16 ApplesoftToken::ASIn = 0x8B;
const quint16 ApplesoftToken::ASCall = 0x8C; const quint16 ApplesoftToken::ASPlot = 0x8D;
const quint16 ApplesoftToken::ASHlin = 0x8E; const quint16 ApplesoftToken::ASVlin = 0x8F;
const quint16 ApplesoftToken::ASHgr2 = 0x90; const quint16 ApplesoftToken::ASHgr = 0x91;
const quint16 ApplesoftToken::ASHcolor = 0x92; const quint16 ApplesoftToken::ASHplot = 0x93;
const quint16 ApplesoftToken::ASDraw = 0x94; const quint16 ApplesoftToken::ASXdraw = 0x95;
const quint16 ApplesoftToken::ASHtab = 0x96; const quint16 ApplesoftToken::ASHome = 0x97;
const quint16 ApplesoftToken::ASRot = 0x98; const quint16 ApplesoftToken::ASScale = 0x99;
const quint16 ApplesoftToken::ASShload = 0x9A; const quint16 ApplesoftToken::ASTrace = 0x9B;
const quint16 ApplesoftToken::ASNotrace = 0x9C; const quint16 ApplesoftToken::ASNormal = 0x9D;
const quint16 ApplesoftToken::ASInverse = 0x9E; const quint16 ApplesoftToken::ASFlash = 0x9F;
const quint16 ApplesoftToken::ASColor = 0xA0; const quint16 ApplesoftToken::ASPop = 0xA1;
const quint16 ApplesoftToken::ASVtab = 0xA2; const quint16 ApplesoftToken::ASHimem = 0xA3;
const quint16 ApplesoftToken::ASLomem = 0xA4; const quint16 ApplesoftToken::ASOnerr = 0xA5;
const quint16 ApplesoftToken::ASResume = 0xA6; const quint16 ApplesoftToken::ASRecall = 0xA7;
const quint16 ApplesoftToken::ASStore = 0xA8; const quint16 ApplesoftToken::ASSpeed = 0xA9;
const quint16 ApplesoftToken::ASLet = 0xAA; const quint16 ApplesoftToken::ASGoto = 0xAB;
const quint16 ApplesoftToken::ASRun = 0xAC; const quint16 ApplesoftToken::ASIf = 0xAD;
const quint16 ApplesoftToken::ASRestore = 0xAE; const quint16 ApplesoftToken::ASAMP = 0xAF;
const quint16 ApplesoftToken::ASGosub = 0xB0; const quint16 ApplesoftToken::ASReturn = 0xB1;
const quint16 ApplesoftToken::ASRem = 0xB2; const quint16 ApplesoftToken::ASStop = 0xB3;
const quint16 ApplesoftToken::ASOn = 0xB4; const quint16 ApplesoftToken::ASWait = 0xB5;
const quint16 ApplesoftToken::ASLoad = 0xB6; const quint16 ApplesoftToken::ASSave = 0xB7;
const quint16 ApplesoftToken::ASDef = 0xB8; const quint16 ApplesoftToken::ASPoke = 0xB9;
const quint16 ApplesoftToken::ASPrint = 0xBA; const quint16 ApplesoftToken::ASCont = 0xBB;
const quint16 ApplesoftToken::ASList = 0xBC; const quint16 ApplesoftToken::ASClear = 0xBD;
const quint16 ApplesoftToken::ASGet = 0xBE; const quint16 ApplesoftToken::ASNew = 0xBF;
const quint16 ApplesoftToken::ASTab = 0xC0; const quint16 ApplesoftToken::ASTo = 0xC1;
const quint16 ApplesoftToken::ASFn = 0xC2; const quint16 ApplesoftToken::ASSpc = 0xC3;
const quint16 ApplesoftToken::ASThen = 0xC4; const quint16 ApplesoftToken::ASAt = 0xC5;
const quint16 ApplesoftToken::ASNot = 0xC6; const quint16 ApplesoftToken::ASStep = 0xC7;
const quint16 ApplesoftToken::ASPLUS = 0xC8; const quint16 ApplesoftToken::ASMINUS = 0xC9;
const quint16 ApplesoftToken::ASASTERISK = 0xCA; const quint16 ApplesoftToken::ASSLASH = 0xCB;
const quint16 ApplesoftToken::ASCARET = 0xCC; const quint16 ApplesoftToken::ASAnd = 0xCD;
const quint16 ApplesoftToken::ASOr = 0xCE; const quint16 ApplesoftToken::ASGREATER = 0xCF;
const quint16 ApplesoftToken::ASEQUAL = 0xD0; const quint16 ApplesoftToken::ASLESS = 0xD1;
const quint16 ApplesoftToken::ASSgn = 0xD2; const quint16 ApplesoftToken::ASInt = 0xD3;
const quint16 ApplesoftToken::ASAbs = 0xD4; const quint16 ApplesoftToken::ASUsr = 0xD5;
const quint16 ApplesoftToken::ASFre = 0xD6; const quint16 ApplesoftToken::ASScrn = 0xD7;
const quint16 ApplesoftToken::ASPdl = 0xD8; const quint16 ApplesoftToken::ASPos = 0xD9;
const quint16 ApplesoftToken::ASSqr = 0xDA; const quint16 ApplesoftToken::ASRnd = 0xDB;
const quint16 ApplesoftToken::ASLog = 0xDC; const quint16 ApplesoftToken::ASExp = 0xDD;
const quint16 ApplesoftToken::ASCos = 0xDE; const quint16 ApplesoftToken::ASSin = 0xDF;
const quint16 ApplesoftToken::ASTan = 0xE0; const quint16 ApplesoftToken::ASAtn = 0xE1;
const quint16 ApplesoftToken::ASPeek = 0xE2; const quint16 ApplesoftToken::ASLen = 0xE3;
const quint16 ApplesoftToken::ASStr = 0xE4; const quint16 ApplesoftToken::ASVal = 0xE5;
const quint16 ApplesoftToken::ASAsc = 0xE6; const quint16 ApplesoftToken::ASChr = 0xE7;
const quint16 ApplesoftToken::ASLeft = 0xE8; const quint16 ApplesoftToken::ASRight = 0xE9;
const quint16 ApplesoftToken::ASMid = 0xEA; const quint16 ApplesoftToken::AS_EB = 0xEB;
const quint16 ApplesoftToken::AS_EC = 0xEC; const quint16 ApplesoftToken::AS_ED = 0xED;
const quint16 ApplesoftToken::AS_EE = 0xEE; const quint16 ApplesoftToken::AS_EF = 0xEF;
const quint16 ApplesoftToken::AS_F0 = 0xF0; const quint16 ApplesoftToken::AS_F1 = 0xF1;
const quint16 ApplesoftToken::AS_F2 = 0xF2; const quint16 ApplesoftToken::AS_F3 = 0xF3;
const quint16 ApplesoftToken::AS_F4 = 0xF4; const quint16 ApplesoftToken::AS_F5 = 0xF5;
const quint16 ApplesoftToken::AS_F6 = 0xF6; const quint16 ApplesoftToken::AS_F7 = 0xF7;
const quint16 ApplesoftToken::AS_F8 = 0xF8; const quint16 ApplesoftToken::AS_F9 = 0xF9;
const quint16 ApplesoftToken::AS_FA = 0xFA; const quint16 ApplesoftToken::AS_FB = 0xFB;
const quint16 ApplesoftToken::AS_FC = 0xFC; const quint16 ApplesoftToken::AS_FD = 0xFD;
const quint16 ApplesoftToken::AS_FE = 0xFE; const quint16 ApplesoftToken::AS_FF = 0xFF;
+221 -162
View File
@@ -5,19 +5,19 @@
#include <QMap>
#include <QTextCharFormat>
enum TextCharFormatType {
TCFDefault,
TCFCtrlChar,
TCFAscii,
TCFFunction,
TCFOperator,
TCFUnusedToken,
TCFNumber,
TCFString,
TCFVariable,
TCFDataString,
TCFRemString,
TCFUnknown
enum class TextCharFormatType {
Default,
CtrlChar,
Ascii,
Function,
Operator,
UnusedToken,
Number,
String,
Variable,
DataString,
RemString,
Unknown
};
@@ -25,195 +25,254 @@ class ApplesoftToken
{
public:
static const quint16 StringTokenVal = 0x100;
static const quint16 RemStringTokenVal = 0x101;
static const quint16 DataStringTokenVal = 0x102;
static constexpr quint16 StringTokenVal = 0x100;
static constexpr quint16 RemStringTokenVal = 0x101;
static constexpr quint16 DataStringTokenVal = 0x102;
static const quint16 IntegerTokenVal = 0x103;
static const quint16 FloatTokenVal = 0x104;
static constexpr quint16 IntegerTokenVal = 0x103;
static constexpr quint16 FloatTokenVal = 0x104;
static const quint16 IntVarTokenVal = 0x105;
static const quint16 IntAryVarTokenVal = 0x106;
static constexpr quint16 IntVarTokenVal = 0x105;
static constexpr quint16 IntAryVarTokenVal = 0x106;
static const quint16 FloatVarTokenVal = 0x107;
static const quint16 FloatAryVarTokenVal = 0x108;
static constexpr quint16 FloatVarTokenVal = 0x107;
static constexpr quint16 FloatAryVarTokenVal = 0x108;
static const quint16 StringVarTokenVal = 0x109;
static const quint16 StringAryVarTokenVal = 0x10A;
static constexpr quint16 StringVarTokenVal = 0x109;
static constexpr quint16 StringAryVarTokenVal = 0x10A;
static const quint16 OptFmtLeadingSpaceTokenValue = 0xe000;
static const quint16 OptFmtIndentLineBreakTokenValue = 0xe001;
static const quint16 OptFmtIndentTabTokenValue = 0xe002;
static const quint16 OptFmtIndentSpaceTokenValue = 0xe003;
static const quint16 OptFmtFlagFlowTargetNextTokenValue = 0xe004;
static const quint16 OptFmtReturnLineBreakTokenValue = 0xe005;
static constexpr quint16 OptFmtLeadingSpaceTokenValue = 0xe000;
static constexpr quint16 OptFmtIndentLineBreakTokenValue = 0xe001;
static constexpr quint16 OptFmtIndentTabTokenValue = 0xe002;
static constexpr quint16 OptFmtIndentSpaceTokenValue = 0xe003;
static constexpr quint16 OptFmtFlagFlowTargetNextTokenValue = 0xe004;
static constexpr quint16 OptFmtReturnLineBreakTokenValue = 0xe005;
static const quint16 ControlCharTokenVal = 0xfffd;
static const quint16 LineNumberTokenVal = 0xfffe;
static const quint16 DefaultTokenVal = 0xffff;
static constexpr quint16 ControlCharTokenVal = 0xfffd;
static constexpr quint16 LineNumberTokenVal = 0xfffe;
static constexpr quint16 DefaultTokenVal = 0xffff;
static const quint16 ASEnd; static const quint16 ASFor;
static const quint16 ASNext; static const quint16 ASData;
static const quint16 ASInput; static const quint16 ASDel;
static const quint16 ASDim; static const quint16 ASRead;
static const quint16 ASGr; static const quint16 ASText;
static const quint16 ASPr; static const quint16 ASIn;
static const quint16 ASCall; static const quint16 ASPlot;
static const quint16 ASHlin; static const quint16 ASVlin;
static constexpr quint16 ASEnd = 0x80; static constexpr quint16 ASFor = 0x81;
static constexpr quint16 ASNext = 0x82; static constexpr quint16 ASData = 0x83;
static constexpr quint16 ASInput = 0x84; static constexpr quint16 ASDel = 0x85;
static constexpr quint16 ASDim = 0x86; static constexpr quint16 ASRead = 0x87;
static constexpr quint16 ASGr = 0x88; static constexpr quint16 ASText = 0x89;
static constexpr quint16 ASPr = 0x8A; static constexpr quint16 ASIn = 0x8B;
static constexpr quint16 ASCall = 0x8C; static constexpr quint16 ASPlot = 0x8D;
static constexpr quint16 ASHlin = 0x8E; static constexpr quint16 ASVlin = 0x8F;
static const quint16 ASHgr2; static const quint16 ASHgr;
static const quint16 ASHcolor; static const quint16 ASHplot;
static const quint16 ASDraw; static const quint16 ASXdraw;
static const quint16 ASHtab; static const quint16 ASHome;
static const quint16 ASRot; static const quint16 ASScale;
static const quint16 ASShload; static const quint16 ASTrace;
static const quint16 ASNotrace; static const quint16 ASNormal;
static const quint16 ASInverse; static const quint16 ASFlash;
static constexpr quint16 ASHgr2 = 0x90; static constexpr quint16 ASHgr = 0x91;
static constexpr quint16 ASHcolor = 0x92; static constexpr quint16 ASHplot = 0x93;
static constexpr quint16 ASDraw = 0x94; static constexpr quint16 ASXdraw = 0x95;
static constexpr quint16 ASHtab = 0x96; static constexpr quint16 ASHome = 0x97;
static constexpr quint16 ASRot = 0x98; static constexpr quint16 ASScale = 0x99;
static constexpr quint16 ASShload = 0x9A; static constexpr quint16 ASTrace = 0x9B;
static constexpr quint16 ASNotrace = 0x9C; static constexpr quint16 ASNormal = 0x9D;
static constexpr quint16 ASInverse = 0x9E; static constexpr quint16 ASFlash = 0x9F;
static const quint16 ASColor; static const quint16 ASPop;
static const quint16 ASVtab; static const quint16 ASHimem;
static const quint16 ASLomem; static const quint16 ASOnerr;
static const quint16 ASResume; static const quint16 ASRecall;
static const quint16 ASStore; static const quint16 ASSpeed;
static const quint16 ASLet; static const quint16 ASGoto;
static const quint16 ASRun; static const quint16 ASIf;
static const quint16 ASRestore; static const quint16 ASAMP;
static constexpr quint16 ASColor = 0xA0; static constexpr quint16 ASPop = 0xA1;
static constexpr quint16 ASVtab = 0xA2; static constexpr quint16 ASHimem = 0xA3;
static constexpr quint16 ASLomem = 0xA4; static constexpr quint16 ASOnerr = 0xA5;
static constexpr quint16 ASResume = 0xA6; static constexpr quint16 ASRecall = 0xA7;
static constexpr quint16 ASStore = 0xA8; static constexpr quint16 ASSpeed = 0xA9;
static constexpr quint16 ASLet = 0xAA; static constexpr quint16 ASGoto = 0xAB;
static constexpr quint16 ASRun = 0xAC; static constexpr quint16 ASIf = 0xAD;
static constexpr quint16 ASRestore = 0xAE; static constexpr quint16 ASAMP = 0xAF;
static const quint16 ASGosub; static const quint16 ASReturn;
static const quint16 ASRem; static const quint16 ASStop;
static const quint16 ASOn; static const quint16 ASWait;
static const quint16 ASLoad; static const quint16 ASSave;
static const quint16 ASDef; static const quint16 ASPoke;
static const quint16 ASPrint; static const quint16 ASCont;
static const quint16 ASList; static const quint16 ASClear;
static const quint16 ASGet; static const quint16 ASNew;
static constexpr quint16 ASGosub = 0xB0; static constexpr quint16 ASReturn = 0xB1;
static constexpr quint16 ASRem = 0xB2; static constexpr quint16 ASStop = 0xB3;
static constexpr quint16 ASOn = 0xB4; static constexpr quint16 ASWait = 0xB5;
static constexpr quint16 ASLoad = 0xB6; static constexpr quint16 ASSave = 0xB7;
static constexpr quint16 ASDef = 0xB8; static constexpr quint16 ASPoke = 0xB9;
static constexpr quint16 ASPrint = 0xBA; static constexpr quint16 ASCont = 0xBB;
static constexpr quint16 ASList = 0xBC; static constexpr quint16 ASClear = 0xBD;
static constexpr quint16 ASGet = 0xBE; static constexpr quint16 ASNew = 0xBF;
static const quint16 ASTab; static const quint16 ASTo;
static const quint16 ASFn; static const quint16 ASSpc;
static const quint16 ASThen; static const quint16 ASAt;
static const quint16 ASNot; static const quint16 ASStep;
static const quint16 ASPLUS; static const quint16 ASMINUS;
static const quint16 ASASTERISK; static const quint16 ASSLASH;
static const quint16 ASCARET; static const quint16 ASAnd;
static const quint16 ASOr; static const quint16 ASGREATER;
static constexpr quint16 ASTab = 0xC0; static constexpr quint16 ASTo = 0xC1;
static constexpr quint16 ASFn = 0xC2; static constexpr quint16 ASSpc = 0xC3;
static constexpr quint16 ASThen = 0xC4; static constexpr quint16 ASAt = 0xC5;
static constexpr quint16 ASNot = 0xC6; static constexpr quint16 ASStep = 0xC7;
static constexpr quint16 ASPLUS = 0xC8; static constexpr quint16 ASMINUS = 0xC9;
static constexpr quint16 ASASTERISK = 0xCA; static constexpr quint16 ASSLASH = 0xCB;
static constexpr quint16 ASCARET = 0xCC; static constexpr quint16 ASAnd = 0xCD;
static constexpr quint16 ASOr = 0xCE; static constexpr quint16 ASGREATER = 0xCF;
static const quint16 ASEQUAL; static const quint16 ASLESS;
static const quint16 ASSgn; static const quint16 ASInt;
static const quint16 ASAbs; static const quint16 ASUsr;
static const quint16 ASFre; static const quint16 ASScrn;
static const quint16 ASPdl; static const quint16 ASPos;
static const quint16 ASSqr; static const quint16 ASRnd;
static const quint16 ASLog; static const quint16 ASExp;
static const quint16 ASCos; static const quint16 ASSin;
static constexpr quint16 ASEQUAL = 0xD0; static constexpr quint16 ASLESS = 0xD1;
static constexpr quint16 ASSgn = 0xD2; static constexpr quint16 ASInt = 0xD3;
static constexpr quint16 ASAbs = 0xD4; static constexpr quint16 ASUsr = 0xD5;
static constexpr quint16 ASFre = 0xD6; static constexpr quint16 ASScrn = 0xD7;
static constexpr quint16 ASPdl = 0xD8; static constexpr quint16 ASPos = 0xD9;
static constexpr quint16 ASSqr = 0xDA; static constexpr quint16 ASRnd = 0xDB;
static constexpr quint16 ASLog = 0xDC; static constexpr quint16 ASExp = 0xDD;
static constexpr quint16 ASCos = 0xDE; static constexpr quint16 ASSin = 0xDF;
static const quint16 ASTan; static const quint16 ASAtn;
static const quint16 ASPeek; static const quint16 ASLen;
static const quint16 ASStr; static const quint16 ASVal;
static const quint16 ASAsc; static const quint16 ASChr;
static const quint16 ASLeft; static const quint16 ASRight;
static const quint16 ASMid; static const quint16 AS_EB;
static const quint16 AS_EC; static const quint16 AS_ED;
static const quint16 AS_EE; static const quint16 AS_EF;
static constexpr quint16 ASTan = 0xE0; static constexpr quint16 ASAtn = 0xE1;
static constexpr quint16 ASPeek = 0xE2; static constexpr quint16 ASLen = 0xE3;
static constexpr quint16 ASStr = 0xE4; static constexpr quint16 ASVal = 0xE5;
static constexpr quint16 ASAsc = 0xE6; static constexpr quint16 ASChr = 0xE7;
static constexpr quint16 ASLeft = 0xE8; static constexpr quint16 ASRight = 0xE9;
static constexpr quint16 ASMid = 0xEA; static constexpr quint16 AS_EB = 0xEB;
static constexpr quint16 AS_EC = 0xEC; static constexpr quint16 AS_ED = 0xED;
static constexpr quint16 AS_EE = 0xEE; static constexpr quint16 AS_EF = 0xEF;
static const quint16 AS_F0; static const quint16 AS_F1;
static const quint16 AS_F2; static const quint16 AS_F3;
static const quint16 AS_F4; static const quint16 AS_F5;
static const quint16 AS_F6; static const quint16 AS_F7;
static const quint16 AS_F8; static const quint16 AS_F9;
static const quint16 AS_FA; static const quint16 AS_FB;
static const quint16 AS_FC; static const quint16 AS_FD;
static const quint16 AS_FE; static const quint16 AS_FF;
static constexpr quint16 AS_F0 = 0xF0; static constexpr quint16 AS_F1 = 0xF1;
static constexpr quint16 AS_F2 = 0xF2; static constexpr quint16 AS_F3 = 0xF3;
static constexpr quint16 AS_F4 = 0xF4; static constexpr quint16 AS_F5 = 0xF5;
static constexpr quint16 AS_F6 = 0xF6; static constexpr quint16 AS_F7 = 0xF7;
static constexpr quint16 AS_F8 = 0xF8; static constexpr quint16 AS_F9 = 0xF9;
static constexpr quint16 AS_FA = 0xFA; static constexpr quint16 AS_FB = 0xFB;
static constexpr quint16 AS_FC = 0xFC; static constexpr quint16 AS_FD = 0xFD;
static constexpr quint16 AS_FE = 0xFE; static constexpr quint16 AS_FF = 0xFF;
typedef enum {
UNKNOWN_TOKEN = 0x0,
ASCIICHAR_TOKEN = 0x1,
APPLESOFT_TOKEN = 0x2,
UNDEFINED_APPLESOFT_TOKEN = 0x3,
STRING_TOKEN = 0x4,
INTEGER_TOKEN = 0x5,
FLOAT_TOKEN = 0x6,
DATASTRING_TOKEN = 0x7,
REM_TOKEN = 0x8,
INT_VARIABLE_TOKEN = 0x9,
INT_ARY_VARIABLE_TOKEN = 0xA,
FLOAT_VARIABLE_TOKEN = 0xB,
FLOAT_ARY_VARIABLE_TOKEN = 0xC,
STRING_VARIABLE_TOKEN = 0xD,
STRING_ARY_VARIABLE_TOKEN = 0xE,
OPTIONAL_FORMAT_TOKEN = 0xF
} TokenType;
private:
static inline const QMap<quint16, QString> m_tokens = {
{ASEnd, " END "}, {ASFor, " FOR "},
{ASNext, " NEXT "}, {ASData, " DATA "},
{ASInput, " INPUT "}, {ASDel, " DEL "},
{ASDim, " DIM "}, {ASRead, " READ "},
{ASGr, " GR "}, {ASText, " TEXT "},
{ASPr, " PR# "}, {ASIn, " IN# "},
{ASCall, " CALL "}, {ASPlot, " PLOT "},
{ASHlin, " HLIN "}, {ASVlin, " VLIN "},
{ASHgr2, " HGR2 "}, {ASHgr, " HGR "},
{ASHcolor, " HCOLOR= "}, {ASHplot, " HPLOT "},
{ASDraw, " DRAW "}, {ASXdraw, " XDRAW "},
{ASHtab, " HTAB "}, {ASHome, " HOME "},
{ASRot, " ROT= "}, {ASScale, " SCALE= "},
{ASShload, " SHLOAD "}, {ASTrace, " TRACE "},
{ASNotrace, " NOTRACE "}, {ASNormal, " NORMAL "},
{ASInverse, " INVERSE "}, {ASFlash, " FLASH "},
{ASColor, " COLOR= "}, {ASPop, " POP "},
{ASVtab, " VTAB "}, {ASHimem, " HIMEM: "},
{ASLomem, " LOMEM: "}, {ASOnerr, " ONERR "},
{ASResume, " RESUME "}, {ASRecall, " RECALL "},
{ASStore, " STORE "}, {ASSpeed, " SPEED= "},
{ASLet, " LET "}, {ASGoto, " GOTO "},
{ASRun, " RUN "}, {ASIf, " IF "},
{ASRestore, " RESTORE "}, {ASAMP, " & "},
{ASGosub, " GOSUB "}, {ASReturn, " RETURN "},
{ASRem, " REM "}, {ASStop, " STOP "},
{ASOn, " ON "}, {ASWait, " WAIT "},
{ASLoad, " LOAD "}, {ASSave, " SAVE "},
{ASDef, " DEF "}, {ASPoke, " POKE "},
{ASPrint, " PRINT "}, {ASCont, " CONT "},
{ASList, " LIST "}, {ASClear, " CLEAR "},
{ASGet, " GET "}, {ASNew, " NEW "},
{ASTab, " TAB("}, {ASTo, " TO "},
{ASFn, " FN "}, {ASSpc, " SPC( "},
{ASThen, " THEN "}, {ASAt, " AT "},
{ASNot, " NOT "}, {ASStep, " STEP "},
{ASPLUS, " + "}, {ASMINUS, " - "},
{ASASTERISK, " * "}, {ASSLASH, " / "},
{ASCARET, " ^ "}, {ASAnd, " AND "},
{ASOr, " OR "}, {ASGREATER, " > "},
{ASEQUAL, " = "}, {ASLESS, " < "},
{ASSgn, " SGN"}, {ASInt, " INT"},
{ASAbs, " ABS"}, {ASUsr, " USR"},
{ASFre, " FRE"}, {ASScrn, " SCRN( "},
{ASPdl, " PDL"}, {ASPos, " POS"},
{ASSqr, " SQR"}, {ASRnd, " RND"},
{ASLog, " LOG"}, {ASExp, " EXP"},
{ASCos, " COS"}, {ASSin, " SIN"},
{ASTan, " TAN"}, {ASAtn, " ATN"},
{ASPeek, " PEEK"}, {ASLen, " LEN"},
{ASStr, " STR$"}, {ASVal, " VAL"},
{ASAsc, " ASC"}, {ASChr, " CHR$"},
{ASLeft, " LEFT$ "}, {ASRight, " RIGHT$ "},
{ASMid, " MID$ "},
{AS_EB, "{Token 0xEB} "}, {AS_EC, "{Token 0xEC} "},
{AS_ED, "{Token 0xED} "}, {AS_EE, "{Token 0xEE} "},
{AS_EF, "{Token 0xEF} "}, {AS_F0, "{Token 0xF0} "},
{AS_F1, "{Token 0xF1} "}, {AS_F2, "{Token 0xF2} "},
{AS_F3, "{Token 0xF3} "}, {AS_F4, "{Token 0xF4} "},
{AS_F5, "{Token 0xF5} "}, {AS_F6, "{Token 0xF6} "},
{AS_F7, "{Token 0xF7} "}, {AS_F8, "{Token 0xF8} "},
{AS_F9, "{Token 0xF9} "}, {AS_FA, "{Token 0xFA} "},
{AS_FB, "{Token 0xFB} "}, {AS_FC, "{Token 0xFC} "},
{AS_FD, "{Token 0xFD} "}, {AS_FE, "{Token 0xFE} "},
{AS_FF, "{Token 0xFF} "}
};
typedef enum {
NONE,
COMMAND,
OPERATOR,
FUNCTION,
UNDEFINED_COMMAND,
OPTIONAL_FORMAT
} CommandType;
static constexpr quint16 NullChar = 0x00;
static constexpr quint16 MaxAsciiChar = 0x7f;
static constexpr quint16 MaxApplesoftCommand = 0xC7;
static constexpr quint16 MaxApplesoftOperator = 0xD1;
static constexpr quint16 MaxApplesoftFunction = 0xEA;
static constexpr quint16 MaxApplesoftToken = 0xFF;
static constexpr quint16 OptFmtRangeStart = 0xe000;
static constexpr quint16 OptFmtRangeEnd = 0xf000;
public:
enum class TokenType {
Unknown = 0x0,
AsciiChar = 0x1,
ApplesoftToken = 0x2,
UndefinedApplesoft = 0x3,
String = 0x4,
Integer = 0x5,
Float = 0x6,
DataString = 0x7,
Rem = 0x8,
IntVariable = 0x9,
IntAryVariable = 0xA,
FloatVariable = 0xB,
FloatAryVariable = 0xC,
StringVariable = 0xD,
StringAryVariable = 0xE,
OptionalFormat = 0xF
};
enum class CommandType {
None,
Command,
Operator,
Function,
UndefinedCommand,
OptionalFormat
};
ApplesoftToken();
ApplesoftToken(quint16 id);
ApplesoftToken(quint16 id, QVariant payload);
void setTokenId(quint16 id);
quint16 getTokenId() const { return m_token_id; }
inline quint16 getTokenId() const { return m_token_id; }
void setValue(QVariant value);
QVariant getValue() const { return m_payload; }
inline QVariant getValue() const { return m_payload; }
QByteArray getByteStringValue() const { return m_payload.toByteArray(); }
QString getStringValue() const {
QString str = m_payload.toString();
// Remove trailing NUL character if present
if (!str.isEmpty() && str.back() == QChar(0)) {
str.chop(1);
}
return str;
}
quint32 getUnsignedIntegerValue() const { return (quint32) (m_payload.toUInt() & 0xFFFFFFFF); }
qint32 getIntegerValue() const { return (qint32) (m_payload.toInt() & 0xFFFFFFFF); }
inline QByteArray getByteStringValue() const { return m_payload.toByteArray(); }
QString getStringValue() const;
inline quint32 getUnsignedIntegerValue() const { return m_payload.toUInt(); }
inline qint32 getIntegerValue() const { return m_payload.toInt(); }
quint16 getWordValue() const { return (quint16) (m_payload.toUInt() & 0xFFFF); }
quint8 getByteValue() const { return (quint8) (m_payload.toUInt() & 0xFF); }
inline quint16 getWordValue() const { return quint16(m_payload.toUInt() & 0xFFFF); }
inline quint8 getByteValue() const { return quint8(m_payload.toUInt() & 0xFF); }
TokenType getTokenType() const { return m_token_type; }
CommandType getCommandType() const { return m_command_type; }
inline TokenType getTokenType() const { return m_token_type; }
inline CommandType getCommandType() const { return m_command_type; }
QString getRawPrintableString() const;
QTextCharFormat textFormat()
{
return textFormat(m_token_id);
}
QTextCharFormat textFormat();
static QTextCharFormat defaultTextFormat();
static QTextCharFormat defaultInverseTextFormat();
static QTextCharFormat textFormat(quint16 tokentype) ;
QString getStringForToken(quint8 token) {
if (m_tokens.size() == 0) { initializeTokenTable(); }
return m_tokens[token];
}
QString getStringForToken(quint8 token);
bool isOptFmtToken() const { return (m_token_id >= 0xe000 && m_token_id < 0xf000); }
inline bool isOptFmtToken() const { return (m_token_id >= OptFmtRangeStart && m_token_id < OptFmtRangeEnd); }
private:
void makeTextCharFormats();
static QMap<quint16, QString> m_tokens;
quint16 m_token_id;
QString m_tokenname;
QVariant m_payload;
TokenType m_token_type;
CommandType m_command_type;
static void initializeTokenTable();
quint16 m_token_id{0};
QString m_tokenname{""};
QVariant m_payload{};
TokenType m_token_type{TokenType::Unknown};
CommandType m_command_type{CommandType::None};
};
+1 -1
View File
@@ -96,7 +96,7 @@ bool AssemblerSymbolModel::setData(const QModelIndex &index, const QVariant &val
{
assemblerSymbols->symbolRefAt(index.row()).name = value.toString();
}
emit dataChanged(index, index, QVector<int>() << role);
emit dataChanged(index, index, QList<int>() << role);
return true;
}
return false;
+1 -1
View File
@@ -46,7 +46,7 @@ protected slots:
void handleSymbolChange(int location)
{
QModelIndex ind = createIndex(location,0);
emit dataChanged(ind,ind,QVector<int>() << Qt::DisplayRole);
emit dataChanged(ind,ind,QList<int>() << Qt::DisplayRole);
}
+3 -1
View File
@@ -1,7 +1,9 @@
#include <QDebug>
#include "BinaryFile.h"
#include "Util.h"
#include <QDebug>
#include <QByteArray>
BinaryFile::BinaryFile(QByteArray data) : GenericFile(data)
{
m_length = 0;
+3
View File
@@ -2,6 +2,9 @@
#include "GenericFile.h"
// Forward declarations
class QByteArray;
class BinaryFile : public GenericFile
{
public:
+35 -3
View File
@@ -1,12 +1,11 @@
#include "Disassembler.h"
#include "OpCodes.h"
#include "AttributedMemory.h"
#include "RoleAsmOpcode.h"
#include "RoleAsmOperand.h"
#include "Util.h"
#include <QByteArray>
#include <QDebug>
#include <QList>
#include <math.h>
@@ -378,3 +377,36 @@ void DisassembledItem::init() {
m_canNotFollow = false;
m_isInvalidOp = false;
}
// Moved inline methods from header
QString DisassembledItem::hexAddress() const {
return uint16ToHex(m_address);
}
bool DisassembledItem::isBranch() const {
return OpCodes::isBranch(m_opcode);
}
bool DisassembledItem::isJump() const {
return OpCodes::isJump(m_opcode);
}
bool DisassembledItem::isJsr() const {
return OpCodes::isJsr(m_opcode);
}
bool DisassembledItem::isReturn() {
return OpCodes::isReturn(m_opcode);
}
bool DisassembledItem::isBreak() {
return OpCodes::isBreak(m_opcode);
}
QString DisassembledItem::arg8Str() {
return uint8ToHex(arg8());
}
QString DisassembledItem::arg16Str() {
return uint16ToHex(arg16());
}
+15 -13
View File
@@ -1,16 +1,18 @@
#pragma once
#include "MemoryUsageMap.h"
#include "Util.h"
#include "JumpLineManager.h"
#include "OpCodes.h"
#include "AttributedMemory.h"
#include "MemoryUsageMap.h"
#include "../internals/JumpLineManager.h"
#include <QByteArray>
#include <QStringList>
#include <QHash>
#include <QDebug>
#include <QStack>
#include <QList>
// Forward declarations
class AttributedMemory;
struct JumpLines;
class AddressStack
@@ -58,15 +60,15 @@ public:
quint16 address() const { return m_address; }
QString disassembledString();
QString rawDisassembledString() const { return m_disassembly_text; }
QString hexAddress() const { return uint16ToHex(m_address); }
QString hexAddress() const;
QByteArray hexValues() const { return m_hexvalues; }
QString hexString() const { return m_hexstring; }
bool isBranch() const { return OpCodes::isBranch(m_opcode); }
bool isJump() const { return OpCodes::isJump(m_opcode); }
bool isJsr() const { return OpCodes::isJsr(m_opcode); }
bool isReturn() { return OpCodes::isReturn(m_opcode); }
bool isBreak() { return OpCodes::isBreak(m_opcode); }
bool isBranch() const;
bool isJump() const;
bool isJsr() const;
bool isReturn();
bool isBreak();
bool isInvalidOp() { return m_isInvalidOp; }
bool canNotFollow() { return m_canNotFollow; }
@@ -86,10 +88,10 @@ public:
bool hasArg() const { return m_has_arg; }
quint8 arg8() { return m_raw_arg % 256; }
QString arg8Str() { return uint8ToHex(arg8()); }
QString arg8Str();
quint16 arg16() { return m_raw_arg; }
QString arg16Str() { return uint16ToHex(arg16()); }
QString arg16Str();
private:
void init();
+1 -1
View File
@@ -85,7 +85,7 @@ bool EntryPointModel::setData(const QModelIndex &index, const QVariant &value, i
{
entryPoints->pointRefAt(index.row()).note = value.toString();
}
emit dataChanged(index, index, QVector<int>() << role);
emit dataChanged(index, index, QList<int>() << role);
return true;
}
return false;
+1 -1
View File
@@ -45,7 +45,7 @@ protected slots:
void handlePointChange(int location)
{
QModelIndex ind = createIndex(location,0);
emit dataChanged(ind,ind,QVector<int>() << Qt::DisplayRole);
emit dataChanged(ind,ind,QList<int>() << Qt::DisplayRole);
}
+3 -4
View File
@@ -2,7 +2,6 @@
#include <QFlag>
#include <QFlags>
#include <QVector>
#include <QList>
@@ -32,7 +31,7 @@ enum MemoryUsage {
Q_DECLARE_FLAGS(MemoryUsages,MemoryUsage)
class MemoryUsageMap : public QVector<MemoryUsages>
class MemoryUsageMap : public QList<MemoryUsages>
{
public:
@@ -79,7 +78,7 @@ private:
void clear();
void append(const MemoryUsages &);
void append(MemoryUsages &&);
void append(const QVector<MemoryUsages>);
void append(const QList<MemoryUsages>);
void insert(int,const MemoryUsages &);
void insert(int,int,const MemoryUsages &);
void move(int,int);
@@ -96,7 +95,7 @@ private:
bool removeOne(const MemoryUsages&);
void reserve(int);
void resize(int);
void swap(QVector<MemoryUsages>&);
void swap(QList<MemoryUsages>&);
MemoryUsages &takeAt(int);
MemoryUsages &takeFirst();
MemoryUsages &takeLast();
-1
View File
@@ -116,7 +116,6 @@ GenericFile *DiskFile::getFile(FileDescriptiveEntry fde)
}
else
{
if (!fde.firstTSListSector().isValid())
{
qWarning(" Not returning a file from invalid TSList!");
+3 -3
View File
@@ -32,8 +32,8 @@ public:
protected:
QByteArray m_data;
QString m_filename;
quint16 m_address;
qint16 m_length;
DiskFile * m_diskfile;
quint16 m_address{0};
qint16 m_length{0};
DiskFile * m_diskfile{nullptr};
};
+1 -1
View File
@@ -138,7 +138,7 @@ QByteArray IntBasicFile::dumpBufferAsIntBasicFile(QByteArray origdata)
QByteArray retval;
QVector<quint8> data;
QList<quint8> data;
QByteArray data0 = origdata;
+1 -1
View File
@@ -27,7 +27,7 @@ ApplesoftFileDetailViewer::~ApplesoftFileDetailViewer()
delete ui;
}
void ApplesoftFileDetailViewer::setLineData(QVector<ApplesoftLine> lineData)
void ApplesoftFileDetailViewer::setLineData(QList<ApplesoftLine> lineData)
{
m_lines = lineData;
process();
+2 -2
View File
@@ -19,7 +19,7 @@ public:
explicit ApplesoftFileDetailViewer(ApplesoftFile *file, QWidget *parent = 0);
~ApplesoftFileDetailViewer();
void setLineData(QVector<ApplesoftLine> lineData);
void setLineData(QList<ApplesoftLine> lineData);
void foo() { qDebug() << "AFDV::foo!"; }
bool save();
@@ -31,7 +31,7 @@ private:
void process();
Ui::ApplesoftFileDetailViewer *ui;
QVector<ApplesoftLine> m_lines;
QList<ApplesoftLine> m_lines;
QMap<QString,QString> m_notes;
+2 -2
View File
@@ -2,7 +2,7 @@
#include "ui_TextHexDumpViewer.h"
#include "AppleString.h"
#include <QVector>
#include <QList>
#include <QByteArray>
#include <QSettings>
#include <QMenu>
@@ -88,7 +88,7 @@ void TextHexDumpViewer::setFile(GenericFile *file, quint16 offset)
QStringList outputlines;
QVector<QByteArray> chunks;
QList<QByteArray> chunks;
QByteArray tmpval = data;
+5 -5
View File
@@ -494,7 +494,7 @@ QColor HiresScreenWidget::getColorFromBits(QBitArray bits, quint8 phase)
}
void HiresScreenWidget::drawNtscLine(QPainter &painter, int lineNum, QBitArray data) {
QVector<QColor> colors;
QList<QColor> colors;
colors.resize(data.size()+3);
for (int idx = 0; idx < data.size(); idx++) {
@@ -605,7 +605,7 @@ void HiresScreenWidget::makeAddressTables()
}
QVector<HiresScreenWidget::ColRow> HiresScreenWidget::m_rawAddressToColRowList
= QVector<HiresScreenWidget::ColRow>();
QVector<HiresScreenWidget::ColRow> HiresScreenWidget::m_appleAddressToColRowList
= QVector<HiresScreenWidget::ColRow>();
QList<HiresScreenWidget::ColRow> HiresScreenWidget::m_rawAddressToColRowList
= QList<HiresScreenWidget::ColRow>();
QList<HiresScreenWidget::ColRow> HiresScreenWidget::m_appleAddressToColRowList
= QList<HiresScreenWidget::ColRow>();
+3 -3
View File
@@ -10,7 +10,7 @@
#include <QBitArray>
#include <QAction>
#include <QMenu>
#include <QVector>
#include <QList>
#include <QDebug>
class HiresScreenWidget : public QWidget
@@ -135,8 +135,8 @@ private:
bool m_showScanLines;
static QVector<ColRow> m_rawAddressToColRowList;
static QVector<ColRow> m_appleAddressToColRowList;
static QList<ColRow> m_rawAddressToColRowList;
static QList<ColRow> m_appleAddressToColRowList;
quint16 m_offset;
};
+2 -2
View File
@@ -14,9 +14,9 @@ QString AppleString::printable() const
return retval;
}
QVector<TextAttribute> AppleString::attributes() const
QList<TextAttribute> AppleString::attributes() const
{
QVector<TextAttribute> retval(this->length());
QList<TextAttribute> retval(this->length());
int idx = 0;
foreach (quint8 ch, *this) {
retval[idx++] = AppleChar(ch).getAttribute();
+2 -3
View File
@@ -2,7 +2,7 @@
#include "Util.h"
#include <QVector>
#include <QList>
#include <QChar>
#include <QString>
#include <QByteArray>
@@ -31,8 +31,7 @@ class AppleString : public QByteArray {
public:
void setData(const QByteArray &data) { insert(0,data); }
QString printable() const;
QVector<TextAttribute> attributes() const;
QList<TextAttribute> attributes() const;
};