Started reworking the Parser to simplify how instructions will be represented. It will act like a 'first pass' that will do grammar checks but not verify the parameters of the opcodes.
This commit is contained in:
+10
-4
@@ -7,7 +7,6 @@
|
||||
#include "../includes/parser.h"
|
||||
#include "../includes/futil.h"
|
||||
#include "../includes/scanner.h"
|
||||
#include "../includes/disass.h"
|
||||
|
||||
int main(int argc, char* args[]) {
|
||||
if (argc == 1) {
|
||||
@@ -23,9 +22,16 @@ int main(int argc, char* args[]) {
|
||||
List* list = GenerateTokenList(source_code);
|
||||
char mnemonic[12];
|
||||
|
||||
printf("PRINTING TOKENS\n");
|
||||
|
||||
for(int i = 0; i < list->size; i++) {
|
||||
Token* t = (Token*) list->content[i];
|
||||
|
||||
if (t->EndOfFile) {
|
||||
printf("EOF\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (t->Class == PunctuationClass){
|
||||
if(t->Value.Punctuation == NewLine) {
|
||||
if(i - 1 >= 0 && (((Token*)list->content[i - 1])->Class == PunctuationClass && ((Token*)list->content[i - 1])->Value.Punctuation == NewLine)) continue;
|
||||
@@ -54,13 +60,13 @@ int main(int argc, char* args[]) {
|
||||
}
|
||||
|
||||
if (t->Class == NumberClass) {
|
||||
printf("%d ", t->Value.Number);
|
||||
printf("[N]%d ", t->Value.Number);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (t->Class == MnemonicClass) {
|
||||
GetMnemonicText(t->Value.Mnemonic, mnemonic);
|
||||
printf("%s ", mnemonic);
|
||||
printf("[M]%s ", mnemonic);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -74,7 +80,7 @@ int main(int argc, char* args[]) {
|
||||
}
|
||||
}
|
||||
|
||||
//IRState* image = ParseTokens(list);
|
||||
IRState* image = ParseTokens(list);
|
||||
//Disassemble(image);
|
||||
//for(int i = 0; i < image->Opcodes->size; i++) {
|
||||
// printf("%d\n", ((IROpcode*) image->Opcodes->content[i])->Mnemonic);
|
||||
|
||||
Reference in New Issue
Block a user