Improvements to the debugger prompt

- commands are now properly range checked (byte, short, etc)
  - better error messages
  - internally, use 16-bit/8-bit instead of 32-bit when necessary
This commit is contained in:
Stephen Anthony 2017-04-15 19:00:50 -02:30
parent d456721c5e
commit 3aeae9b6f6
10 changed files with 142 additions and 160 deletions

View File

@ -345,58 +345,55 @@ int Debugger::trace()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::toggleBreakPoint(int bp)
void Debugger::toggleBreakPoint(uInt16 bp)
{
breakPoints().initialize();
if(bp < 0) bp = myCpuDebug->pc();
breakPoints().toggle(bp);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::setBreakPoint(int bp, bool set)
void Debugger::setBreakPoint(uInt16 bp, bool set)
{
breakPoints().initialize();
if(bp < 0) bp = myCpuDebug->pc();
if(set) breakPoints().set(bp);
else breakPoints().clear(bp);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::breakPoint(int bp)
bool Debugger::breakPoint(uInt16 bp)
{
if(bp < 0) bp = myCpuDebug->pc();
return breakPoints().isSet(bp);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::toggleReadTrap(int t)
void Debugger::toggleReadTrap(uInt16 t)
{
readTraps().initialize();
readTraps().toggle(t);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::toggleWriteTrap(int t)
void Debugger::toggleWriteTrap(uInt16 t)
{
writeTraps().initialize();
writeTraps().toggle(t);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::toggleTrap(int t)
void Debugger::toggleTrap(uInt16 t)
{
toggleReadTrap(t);
toggleWriteTrap(t);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::readTrap(int t)
bool Debugger::readTrap(uInt16 t)
{
return readTraps().isInitialized() && readTraps().isSet(t);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::writeTrap(int t)
bool Debugger::writeTrap(uInt16 t)
{
return writeTraps().isInitialized() && writeTraps().isSet(t);
}
@ -463,7 +460,7 @@ string Debugger::showWatches()
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::patchROM(int addr, int value)
bool Debugger::patchROM(uInt16 addr, uInt8 value)
{
return myConsole.cartridge().patch(addr, value);
}

View File

@ -219,9 +219,9 @@ class Debugger : public DialogContainer
void setAccessFlags(uInt16 addr, uInt8 flags)
{ mySystem.setAccessFlags(addr, flags); }
void setBreakPoint(int bp, bool set);
void setBreakPoint(uInt16 bp, bool set);
bool patchROM(int addr, int value);
bool patchROM(uInt16 addr, uInt8 value);
/**
Normally, accessing RAM or ROM during emulation can possibly trigger
@ -256,14 +256,14 @@ class Debugger : public DialogContainer
void nextFrame(int frames);
bool rewindState();
void toggleBreakPoint(int bp);
void toggleBreakPoint(uInt16 bp);
bool breakPoint(int bp);
void toggleReadTrap(int t);
void toggleWriteTrap(int t);
void toggleTrap(int t);
bool readTrap(int t);
bool writeTrap(int t);
bool breakPoint(uInt16 bp);
void toggleReadTrap(uInt16 t);
void toggleWriteTrap(uInt16 t);
void toggleTrap(uInt16 t);
bool readTrap(uInt16 t);
bool writeTrap(uInt16 t);
void clearAllTraps();
// Set a bunch of RAM locations at once

View File

@ -37,7 +37,7 @@ class BinAndExpression : public Expression
{
public:
BinAndExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() & myRHS->evaluate(); }
};
@ -46,7 +46,7 @@ class BinNotExpression : public Expression
{
public:
BinNotExpression(Expression* left) : Expression(left) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return ~(myLHS->evaluate()); }
};
@ -55,7 +55,7 @@ class BinOrExpression : public Expression
{
public:
BinOrExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() | myRHS->evaluate(); }
};
@ -64,7 +64,7 @@ class BinXorExpression : public Expression
{
public:
BinXorExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() ^ myRHS->evaluate(); }
};
@ -73,7 +73,7 @@ class ByteDerefExpression : public Expression
{
public:
ByteDerefExpression(Expression* left): Expression(left) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return Debugger::debugger().peek(myLHS->evaluate()); }
};
@ -82,7 +82,7 @@ class ByteDerefOffsetExpression : public Expression
{
public:
ByteDerefOffsetExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return Debugger::debugger().peek(myLHS->evaluate() + myRHS->evaluate()); }
};
@ -91,7 +91,7 @@ class ConstExpression : public Expression
{
public:
ConstExpression(const int value) : Expression(), myValue(value) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myValue; }
private:
@ -103,7 +103,7 @@ class CpuMethodExpression : public Expression
{
public:
CpuMethodExpression(CpuMethod method) : Expression(), myMethod(std::mem_fn(method)) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myMethod(Debugger::debugger().cpuDebug()); }
private:
@ -115,7 +115,7 @@ class DivExpression : public Expression
{
public:
DivExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ int denom = myRHS->evaluate();
return denom == 0 ? 0 : myLHS->evaluate() / denom; }
};
@ -125,7 +125,7 @@ class EqualsExpression : public Expression
{
public:
EqualsExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() == myRHS->evaluate(); }
};
@ -134,7 +134,7 @@ class EquateExpression : public Expression
{
public:
EquateExpression(const string& label) : Expression(), myLabel(label) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return Debugger::debugger().cartDebug().getAddress(myLabel); }
private:
@ -146,7 +146,7 @@ class FunctionExpression : public Expression
{
public:
FunctionExpression(const string& label) : Expression(), myLabel(label) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return Debugger::debugger().getFunction(myLabel).evaluate(); }
private:
@ -158,7 +158,7 @@ class GreaterEqualsExpression : public Expression
{
public:
GreaterEqualsExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() >= myRHS->evaluate(); }
};
@ -167,7 +167,7 @@ class GreaterExpression : public Expression
{
public:
GreaterExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() > myRHS->evaluate(); }
};
@ -176,7 +176,7 @@ class HiByteExpression : public Expression
{
public:
HiByteExpression(Expression* left) : Expression(left) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return 0xff & (myLHS->evaluate() >> 8); }
};
@ -185,7 +185,7 @@ class LessEqualsExpression : public Expression
{
public:
LessEqualsExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() <= myRHS->evaluate(); }
};
@ -194,7 +194,7 @@ class LessExpression : public Expression
{
public:
LessExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() < myRHS->evaluate(); }
};
@ -203,7 +203,7 @@ class LoByteExpression : public Expression
{
public:
LoByteExpression(Expression* left) : Expression(left) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return 0xff & myLHS->evaluate(); }
};
@ -212,7 +212,7 @@ class LogAndExpression : public Expression
{
public:
LogAndExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() && myRHS->evaluate(); }
};
@ -221,7 +221,7 @@ class LogNotExpression : public Expression
{
public:
LogNotExpression(Expression* left) : Expression(left) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return !(myLHS->evaluate()); }
};
@ -230,7 +230,7 @@ class LogOrExpression : public Expression
{
public:
LogOrExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() || myRHS->evaluate(); }
};
@ -239,7 +239,7 @@ class MinusExpression : public Expression
{
public:
MinusExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() - myRHS->evaluate(); }
};
@ -248,7 +248,7 @@ class ModExpression : public Expression
{
public:
ModExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ int rhs = myRHS->evaluate();
return rhs == 0 ? 0 : myLHS->evaluate() % rhs; }
};
@ -258,7 +258,7 @@ class MultExpression : public Expression
{
public:
MultExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() * myRHS->evaluate(); }
};
@ -267,7 +267,7 @@ class NotEqualsExpression : public Expression
{
public:
NotEqualsExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() != myRHS->evaluate(); }
};
@ -276,7 +276,7 @@ class PlusExpression : public Expression
{
public:
PlusExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() + myRHS->evaluate(); }
};
@ -285,7 +285,7 @@ class CartMethodExpression : public Expression
{
public:
CartMethodExpression(CartMethod method) : Expression(), myMethod(std::mem_fn(method)) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myMethod(Debugger::debugger().cartDebug()); }
private:
@ -297,7 +297,7 @@ class ShiftLeftExpression : public Expression
{
public:
ShiftLeftExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() << myRHS->evaluate(); }
};
@ -306,7 +306,7 @@ class ShiftRightExpression : public Expression
{
public:
ShiftRightExpression(Expression* left, Expression* right) : Expression(left, right) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myLHS->evaluate() >> myRHS->evaluate(); }
};
@ -315,7 +315,7 @@ class TiaMethodExpression : public Expression
{
public:
TiaMethodExpression(TiaMethod method) : Expression(), myMethod(std::mem_fn(method)) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return myMethod(Debugger::debugger().tiaDebug()); }
private:
@ -327,7 +327,7 @@ class UnaryMinusExpression : public Expression
{
public:
UnaryMinusExpression(Expression* left) : Expression(left) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return -(myLHS->evaluate()); }
};
@ -336,7 +336,7 @@ class WordDerefExpression : public Expression
{
public:
WordDerefExpression(Expression* left) : Expression(left) { }
uInt16 evaluate() const override
uInt32 evaluate() const override
{ return Debugger::debugger().dpeek(myLHS->evaluate()); }
};

View File

@ -66,8 +66,8 @@ DebuggerParser::DebuggerParser(Debugger& d, Settings& s)
// main entry point: PromptWidget calls this method.
string DebuggerParser::run(const string& command)
{
/*
// this was our parser test code. Left for reference.
#if 0
// this was our parser test code. Left for reference.
static Expression *lastExpression;
// special case: parser testing
@ -99,14 +99,10 @@ string DebuggerParser::run(const string& command)
commandResult = "no valid expr";
return commandResult;
}
*/
#endif
string verb;
getArgs(command, verb);
#ifdef EXPR_REF_COUNT
extern int refCount;
cerr << "Expression count: " << refCount << endl;
#endif
commandResult.str("");
for(int i = 0; i < kNumCommands; ++i)
@ -373,24 +369,9 @@ bool DebuggerParser::getArgs(const string& command, string& verb)
if(curArg != "")
argStrings.push_back(curArg);
argCount = int(argStrings.size());
/*
cerr << "verb = " << verb << endl;
cerr << "arguments (" << argCount << "):\n";
for(int x = 0; x < argCount; x++)
cerr << "command " << x << ": " << argStrings[x] << endl;
*/
argCount = uInt32(argStrings.size());
/*
// Now decipher each argument, in turn.
for(int i=0; i<argCount; i++) {
int temp = decipher_arg(argStrings[i]);
args.push_back(temp); // value maybe -1, if not expression argument
// (validate_args will decide whether that's OK, not us.)
}
*/
for(int arg = 0; arg < argCount; ++arg)
for(uInt32 arg = 0; arg < argCount; ++arg)
{
if(!YaccParser::parse(argStrings[arg].c_str()))
{
@ -423,7 +404,7 @@ bool DebuggerParser::validateArgs(int cmd)
}
// Figure out how many arguments are required by the command
int count = 0, argRequiredCount = 0;
uInt32 count = 0, argRequiredCount = 0;
while(*p != kARG_END_ARGS && *p != kARG_MULTI_BYTE)
{
count++;
@ -435,19 +416,19 @@ bool DebuggerParser::validateArgs(int cmd)
argRequiredCount = (*p == kARG_END_ARGS) ? count : argCount;
p = commands[cmd].parms;
int curCount = 0;
uInt32 curCount = 0;
do {
if(curCount >= argCount)
break;
int curArgInt = args[curCount];
uInt32 curArgInt = args[curCount];
string& curArgStr = argStrings[curCount];
switch(*p)
{
case kARG_WORD:
if(curArgInt < 0 || curArgInt > 0xffff)
if(curArgInt > 0xffff)
{
commandResult.str(red("invalid word argument (must be 0-$ffff)"));
return false;
@ -455,7 +436,7 @@ bool DebuggerParser::validateArgs(int cmd)
break;
case kARG_BYTE:
if(curArgInt < 0 || curArgInt > 0xff)
if(curArgInt > 0xff)
{
commandResult.str(red("invalid byte argument (must be 0-$ff)"));
return false;
@ -519,7 +500,7 @@ cerr << "curCount = " << curCount << endl
string DebuggerParser::eval()
{
ostringstream buf;
for(int i = 0; i < argCount; ++i)
for(uInt32 i = 0; i < argCount; ++i)
{
string rlabel = debugger.cartDebug().getLabel(args[i], true);
string wlabel = debugger.cartDebug().getLabel(args[i], false);
@ -665,7 +646,7 @@ void DebuggerParser::executeBase()
// "break"
void DebuggerParser::executeBreak()
{
int bp;
uInt16 bp;
if(argCount == 0)
bp = debugger.cpuDebug().pc();
else
@ -718,7 +699,7 @@ void DebuggerParser::executeCheat()
return;
}
for(int arg = 0; arg < argCount; arg++)
for(uInt32 arg = 0; arg < argCount; ++arg)
{
const string& cheat = argStrings[arg];
if(debugger.myOSystem.cheat().add("DBG", cheat))
@ -1053,7 +1034,7 @@ void DebuggerParser::executeListbreaks()
ostringstream buf;
int count = 0;
for(uInt32 i = 0; i < 0x10000; i++)
for(uInt32 i = 0; i <= 0xffff; ++i)
{
if(debugger.breakPoints().isSet(i))
{
@ -1117,7 +1098,7 @@ void DebuggerParser::executeListtraps()
{
int count = 0;
for(uInt32 i = 0; i < 0x10000; ++i)
for(uInt32 i = 0; i <= 0xffff; ++i)
{
if(debugger.readTrap(i) || debugger.writeTrap(i))
{
@ -1243,10 +1224,10 @@ void DebuggerParser::executeRiot()
// "rom"
void DebuggerParser::executeRom()
{
int addr = args[0];
for(int i = 1; i < argCount; ++i)
uInt16 addr = args[0];
for(uInt32 i = 1; i < argCount; ++i)
{
if( !(debugger.patchROM(addr++, args[i])) )
if(!(debugger.patchROM(addr++, args[i])))
{
commandResult << red("patching ROM unsupported for this cart type");
return;
@ -1301,7 +1282,7 @@ void DebuggerParser::executeRunTo()
const CartDebug& cartdbg = debugger.cartDebug();
const CartDebug::DisassemblyList& list = cartdbg.disassembly().list;
uInt32 count = 0, max_iterations = int(list.size());
uInt32 count = 0, max_iterations = uInt32(list.size());
// Create a progress dialog box to show the progress searching through the
// disassembly, since this may be a time-consuming operation
@ -1352,8 +1333,7 @@ void DebuggerParser::executeRunToPc()
// Update romlist to point to current PC
int pcline = cartdbg.addressToLine(debugger.cpuDebug().pc());
done = (pcline >= 0) && (list[pcline].address == args[0]);
++count;
} while(!done && count < list.size());
} while(!done && ++count < list.size());
if(done)
commandResult
@ -1683,10 +1663,10 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{
"a",
"Set Accumulator to <value>",
"Valid value is 0 - 255\nExample: a ff, a #10",
"Valid value is 0 - ff\nExample: a ff, a #10",
true,
true,
{ kARG_WORD, kARG_END_ARGS },
{ kARG_BYTE, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeA)
},
@ -1703,7 +1683,8 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{
"break",
"Set/clear breakpoint at <address>",
"Command is a toggle, default is current PC\n:Example: break, break f000",
"Command is a toggle, default is current PC\nValid address is 0 - ffff\n"
"Example: break, break f000",
false,
true,
{ kARG_WORD, kARG_END_ARGS },
@ -1806,7 +1787,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
"Shows a color swatch for the given value\nExample: colortest 1f",
true,
false,
{ kARG_WORD, kARG_END_ARGS },
{ kARG_BYTE, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeColortest)
},
@ -2028,7 +2009,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
"Example: loadstate 0, loadstate 9",
true,
true,
{ kARG_WORD, kARG_END_ARGS },
{ kARG_BYTE, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeLoadstate)
},
@ -2178,10 +2159,10 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{
"s",
"Set Stack Pointer to value xx",
"Example: s f0",
"Accepts 8-bit value, Example: s f0",
true,
true,
{ kARG_WORD, kARG_END_ARGS },
{ kARG_BYTE, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeS)
},
@ -2252,7 +2233,7 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
"Example: savestate 0, savestate 9",
true,
false,
{ kARG_WORD, kARG_END_ARGS },
{ kARG_BYTE, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeSavestate)
},
@ -2383,20 +2364,20 @@ DebuggerParser::Command DebuggerParser::commands[kNumCommands] = {
{
"x",
"Set X Register to value xx",
"Valid value is 0 - 255\nExample: x ff, x #10",
"Valid value is 0 - ff\nExample: x ff, x #10",
true,
true,
{ kARG_WORD, kARG_END_ARGS },
{ kARG_BYTE, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeX)
},
{
"y",
"Set Y Register to value xx",
"Valid value is 0 - 255\nExample: y ff, y #10",
"Valid value is 0 - ff\nExample: y ff, y #10",
true,
true,
{ kARG_WORD, kARG_END_ARGS },
{ kARG_BYTE, kARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeY)
},

View File

@ -112,7 +112,7 @@ class DebuggerParser
// Arguments in 'int' and 'string' format for the currently running command
IntArray args;
StringList argStrings;
int argCount;
uInt32 argCount;
StringList watches;

View File

@ -35,7 +35,7 @@ class Expression
: myLHS(lhs), myRHS(rhs) { }
virtual ~Expression() = default;
virtual uInt16 evaluate() const { return 0; }
virtual uInt32 evaluate() const { return 0; }
protected:
unique_ptr<Expression> myLHS, myRHS;

View File

@ -27,12 +27,12 @@ class PackedBitArray
public:
PackedBitArray() : myInitialized(false) { }
bool isSet(uInt32 bit) const { return myBits[bit]; }
bool isClear(uInt32 bit) const { return !myBits[bit]; }
bool isSet(uInt16 bit) const { return myBits[bit]; }
bool isClear(uInt16 bit) const { return !myBits[bit]; }
void set(uInt32 bit) { myBits[bit] = true; }
void clear(uInt32 bit) { myBits[bit] = false; }
void toggle(uInt32 bit) { myBits.flip(bit); }
void set(uInt16 bit) { myBits[bit] = true; }
void clear(uInt16 bit) { myBits[bit] = false; }
void toggle(uInt16 bit) { myBits.flip(bit); }
void initialize() { myInitialized = true; }
void clearAll() { myInitialized = false; myBits.reset(); }

View File

@ -93,8 +93,8 @@ expression: expression '+' expression { if(DEBUG_EXP) fprintf(stderr, " +"); $$
| '>' expression { if(DEBUG_EXP) fprintf(stderr, " U>"); $$ = new HiByteExpression($2); lastExp = $$; }
| '(' expression ')' { if(DEBUG_EXP) fprintf(stderr, " ()"); $$ = $2; lastExp = $$; }
| expression '[' expression ']' { if(DEBUG_EXP) fprintf(stderr, " []"); $$ = new ByteDerefOffsetExpression($1, $3); lastExp = $$; }
| NUMBER { if(DEBUG_EXP) fprintf(stderr, " %d", $1); $$ = new ConstExpression($1); lastExp = $$; }
| EQUATE { if(DEBUG_EXP) fprintf(stderr, " %s", $1); $$ = new EquateExpression($1); lastExp = $$; }
| NUMBER { if(DEBUG_EXP) fprintf(stderr, "const %d", $1); $$ = new ConstExpression($1); lastExp = $$; }
| EQUATE { if(DEBUG_EXP) fprintf(stderr, "equate %s", $1); $$ = new EquateExpression($1); lastExp = $$; }
| CPU_METHOD { if(DEBUG_EXP) fprintf(stderr, " (CpuMethod)"); $$ = new CpuMethodExpression($1); lastExp = $$; }
| CART_METHOD { if(DEBUG_EXP) fprintf(stderr, " (CartMethod)"); $$ = new CartMethodExpression($1); lastExp = $$; }
| TIA_METHOD { if(DEBUG_EXP) fprintf(stderr, " (TiaMethod)"); $$ = new TiaMethodExpression($1); lastExp = $$; }

View File

@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 3.0.2. */
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -44,7 +44,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "3.0.2"
#define YYBISON_VERSION "3.0.4"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@ -166,7 +166,7 @@ extern int yydebug;
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
#line 28 "stella.y" /* yacc.c:355 */
@ -181,6 +181,8 @@ union YYSTYPE
#line 183 "y.tab.c" /* yacc.c:355 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
@ -194,7 +196,7 @@ int yyparse (void);
/* Copy the second part of user declarations. */
#line 198 "y.tab.c" /* yacc.c:358 */
#line 200 "y.tab.c" /* yacc.c:358 */
#ifdef short
# undef short
@ -1338,215 +1340,215 @@ yyreduce:
case 2:
#line 66 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, "\ndone\n"); result.exp = (yyvsp[0].exp); }
#line 1342 "y.tab.c" /* yacc.c:1646 */
#line 1344 "y.tab.c" /* yacc.c:1646 */
break;
case 3:
#line 69 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " +"); (yyval.exp) = new PlusExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1348 "y.tab.c" /* yacc.c:1646 */
#line 1350 "y.tab.c" /* yacc.c:1646 */
break;
case 4:
#line 70 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " -"); (yyval.exp) = new MinusExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1354 "y.tab.c" /* yacc.c:1646 */
#line 1356 "y.tab.c" /* yacc.c:1646 */
break;
case 5:
#line 71 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " *"); (yyval.exp) = new MultExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1360 "y.tab.c" /* yacc.c:1646 */
#line 1362 "y.tab.c" /* yacc.c:1646 */
break;
case 6:
#line 72 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " /"); (yyval.exp) = new DivExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1366 "y.tab.c" /* yacc.c:1646 */
#line 1368 "y.tab.c" /* yacc.c:1646 */
break;
case 7:
#line 73 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " %%"); (yyval.exp) = new ModExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1372 "y.tab.c" /* yacc.c:1646 */
#line 1374 "y.tab.c" /* yacc.c:1646 */
break;
case 8:
#line 74 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " &"); (yyval.exp) = new BinAndExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1378 "y.tab.c" /* yacc.c:1646 */
#line 1380 "y.tab.c" /* yacc.c:1646 */
break;
case 9:
#line 75 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " |"); (yyval.exp) = new BinOrExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1384 "y.tab.c" /* yacc.c:1646 */
#line 1386 "y.tab.c" /* yacc.c:1646 */
break;
case 10:
#line 76 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " ^"); (yyval.exp) = new BinXorExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1390 "y.tab.c" /* yacc.c:1646 */
#line 1392 "y.tab.c" /* yacc.c:1646 */
break;
case 11:
#line 77 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " <"); (yyval.exp) = new LessExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1396 "y.tab.c" /* yacc.c:1646 */
#line 1398 "y.tab.c" /* yacc.c:1646 */
break;
case 12:
#line 78 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " >"); (yyval.exp) = new GreaterExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1402 "y.tab.c" /* yacc.c:1646 */
#line 1404 "y.tab.c" /* yacc.c:1646 */
break;
case 13:
#line 79 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " >="); (yyval.exp) = new GreaterEqualsExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1408 "y.tab.c" /* yacc.c:1646 */
#line 1410 "y.tab.c" /* yacc.c:1646 */
break;
case 14:
#line 80 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " <="); (yyval.exp) = new LessEqualsExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1414 "y.tab.c" /* yacc.c:1646 */
#line 1416 "y.tab.c" /* yacc.c:1646 */
break;
case 15:
#line 81 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " !="); (yyval.exp) = new NotEqualsExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1420 "y.tab.c" /* yacc.c:1646 */
#line 1422 "y.tab.c" /* yacc.c:1646 */
break;
case 16:
#line 82 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " =="); (yyval.exp) = new EqualsExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1426 "y.tab.c" /* yacc.c:1646 */
#line 1428 "y.tab.c" /* yacc.c:1646 */
break;
case 17:
#line 83 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " >>"); (yyval.exp) = new ShiftRightExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1432 "y.tab.c" /* yacc.c:1646 */
#line 1434 "y.tab.c" /* yacc.c:1646 */
break;
case 18:
#line 84 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " <<"); (yyval.exp) = new ShiftLeftExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1438 "y.tab.c" /* yacc.c:1646 */
#line 1440 "y.tab.c" /* yacc.c:1646 */
break;
case 19:
#line 85 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " ||"); (yyval.exp) = new LogOrExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1444 "y.tab.c" /* yacc.c:1646 */
#line 1446 "y.tab.c" /* yacc.c:1646 */
break;
case 20:
#line 86 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " &&"); (yyval.exp) = new LogAndExpression((yyvsp[-2].exp), (yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1450 "y.tab.c" /* yacc.c:1646 */
#line 1452 "y.tab.c" /* yacc.c:1646 */
break;
case 21:
#line 87 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " U-"); (yyval.exp) = new UnaryMinusExpression((yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1456 "y.tab.c" /* yacc.c:1646 */
#line 1458 "y.tab.c" /* yacc.c:1646 */
break;
case 22:
#line 88 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " ~"); (yyval.exp) = new BinNotExpression((yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1462 "y.tab.c" /* yacc.c:1646 */
#line 1464 "y.tab.c" /* yacc.c:1646 */
break;
case 23:
#line 89 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " !"); (yyval.exp) = new LogNotExpression((yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1468 "y.tab.c" /* yacc.c:1646 */
#line 1470 "y.tab.c" /* yacc.c:1646 */
break;
case 24:
#line 90 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " U*"); (yyval.exp) = new ByteDerefExpression((yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1474 "y.tab.c" /* yacc.c:1646 */
#line 1476 "y.tab.c" /* yacc.c:1646 */
break;
case 25:
#line 91 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " U@"); (yyval.exp) = new WordDerefExpression((yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1480 "y.tab.c" /* yacc.c:1646 */
#line 1482 "y.tab.c" /* yacc.c:1646 */
break;
case 26:
#line 92 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " U<"); (yyval.exp) = new LoByteExpression((yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1486 "y.tab.c" /* yacc.c:1646 */
#line 1488 "y.tab.c" /* yacc.c:1646 */
break;
case 27:
#line 93 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " U>"); (yyval.exp) = new HiByteExpression((yyvsp[0].exp)); lastExp = (yyval.exp); }
#line 1492 "y.tab.c" /* yacc.c:1646 */
#line 1494 "y.tab.c" /* yacc.c:1646 */
break;
case 28:
#line 94 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " ()"); (yyval.exp) = (yyvsp[-1].exp); lastExp = (yyval.exp); }
#line 1498 "y.tab.c" /* yacc.c:1646 */
#line 1500 "y.tab.c" /* yacc.c:1646 */
break;
case 29:
#line 95 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " []"); (yyval.exp) = new ByteDerefOffsetExpression((yyvsp[-3].exp), (yyvsp[-1].exp)); lastExp = (yyval.exp); }
#line 1504 "y.tab.c" /* yacc.c:1646 */
#line 1506 "y.tab.c" /* yacc.c:1646 */
break;
case 30:
#line 96 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " %d", (yyvsp[0].val)); (yyval.exp) = new ConstExpression((yyvsp[0].val)); lastExp = (yyval.exp); }
#line 1510 "y.tab.c" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, "const %d", (yyvsp[0].val)); (yyval.exp) = new ConstExpression((yyvsp[0].val)); lastExp = (yyval.exp); }
#line 1512 "y.tab.c" /* yacc.c:1646 */
break;
case 31:
#line 97 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " %s", (yyvsp[0].Equate)); (yyval.exp) = new EquateExpression((yyvsp[0].Equate)); lastExp = (yyval.exp); }
#line 1516 "y.tab.c" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, "equate %s", (yyvsp[0].Equate)); (yyval.exp) = new EquateExpression((yyvsp[0].Equate)); lastExp = (yyval.exp); }
#line 1518 "y.tab.c" /* yacc.c:1646 */
break;
case 32:
#line 98 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " (CpuMethod)"); (yyval.exp) = new CpuMethodExpression((yyvsp[0].cpuMethod)); lastExp = (yyval.exp); }
#line 1522 "y.tab.c" /* yacc.c:1646 */
#line 1524 "y.tab.c" /* yacc.c:1646 */
break;
case 33:
#line 99 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " (CartMethod)"); (yyval.exp) = new CartMethodExpression((yyvsp[0].cartMethod)); lastExp = (yyval.exp); }
#line 1528 "y.tab.c" /* yacc.c:1646 */
#line 1530 "y.tab.c" /* yacc.c:1646 */
break;
case 34:
#line 100 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " (TiaMethod)"); (yyval.exp) = new TiaMethodExpression((yyvsp[0].tiaMethod)); lastExp = (yyval.exp); }
#line 1534 "y.tab.c" /* yacc.c:1646 */
#line 1536 "y.tab.c" /* yacc.c:1646 */
break;
case 35:
#line 101 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " (DefinedFunction)"); (yyval.exp) = new FunctionExpression((yyvsp[0].DefinedFunction)); lastExp = (yyval.exp); }
#line 1540 "y.tab.c" /* yacc.c:1646 */
#line 1542 "y.tab.c" /* yacc.c:1646 */
break;
case 36:
#line 102 "stella.y" /* yacc.c:1646 */
{ if(DEBUG_EXP) fprintf(stderr, " ERR: "); yyerror((char*)"Invalid label or constant"); return 1; }
#line 1546 "y.tab.c" /* yacc.c:1646 */
#line 1548 "y.tab.c" /* yacc.c:1646 */
break;
#line 1550 "y.tab.c" /* yacc.c:1646 */
#line 1552 "y.tab.c" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires

View File

@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 3.0.2. */
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -87,7 +87,7 @@ extern int yydebug;
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
#line 28 "stella.y" /* yacc.c:1909 */
@ -102,6 +102,8 @@ union YYSTYPE
#line 104 "y.tab.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif