diff --git a/src/parser.c b/src/parser.c index c91caa1..6902d5e 100644 --- a/src/parser.c +++ b/src/parser.c @@ -40,13 +40,14 @@ void ParseTokens(List* tokens) { case IDENTIFIER: case LABEL: AddSymbol(t, ProgramCounter); + AdvanceParser(); break; case STRING: ProgramCounter += strlen(t->lexeme); break; - case NUMBER: //Number's will be 2 bytes - ProgramCounter += 2; - break; + //case NUMBER: //Number's will be 2 bytes + // ProgramCounter += 2; + // break; default: //Instructions are 1 byte wide. if (t->token_class == Opcode) { ProgramCounter++; @@ -71,11 +72,15 @@ void HandleOperation(void) { AdvanceParser(); - if (inst->parameter_one && PeekToken()->token_class == 1) { + if (inst->parameter_one == None) return; + + if (inst->parameter_one && PeekToken()->token_class > 0) { printf("Matched '%s'\n", PeekToken()->lexeme); AdvanceParser(); } + if (inst->parameter_two == None) return; + if (PeekToken()->type == COMMA) { AdvanceParser(); } else { @@ -84,9 +89,12 @@ void HandleOperation(void) { return; } - if (inst->parameter_two && PeekToken()->token_class == 1) { + if (inst->parameter_two && PeekToken()->token_class > 0) { printf("Matched 2 '%s'\n", PeekToken()->lexeme); AdvanceParser(); + } else { + printf("Failed to match %s (class: %d)\n", PeekToken()->lexeme, PeekToken()->token_class); + printf("Inst %s (class: %x)\n", inst->lexeme, inst->parameter_two); } }