mirror of
https://github.com/ksherlock/mpw.git
synced 2024-12-25 20:29:36 +00:00
debug parser update
This commit is contained in:
parent
dccdd7cb26
commit
8c0e3f04ac
@ -2,6 +2,7 @@
|
|||||||
#define __debugger_commands__
|
#define __debugger_commands__
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
Help,
|
||||||
Print,
|
Print,
|
||||||
Dump,
|
Dump,
|
||||||
List,
|
List,
|
||||||
|
@ -260,12 +260,12 @@ bool ParseLine(const char *iter, Command *command)
|
|||||||
}
|
}
|
||||||
|
|
||||||
'n' | 'next' {
|
'n' | 'next' {
|
||||||
Parse(&parser, tkSTEP, 0, command);
|
Parse(&parser, tkNEXT, 0, command);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
's' | 'step' {
|
's' | 'step' {
|
||||||
Parse(&parser, tkSTEP, 0, command);
|
Parse(&parser, tkNEXT, 0, command);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,12 +275,12 @@ bool ParseLine(const char *iter, Command *command)
|
|||||||
}
|
}
|
||||||
|
|
||||||
'g' | 'go' {
|
'g' | 'go' {
|
||||||
Parse(&parser, tkGO, 0, command);
|
Parse(&parser, tkCONTINUE, 0, command);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
'r' | 'run' {
|
'r' | 'run' {
|
||||||
Parse(&parser, tkRUN, 0, command);
|
Parse(&parser, tkCONTINUE, 0, command);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,6 @@ bool ParseLine(const char *iter, Command *command)
|
|||||||
|
|
||||||
[\x00] {
|
[\x00] {
|
||||||
// eol.
|
// eol.
|
||||||
Parse(&parser, tkEOL, 0, command);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,19 @@
|
|||||||
%extra_argument { struct Command *command }
|
%extra_argument { struct Command *command }
|
||||||
%token_prefix tk
|
%token_prefix tk
|
||||||
|
|
||||||
%token_type {uint32_t}
|
%token_type {uint32_t}
|
||||||
|
%include {
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include "commands.h"
|
||||||
|
|
||||||
|
uint32_t cpuGetSR();
|
||||||
|
uint32_t cpuGetPC();
|
||||||
|
uint32_t cpuGetAReg(unsigned);
|
||||||
|
uint32_t cpuGetDReg(unsigned);
|
||||||
|
uint32_t debuggerReadLong(uint32_t);
|
||||||
|
}
|
||||||
|
|
||||||
%parse_failure {
|
%parse_failure {
|
||||||
fprintf(stderr,"I don't understand.\n");
|
fprintf(stderr,"I don't understand.\n");
|
||||||
@ -15,6 +26,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%left PIPEPIPE.
|
%left PIPEPIPE.
|
||||||
%left AMPAMP.
|
%left AMPAMP.
|
||||||
%left PIPE.
|
%left PIPE.
|
||||||
@ -28,12 +40,9 @@
|
|||||||
%right BANG TILDE.
|
%right BANG TILDE.
|
||||||
|
|
||||||
|
|
||||||
|
stmt ::= expr(a).
|
||||||
|
|
||||||
|
|
||||||
stmt ::= assignment EOL.
|
|
||||||
stmt ::= expr(a) EOL.
|
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
// print the value.
|
// print the value.
|
||||||
// hex, base 10, signed 16-bit (if appropriate)
|
// hex, base 10, signed 16-bit (if appropriate)
|
||||||
printf("$%08x - %u", a, a);
|
printf("$%08x - %u", a, a);
|
||||||
@ -45,73 +54,110 @@ stmt ::= expr(a) EOL.
|
|||||||
printf(" %h", (int16_t)a);
|
printf(" %h", (int16_t)a);
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
*/
|
||||||
command->action = PRINT;
|
command->action = Print;
|
||||||
command->arg = a;
|
command->argc = 1;
|
||||||
|
command->argv[0] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt ::= BREAK expr(a) EOL.
|
stmt ::= BREAK expr(a).
|
||||||
{
|
{
|
||||||
command->action = tkBREAK;
|
command->action = Break;
|
||||||
command->arg = a;
|
command->argc = 1;
|
||||||
|
command->argv[0] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt ::= NEXT EOL.
|
stmt ::= CONTINUE.
|
||||||
{
|
{
|
||||||
command->action = tkNEXT;
|
command->action = Continue;
|
||||||
command->arg = 1;
|
command->argc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt ::= NEXT expr(a) EOL.
|
stmt ::= TBREAK expr(a).
|
||||||
{
|
{
|
||||||
command->action = tkNEXT;
|
// negative number = remove it.
|
||||||
command->arg = a;
|
command->action = TBreak;
|
||||||
|
command->argc = 1;
|
||||||
|
command->argv[0] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt ::= PRINT expr(a) EOL.
|
stmt ::= NEXT.
|
||||||
{
|
{
|
||||||
command->action = tkPRINT;
|
command->action = Step;
|
||||||
command->arg = a;
|
command->argc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt ::= DUMP expr(a) EOL .
|
stmt ::= NEXT expr(a).
|
||||||
{
|
{
|
||||||
command->action = tkDUMP;
|
command->action = Step;
|
||||||
command->arg = a;
|
command->argc = 1;
|
||||||
|
command->argv[0] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt ::= LIST expr(a) EOL .
|
stmt ::= PRINT expr(a).
|
||||||
{
|
{
|
||||||
command->action = tkLIST;
|
command->action = Print;
|
||||||
command->arg = a;
|
command->argc = 1;
|
||||||
|
command->argv[0] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt ::= expr(a) SEMIL EOL.
|
stmt ::= DUMP expr(a).
|
||||||
{
|
{
|
||||||
command->action = tkLIST;
|
command->action = Dump;
|
||||||
command->arg = a;
|
command->argc = 1;
|
||||||
|
command->argv[0] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
stmt ::= expr(a) SEMIH EOL.
|
stmt ::= LIST expr(a).
|
||||||
{
|
{
|
||||||
command->action = tkDUMP;
|
command->action = List;
|
||||||
command->arg = a;
|
command->argc = 1;
|
||||||
|
command->argv[0] = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt ::= expr(a) SEMIL.
|
||||||
|
{
|
||||||
|
command->action = List;
|
||||||
|
command->argc = 1;
|
||||||
|
command->argv[0] = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt ::= expr(a) SEMIH.
|
||||||
|
{
|
||||||
|
command->action = Dump;
|
||||||
|
command->argc = 1;
|
||||||
|
command->argv[0] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
assignment ::= DREGISTER(a) EQ expr(b). { cpuSetDReg(a, b); }
|
stmt ::= DREGISTER(a) EQ expr(b).
|
||||||
assignment ::= AREGISTER(a) EQ expr(b). { cpuSetAReg(a, b); }
|
{
|
||||||
assignment ::= XREGISTER(a) EQ expr(b).
|
command->action = SetDRegister;
|
||||||
{
|
command->argc = 2;
|
||||||
switch(a)
|
command->argv[0] = a;
|
||||||
{
|
command->argv[1] = b;
|
||||||
case 0:
|
}
|
||||||
cpuSetPC(b);
|
|
||||||
break;
|
stmt ::= AREGISTER(a) EQ expr(b).
|
||||||
case 1:
|
{
|
||||||
cpuSetSR(b);
|
command->action = SetARegister;
|
||||||
break;
|
command->argc = 2;
|
||||||
}
|
command->argv[0] = a;
|
||||||
|
command->argv[1] = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt ::= XREGISTER(a) EQ expr(b).
|
||||||
|
{
|
||||||
|
command->action = SetXRegister;
|
||||||
|
command->argc = 2;
|
||||||
|
command->argv[0] = a;
|
||||||
|
command->argv[1] = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt ::= HELP .
|
||||||
|
{
|
||||||
|
command->action = Help;
|
||||||
|
command->argc = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
expr(rhs) ::= unary(a). { rhs = a; }
|
expr(rhs) ::= unary(a). { rhs = a; }
|
||||||
@ -140,7 +186,7 @@ unary(rhs) ::= PLUS unary(a). [BANG] { rhs = a; }
|
|||||||
unary(rhs) ::= MINUS unary(a). [BANG] { rhs = -a; }
|
unary(rhs) ::= MINUS unary(a). [BANG] { rhs = -a; }
|
||||||
unary(rhs) ::= TILDE unary(a). { rhs = ~a; }
|
unary(rhs) ::= TILDE unary(a). { rhs = ~a; }
|
||||||
unary(rhs) ::= BANG unary(a). { rhs = !a; }
|
unary(rhs) ::= BANG unary(a). { rhs = !a; }
|
||||||
unary(rhs) ::= STAR unary(a). [BANG] { rhs = cpuMemoryReadLong(a); }
|
unary(rhs) ::= STAR unary(a). [BANG] { rhs = debuggerReadLong(a); }
|
||||||
|
|
||||||
|
|
||||||
term(rhs) ::= LPAREN expr(a) RPAREN. { rhs = a; }
|
term(rhs) ::= LPAREN expr(a) RPAREN. { rhs = a; }
|
||||||
|
Loading…
Reference in New Issue
Block a user