From ff77516d964d758e33218e03483484d2ef1adef9 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Tue, 22 Jun 2021 20:43:35 -0400 Subject: Sort of handling comments in the transpiler --- transpiler/replacer.cpp | 13 ++++++++++++- transpiler/transpiler | Bin 49640 -> 49688 bytes 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'transpiler') diff --git a/transpiler/replacer.cpp b/transpiler/replacer.cpp index 28c2e8e..0225f92 100644 --- a/transpiler/replacer.cpp +++ b/transpiler/replacer.cpp @@ -17,6 +17,8 @@ const char* types[] = { "struct", "class" }; +const char* commentType = "//"; + bool isType(char* str, int size) { if (size == 0) { return false; @@ -84,7 +86,16 @@ std::string insertCodeSnippets(char* workingDirectory, char* bodyContent) { } int tokenLength = (tokenEnd - tokenStart); - if (isType(&snippetContent[tokenStart], tokenLength)) { + + if (tokenLength == strlen(commentType) && strncmp(&snippetContent[tokenStart], commentType, tokenLength) == 0) { + // @NOTE: Assuming comments are always on a single line + s.append(""); + while (snippetContent[tokenEnd] != '\n') { + tokenEnd++; + } + s.append(&snippetContent[tokenStart], tokenEnd - tokenStart); + s.append(""); + } else if (isType(&snippetContent[tokenStart], tokenLength)) { s.append(""); s.append(&snippetContent[tokenStart], tokenLength); s.append(""); diff --git a/transpiler/transpiler b/transpiler/transpiler index 509db3e..896e778 100755 Binary files a/transpiler/transpiler and b/transpiler/transpiler differ -- cgit v1.2.1