mirror of
https://github.com/jorenchik/mdemory.git
synced 2026-03-22 00:26:21 +00:00
all methods in camelCase
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#include "result.h"
|
||||
#include "parser.h"
|
||||
|
||||
Result<ParseInfo> Transpile(std::string fileContent, bool isDebug);
|
||||
Result<ParseInfo> transpile(std::string fileContent, bool isDebug);
|
||||
|
||||
@@ -29,4 +29,4 @@ struct Token {
|
||||
static std::string ToString(const TokenType* ttype);
|
||||
};
|
||||
|
||||
Result<std::vector<Token>> TokenizeMdem(const std::string& fileRunes);
|
||||
Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes);
|
||||
|
||||
@@ -50,4 +50,4 @@ struct ParseInfo {
|
||||
time_t lastTrainedAt;
|
||||
};
|
||||
|
||||
Result<ParseInfo> ParseQuestions(const std::vector<Token>& tokens);
|
||||
Result<ParseInfo> parseQuestions(const std::vector<Token>& tokens);
|
||||
|
||||
@@ -394,7 +394,7 @@ void loadMdem() {
|
||||
std::stringstream buffer;
|
||||
buffer << file.rdbuf();
|
||||
content = buffer.str();
|
||||
auto res = Transpile(content, true);
|
||||
auto res = transpile(content, true);
|
||||
for (auto question: questions) {
|
||||
delete question;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@ bool debug;
|
||||
std::chrono::high_resolution_clock::time_point start;
|
||||
std::chrono::high_resolution_clock::time_point end;
|
||||
|
||||
Result<ParseInfo> Transpile(std::string fileContent, bool isDebug) {
|
||||
Result<ParseInfo> transpile(std::string fileContent, bool isDebug) {
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
end = std::chrono::high_resolution_clock::now();
|
||||
debug = isDebug;
|
||||
|
||||
auto lexRes = TokenizeMdem(fileContent);
|
||||
auto lexRes = tokenizeMdem(fileContent);
|
||||
auto tokens = lexRes.value;
|
||||
if (lexRes.error.length() > 0) {
|
||||
return {
|
||||
@@ -31,7 +31,7 @@ Result<ParseInfo> Transpile(std::string fileContent, bool isDebug) {
|
||||
};
|
||||
}
|
||||
|
||||
auto parseRes = ParseQuestions(tokens);
|
||||
auto parseRes = parseQuestions(tokens);
|
||||
auto questions = parseRes.value;
|
||||
if (parseRes.error.length() > 0) {
|
||||
return {
|
||||
@@ -46,6 +46,6 @@ Result<ParseInfo> Transpile(std::string fileContent, bool isDebug) {
|
||||
}
|
||||
|
||||
end = std::chrono::high_resolution_clock::now();
|
||||
ShowTime("Transpilation time");
|
||||
showTime("Transpilation time");
|
||||
return {questions};
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ void makeTokenWithTokenBuffer(
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
Result<std::vector<Token>> TokenizeMdem(const std::string& fileRunes) {
|
||||
Result<std::vector<Token>> tokenizeMdem(const std::string& fileRunes) {
|
||||
row = 1;
|
||||
column = 1;
|
||||
previousRow = 1;
|
||||
|
||||
@@ -47,9 +47,9 @@ int main(int argc, char* argv[]) {
|
||||
try {
|
||||
std::string fileContent = readFile(filePath);
|
||||
end = std::chrono::high_resolution_clock::now();
|
||||
ShowTime("I/O time");
|
||||
showTime("I/O time");
|
||||
|
||||
auto res = Transpile(fileContent, debug);
|
||||
auto res = transpile(fileContent, debug);
|
||||
auto questions = res.value.questions;
|
||||
if (res.error.length() > 0) {
|
||||
std::cout << std::format(
|
||||
|
||||
@@ -141,7 +141,7 @@ Result<NoneType> ValidateGrammar(const std::vector<Token>& tokens) {
|
||||
return {};
|
||||
}
|
||||
|
||||
Result<ParseInfo> ParseQuestions(const std::vector<Token>& tokens) {
|
||||
Result<ParseInfo> parseQuestions(const std::vector<Token>& tokens) {
|
||||
auto questions = std::vector<Question*>();
|
||||
time_t time = 0;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "time.h"
|
||||
|
||||
void ShowTime(std::string label) {
|
||||
void showTime(std::string label) {
|
||||
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
|
||||
double_t msDuration = (double_t) duration.count() / 1000;
|
||||
std::cout << std::format("{}: {:.3f} ms", label, msDuration) << std::endl;
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
extern std::chrono::high_resolution_clock::time_point start;
|
||||
extern std::chrono::high_resolution_clock::time_point end;
|
||||
|
||||
void ShowTime(std::string label);
|
||||
void showTime(std::string label);
|
||||
|
||||
Reference in New Issue
Block a user