%extra_argument { Debug::Command *command } %token_prefix tk %token_type {uint32_t} %include { #include #include #include #include #include "debugger.h" #include #ifdef __cplusplus extern "C" { #endif uint32_t cpuGetSR(); uint32_t cpuGetPC(); uint32_t cpuGetAReg(unsigned); uint32_t cpuGetDReg(unsigned); #ifdef __cplusplus } #endif #undef NDEBUG } %parse_failure { //fprintf(stderr,"I don't understand.\n"); command->valid = false; } %parse_accept { command->valid = true; } %left PIPEPIPE. %left AMPAMP. %left PIPE. %left CARET. %left AMP. %left EQEQ BANGEQ. %left LT LTEQ GT GTEQ. %left LTLT GTGT. %left PLUS MINUS. %left STAR SLASH PERCENT. %right BANG TILDE. stmt ::= expr(a) EOL. { Debug::Print(a); } stmt ::= STAR EOL. { Debug::PrintRegisters(); } stmt ::= PRINT expr(a) EOL. { Debug::Print(a); } stmt ::= BREAK EOL. { Debug::Break(); } stmt ::= BREAK expr(a) EOL. { Debug::Break(a); } stmt ::= CONTINUE EOL. { command->action = Debug::cmdContinue; command->argc = 0; } stmt ::= TBREAK EOL. { Debug::ToolBreak(); } stmt ::= TBREAK expr(a) EOL. { Debug::ToolBreak(a); } stmt ::= RBREAK EOL . { Debug::ReadBreak(); } stmt ::= RBREAK expr(a) EOL. { Debug::ReadBreak(a); } stmt ::= WBREAK EOL. { Debug::WriteBreak(); } stmt ::= WBREAK expr(a) EOL. { Debug::WriteBreak(a); } stmt ::= RWBREAK expr(a) EOL . { Debug::ReadWriteBreak(a); } stmt ::= NEXT EOL. { command->action = Debug::cmdStep; command->argc = 0; } stmt ::= NEXT expr(a) EOL. { command->action = Debug::cmdStep; command->argc = 1; command->argv[0] = a; } stmt ::= DUMP expr(a) EOL. { Debug::Dump(a); } stmt ::= DUMP expr(a) COLON expr(b) EOL. { Debug::Dump(a, b - a); } stmt ::= DUMP expr(a) AT expr(b) EOL. { Debug::Dump(a, b); } stmt ::= LIST expr(a) EOL. { Debug::List(a); } stmt ::= expr(a) SEMIH EOL. { Debug::Dump(a); } stmt ::= expr(a) COLON expr(b) SEMIH EOL. { Debug::Dump(a, b - a); } stmt ::= expr(a) AT expr(b) SEMIH EOL. { Debug::Dump(a, b); } stmt ::= expr(a) SEMII EOL. { MM::Native::MemoryInfo(a); } stmt ::= expr(a) SEMIL EOL. { Debug::List(a); } stmt ::= expr(a) AT expr(b) SEMIL EOL. { Debug::List(a, (int)b); } stmt ::= expr(a) COLON expr(b) SEMIL EOL. { Debug::List(a, b); } stmt ::= DREGISTER(a) EQ expr(b) EOL. { Debug::SetDRegister(a, b); } stmt ::= AREGISTER(a) EQ expr(b) EOL. { Debug::SetARegister(a, b); } stmt ::= XREGISTER(a) EQ expr(b) EOL. { Debug::SetXRegister(a, b); } stmt ::= HELP EOL. { Debug::Help(); } expr(rhs) ::= unary(a). { rhs = a; } expr(rhs) ::= expr(a) PLUS expr(b). { rhs = a + b; } expr(rhs) ::= expr(a) MINUS expr(b). { rhs = a - b; } expr(rhs) ::= expr(a) STAR expr(b). { rhs = a * b; } expr(rhs) ::= expr(a) SLASH expr(b). { rhs = a / b; } expr(rhs) ::= expr(a) PERCENT expr(b). { rhs = a % b; } expr(rhs) ::= expr(a) LTLT expr(b). { rhs = a << b; } expr(rhs) ::= expr(a) GTGT expr(b). { rhs = a >> b; } expr(rhs) ::= expr(a) LT expr(b). { rhs = a < b; } expr(rhs) ::= expr(a) LTEQ expr(b). { rhs = a <= b; } expr(rhs) ::= expr(a) GT expr(b). { rhs = a > b; } expr(rhs) ::= expr(a) GTEQ expr(b). { rhs = a >= b; } expr(rhs) ::= expr(a) EQEQ expr(b). { rhs = a == b; } expr(rhs) ::= expr(a) BANGEQ expr(b). { rhs = a != b; } expr(rhs) ::= expr(a) AMP expr(b). { rhs = a & b; } expr(rhs) ::= expr(a) CARET expr(b). { rhs = a ^ b; } expr(rhs) ::= expr(a) PIPE expr(b). { rhs = a | b; } expr(rhs) ::= expr(a) AMPAMP expr(b). { rhs = a && b; } expr(rhs) ::= expr(a) PIPEPIPE expr(b). { rhs = a || b; } unary(rhs) ::= term(a). { rhs = a; } unary(rhs) ::= PLUS unary(a). [BANG] { rhs = a; } unary(rhs) ::= MINUS unary(a). [BANG] { rhs = -a; } unary(rhs) ::= TILDE unary(a). { rhs = ~a; } unary(rhs) ::= BANG unary(a). { rhs = !a; } unary(rhs) ::= STAR unary(a). [BANG] { rhs = Debug::ReadLong(a); } term(rhs) ::= LPAREN expr(a) RPAREN. { rhs = a; } term(rhs) ::= INTEGER(a). { rhs = a; } term(rhs) ::= DREGISTER(a). { rhs = cpuGetDReg(a); } term(rhs) ::= AREGISTER(a). { rhs = cpuGetAReg(a); } term(rhs) ::= XREGISTER(a). { switch(a) { case 0: rhs = cpuGetPC(); break; case 1: rhs = cpuGetSR(); break; default: rhs = 0; } }