From a00c0aab1eb5a7a55bef8ca08115bdd722ab5699 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Sun, 16 May 2021 19:50:15 -0400 Subject: Moved the frontend directory up so that it no longer exists --- frontend/transpiler/transpiler.cpp | 250 ------------------------------------- 1 file changed, 250 deletions(-) delete mode 100644 frontend/transpiler/transpiler.cpp (limited to 'frontend/transpiler/transpiler.cpp') diff --git a/frontend/transpiler/transpiler.cpp b/frontend/transpiler/transpiler.cpp deleted file mode 100644 index fa9820a..0000000 --- a/frontend/transpiler/transpiler.cpp +++ /dev/null @@ -1,250 +0,0 @@ -#include "MyString.h" -#include "List.h" -#include "Logger.h" -#include -#include -#include - -struct InnerCategory { - bool isLabel = false; - String label; - String path; - - void toCode(StringBuilder& sb) { - if (isLabel) { - sb.format("\t\t\t\t\t
  • \n", label.getValue()); - } else { - sb.format("\t\t\t\t\t
  • %s
  • \n", path.getValue(), label.getValue()); - } - } - - void free() { - label.free(); - path.free(); - } -}; - -struct OuterCategory { - String outerName; - String outerSymbol; - List items; - - void toCode(StringBuilder& sb) { - sb.addStr("\t\t\t
  • \n"); - sb.format("\t\t\t\t%s%s\n", outerSymbol.getValue(), outerName.getValue()); - sb.addStr("\t\t\t\t
      \n"); - - FOREACH(items) { - value->toCode(sb); - } - - sb.addStr("\t\t\t\t
    \n"); - sb.addStr("\t\t\t
  • \n"); - } - - void reset() { - outerName.free(); - outerSymbol.free(); - items.clear(); - } - - void free() { - outerName.free(); - outerSymbol.free(); - - FOREACH(items) { - value->free(); - } - items.deallocate(); - } -}; - -int main() { - logger_info("Running transpiler"); - FILE* pagesFile = fopen("transpiler/pages.txt", "r+"); - - char * cLine = NULL; - size_t len = 0; - ssize_t read; - - StringBuilder sb; - StringBuilder otherSb; - - sb.addStr("\t\t\n"); - oc.reset(); - fclose(pagesFile); - - String navbarRetval = sb.toString(); - sb.clear(); - - logger_info("Creating served files"); - - // Create the header - FOREACH(servedFiles) { - otherSb.clear(); - otherSb.format("%s.content", value->getValue()); - String contentFileName = otherSb.toString(); - FILE* contentFile = fopen(contentFileName.getValue(), "r+"); - if (contentFile == NULL) { - logger_warning("Could not output file, most likely unimplemented: %s", contentFileName.getValue()); - continue; - } - - logger_info("Outputting file: %s", contentFileName.getValue()); - - // Header - sb.addStr("\n" - "\n" - "\t\n" - "\t\t\n" - "\t\t\n" - "\t\tPhysics for Games\n" - "\t\t\n" - "\t\n" - "\t\n" - "\t\t
    \n" - "\t\t\t

    Physics for Games

    \n" - "\t\t
    \n" - "\t\t
    \n"); - - // Write navigation bar - sb.addStr(navbarRetval.getValue()); - // Read body - - fseek(contentFile, 0, SEEK_END); - long fsize = ftell(contentFile); - fseek(contentFile, 0, SEEK_SET); - - char* bodyContent = new char[fsize + 1]; - fread(bodyContent, 1, fsize, contentFile); - bodyContent[fsize] = '\0'; - sb.addStr(bodyContent); - delete [] bodyContent; - - - contentFileName.free(); - fclose(contentFile); - - // Footer - sb.addStr("\t\t
    \n" - "\t\n" - "\n"); - - FILE* outFile = fopen(value->getValue(), "w+"); - String outStr = sb.toString(); - fwrite(outStr.getValue(), 1, outStr.length, outFile); - outStr.free(); - fclose(outFile); - sb.clear(); - } - - logger_info("Outputting files to their proper directories..."); - sb.free(); - navbarRetval.free(); - otherSb.free(); - - FOREACH(servedFiles) { - value->free(); - } - - servedFiles.deallocate(); - - return 0; -} \ No newline at end of file -- cgit v1.2.1