Skip to content

Commit

Permalink
Clean up (#49)
Browse files Browse the repository at this point in the history
* fix format

* clean

* clean css
  • Loading branch information
jnyfah committed Sep 14, 2023
1 parent 8bd79c4 commit b68fcd0
Show file tree
Hide file tree
Showing 5 changed files with 272 additions and 481 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ This generates a `Lexical-analysis` `Syntax-analysis` and an `assembly` files ou

You can always validate your assembly code with this ARM emulator [miniarm](https://github.com/ebresafegaga/miniarm)


or Just visit the __[Compiler Playground](https://jnyfah.github.io/CuriousX/)__ 🫠


## Examples
for the source code input:

Expand Down
1 change: 0 additions & 1 deletion SemanticAnalysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ it is basically error free AST, where all the variables are infrerred to their t

__To learn more:__
## [CuriousX Semantic Analysis Blog](https://jenniferchukwu.com/posts/semanticAnalysis)

17 changes: 3 additions & 14 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "CodeGen/include/Codegen.hpp"
#include "Error.hpp"
#include "LexicalAnalysis/include/Lexer.hpp"
#include "SemanticAnalysis/include/Semantic.hpp"
#include "json.hpp"
#include <emscripten/bind.h>
#include <sstream>

Expand All @@ -13,7 +11,6 @@
#endif



nlohmann::json serializeLexerToken(const LexerToken &token)
{
nlohmann::json j;
Expand All @@ -35,7 +32,6 @@ nlohmann::json nodeToJson(const std::shared_ptr<Node> &node)
return j;
}


nlohmann::json treesToJson(const std::vector<std::shared_ptr<Node>> &compound)
{
nlohmann::json jsonArray = nlohmann::json::array();
Expand All @@ -45,9 +41,6 @@ nlohmann::json treesToJson(const std::vector<std::shared_ptr<Node>> &compound)
return jsonArray;
}




std::string processFileContent(const std::string &content)
{
std::ostringstream output;
Expand Down Expand Up @@ -75,7 +68,6 @@ std::string processFileContent(const std::string &content)
throw Error("Parsing failed ");
}


auto sem = new Semantic();
sem->traverse(ast->astRoot());
// Print table for debugging ;D
Expand All @@ -88,12 +80,9 @@ std::string processFileContent(const std::string &content)
output << j.dump();
} catch (Error &ex)
{
nlohmann::json j{
{"success", false},
{"error", std::string("An error occurred: ") + ex.what()}
};
output.str(""); // Clearing the stringstream
output << j.dump();
nlohmann::json j{ { "success", false }, { "error", std::string("An error occurred: ") + ex.what() } };
output.str("");// Clearing the stringstream
output << j.dump();
}
return output.str();
}
Expand Down
Loading

0 comments on commit b68fcd0

Please sign in to comment.