/*************/ /*GEMWIRE */ /* ERYTHRO*/ /*************/ #include #define extern_ #include #undef extern_ #include int TypeSizes[9] = { 0, 1, 4, 8, 0, 8, 8, 8, 8}; // in BYTES char* TokenStrings[] = { "+", "-", "*", "/", "int" }; char* TokenNames[] = { "End of file", "Equivalency", "Addition", "Subtraction", "Multiplication", "Division", "Equality Check", "Inequality Check", "Less Than", "Greater Than", "Less Than or Equal", "Greater Than or Equal", "Integer literal", "Statement End", "Compound Block Start", "Compound Block End", "Array index start", "Array index end", "Logical Block Start", "Logical Block End", "Dereference operator", "Comma", "Identifier", "None Type", "Char Type", "Int Type", "Long Type", "Void Type", "Function keyword", "Print Keyword", "If keyword", "Else keyword", "While keyword", "For keyword", "Return keyword" }; char* TypeNames[9] = { "none", "char", "int", "long", "void", "charptr", "intptr", "longptr", "voidptr"}; int main(int argc, char* argv[]) { Line = 1; Overread = '\n'; struct ASTNode* Node; if((SourceFile = fopen(argv[1], "r")) == NULL) { fprintf(stderr, "Unable to open %s: %s\n", argv[1], strerror(errno)); exit(1); } if((OutputFile = fopen(argv[2], "w")) == NULL) { fprintf(stderr, "Unable to open %s: %s\n", argv[2], strerror(errno)); exit(1); } AddFunctionSymbol("PrintInteger", RET_CHAR, ST_FUNC, 0, 1); AddFunctionSymbol("PrintString", RET_CHAR, ST_FUNC, 1, 1); //AddSymbol("forgecord", PTR_CHAR, ST_VAR); Tokenise(&CurrentToken); AssemblerPreamble(); ParseGlobals(); //AsFunctionEpilogue(); //Node = ParsePrecedenceASTNode(); //printf("%d\n", ParseAST(Node)); //AssembleNode(Node); fclose(OutputFile); exit(0); } void Die(char* Error) { fprintf(stderr, "%s on line %d\n", Error, Line); exit(1); } void DieMessage(char* Error, char* Reason) { fprintf(stderr, "%s: %s on line %d\n", Error, Reason, Line); exit(1); } void DieDecimal(char* Error, int Number) { fprintf(stderr, "%s: %d on line %d\n", Error, Number, Line); exit(1); } void DieChar(char* Error, int Char) { fprintf(stderr, "%s: %c on line %d\n", Error, Char, Line); exit(1); }