mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2024-11-22 00:31:04 +00:00
Stubbed out method for retokenizing negative numbers
This commit is contained in:
parent
f3c2a85b36
commit
171f8d5959
@ -106,6 +106,7 @@ void Retokenizer::retokenize(ApplesoftLine &line)
|
||||
line.tokens = retokenizeDataStatements(line.tokens);
|
||||
line.tokens = retokenizeVariables(line.tokens);
|
||||
line.tokens = retokenizeNumbers(line.tokens);
|
||||
line.tokens = retokenizeNegativeNumbers(line.tokens);
|
||||
|
||||
|
||||
}
|
||||
@ -398,5 +399,36 @@ QVector<ApplesoftToken> Retokenizer::retokenizeNumbers(QVector<ApplesoftToken>&d
|
||||
}
|
||||
|
||||
datatokens = tmptokens.toVector();
|
||||
return datatokens;
|
||||
}
|
||||
|
||||
QVector<ApplesoftToken> Retokenizer::retokenizeNegativeNumbers(QVector<ApplesoftToken>&datatokens)
|
||||
{
|
||||
//TODO: Code to make determination of negative numbers vs. unary minus/math formulas.
|
||||
// Prefixed '-' tokens for negative numbers should get merged with the integer value token.
|
||||
// So, need to determine when we're in an expression vs when we're starting a number.
|
||||
//
|
||||
// A = -1 should retokenize.
|
||||
// A = - 4 - 1 should retokenize -4
|
||||
// A = - 4 - - 1 should retokenize -4 and -1
|
||||
// A = 3 - 1 shoud not retokenize
|
||||
// A = A - 1 should not
|
||||
// A = PEEK(123) - 5 should not
|
||||
// A = 4 * - 1 should
|
||||
// A = (1 + 2) - 4 should not
|
||||
// A = (1 + 2) + - 4 should
|
||||
// A = (1 + 2) - - 4 should
|
||||
// POKE - 4, 1 should
|
||||
// PRINT + - 4 should
|
||||
// PRINT - 4 should
|
||||
// PRINT + + + - - - 4 should retokenize the last -4.
|
||||
// A = 1 - - 4 should
|
||||
// A = 1 - - - 4 should, probably, but it's errorprone to say the least,
|
||||
// as are any multiple arbitrary +/-'s. Have to hope for the best here.
|
||||
// Best bet would be to look at how AppleSoft handles these values.
|
||||
// A = - 0 is the same as 0
|
||||
|
||||
|
||||
|
||||
return datatokens;
|
||||
}
|
||||
|
@ -31,14 +31,13 @@ private:
|
||||
QVector<ApplesoftLine> m_lines;
|
||||
int m_data_end;
|
||||
quint16 m_length;
|
||||
|
||||
friend class Retokenizer;
|
||||
};
|
||||
|
||||
class Retokenizer {
|
||||
public:
|
||||
static void retokenize(ApplesoftLine &line);
|
||||
|
||||
protected:
|
||||
private:
|
||||
static QVector<ApplesoftToken> retokenizeRems(QVector<ApplesoftToken> &datatokens);
|
||||
static QVector<ApplesoftToken> retokenizeStrings(QVector<ApplesoftToken> &datatokens);
|
||||
@ -46,6 +45,7 @@ private:
|
||||
static QVector<ApplesoftToken> processDataPayload(QVector<ApplesoftToken> &datatokens);
|
||||
static QVector<ApplesoftToken> retokenizeVariables(QVector<ApplesoftToken> &datatokens);
|
||||
static QVector<ApplesoftToken> retokenizeNumbers(QVector<ApplesoftToken> &datatokens);
|
||||
static QVector<ApplesoftToken> retokenizeNegativeNumbers(QVector<ApplesoftToken> &datatokens);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user