A bit of cleanup.

This commit is contained in:
2022-10-04 21:05:15 +00:00
parent 33309a2759
commit f38da9cc74
2 changed files with 2 additions and 28 deletions
+2
View File
@@ -4,6 +4,8 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "list.h" #include "list.h"
#include "token.h" #include "token.h"
#include "opcodes.h" #include "opcodes.h"
-28
View File
@@ -1,10 +1,5 @@
#include "../includes/parser.h" #include "../includes/parser.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
Symbol* CreateSymbol(Token* token, int length, int address, int resolved);
const List* TokensList; const List* TokensList;
int CurrentToken = 0; int CurrentToken = 0;
@@ -15,7 +10,6 @@ void AdvanceParser(void);
void IgnoreParserLine(void); void IgnoreParserLine(void);
Token* PeekToken(void); Token* PeekToken(void);
int ParserAtEnd(void); int ParserAtEnd(void);
int Expect(int, ...);
IRState MachineState; IRState MachineState;
IRState* ParseTokens(List* tokens) { IRState* ParseTokens(List* tokens) {
@@ -126,7 +120,6 @@ Parameter* GetParameterType() {
else { else {
fprintf(stderr, "[Error] Line %d: Expected identifier, constant number or register.\n", token->LineNumber); fprintf(stderr, "[Error] Line %d: Expected identifier, constant number or register.\n", token->LineNumber);
IgnoreParserLine(); IgnoreParserLine();
AdvanceParser(); //Consume NewLine
//return NULL; //return NULL;
exit(1); exit(1);
} }
@@ -174,7 +167,6 @@ void HandleOperation() {
goto InsertInstruction; goto InsertInstruction;
} }
//ins->ParameterOne->ParameterType = GetParameterType(&token);
ins->ParameterOne = GetParameterType(); ins->ParameterOne = GetParameterType();
if (ins->ParameterOne->ParameterType == NoParameter) { if (ins->ParameterOne->ParameterType == NoParameter) {
@@ -199,7 +191,6 @@ void HandleOperation() {
AdvanceParser(); //Consume the comma AdvanceParser(); //Consume the comma
//ins->ParameterTwo->ParameterType = GetParameterType(&token);
ins->ParameterTwo = GetParameterType(); ins->ParameterTwo = GetParameterType();
InsertInstruction: InsertInstruction:
@@ -211,25 +202,6 @@ void HandleOperation() {
free(ins); free(ins);
} }
int Expect(int count, ...) {
va_list list;
Token* token = PeekToken();
va_start(list, count);
for(int i = 0; i < count; i++) {
if (va_arg(list, TokenClass) == token->Class) {
va_end(list);
AdvanceParser();
return 1;
}
}
va_end(list);
return 0;
}
void PrintSymbols(void) { void PrintSymbols(void) {
printf("-----SYMBOLS-----\n"); printf("-----SYMBOLS-----\n");
for(int i = 0; i < MachineState.SymbolsTable->Size; i++) { for(int i = 0; i < MachineState.SymbolsTable->Size; i++) {