diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e852c3..8a6db19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.11) project(sc-scn-tex2scs-translator) cmake_policy(SET CMP0048 NEW) set(TRANSLATOR_ROOT ${CMAKE_CURRENT_LIST_DIR}) -set(CMAKE_BUILD_TYPE Debug) - set(CMAKE_CXX_STANDARD 17) diff --git a/README.md b/README.md index 27b22f1..22b557f 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,3 @@ Tex2SCs-translator is a tool for translating SCn-represented *.tex files into SC Contributions, bug reports and feature requests are welcome! Feel free to check our [issues page](https://github.com/ostis-ai/tex2scs-translator/issues) and file a new issue (or comment in existing ones). - -\scnlegtcurlbrace element\scnrightcurlbrace -With space! \ No newline at end of file diff --git a/src/grammar/SCnTexLexer.cpp b/src/grammar/SCnTexLexer.cpp index 9bd1d64..20383b3 100644 --- a/src/grammar/SCnTexLexer.cpp +++ b/src/grammar/SCnTexLexer.cpp @@ -1,5 +1,5 @@ -// Generated from ./src/grammar/SCnTex.g4 by ANTLR 4.7.2 +// Generated from /home/anna/projects/tex2scs-translator/src/grammar/SCnTex.g4 by ANTLR 4.7.2 #include "SCnTexLexer.h" diff --git a/src/grammar/SCnTexLexer.h b/src/grammar/SCnTexLexer.h index c0e31de..09d7e2f 100644 --- a/src/grammar/SCnTexLexer.h +++ b/src/grammar/SCnTexLexer.h @@ -1,5 +1,5 @@ -// Generated from ./src/grammar/SCnTex.g4 by ANTLR 4.7.2 +// Generated from /home/anna/projects/tex2scs-translator/src/grammar/SCnTex.g4 by ANTLR 4.7.2 #pragma once diff --git a/src/grammar/SCnTexParser.cpp b/src/grammar/SCnTexParser.cpp index 0ff058a..27f8d93 100644 --- a/src/grammar/SCnTexParser.cpp +++ b/src/grammar/SCnTexParser.cpp @@ -5,7 +5,7 @@ #include "../translator/log/sc_log.hpp" -// Generated from ./src/grammar/SCnTex.g4 by ANTLR 4.7.2 +// Generated from /home/anna/projects/tex2scs-translator/src/grammar/SCnTex.g4 by ANTLR 4.7.2 diff --git a/src/grammar/SCnTexParser.h b/src/grammar/SCnTexParser.h index 8be8370..9195e7f 100644 --- a/src/grammar/SCnTexParser.h +++ b/src/grammar/SCnTexParser.h @@ -5,7 +5,7 @@ #include "../translator/log/sc_log.hpp" -// Generated from ./src/grammar/SCnTex.g4 by ANTLR 4.7.2 +// Generated from /home/anna/projects/tex2scs-translator/src/grammar/SCnTex.g4 by ANTLR 4.7.2 #pragma once diff --git a/src/translator/commands/math/sc_scn_tex_math_command.cpp b/src/translator/commands/math/sc_scn_tex_math_command.cpp index 1bb2a14..4d41c32 100644 --- a/src/translator/commands/math/sc_scn_tex_math_command.cpp +++ b/src/translator/commands/math/sc_scn_tex_math_command.cpp @@ -1,9 +1,5 @@ #include "sc_scn_tex_math_command.h" -#include "../../helper/scs_helper.h" - -#include "../../log/sc_log.hpp" - /// 0: command 1: 2: ScScnTexCommandResult ScSCnTexMathCommand::Complete( ScSCnCommandsHistory & history, @@ -26,38 +22,38 @@ ScScnTexCommandResult ScSCnTexMathCommand::Complete( .Row([&](SCsStream & stream) { auto const attrs = item->second; - auto const openBracketOfFirstArg = [&]() -> std::string { - return attrs[A_ATTR_POS]; + auto const OpenBracketOfFirstArg = [&]() -> std::string { + return attrs[FIRST_ARG_BEGIN_ATTR]; }; - auto const closedBracketOfFirstArg = [&]() -> std::string { - return attrs[B_ATTR_POS]; + auto const ClosedBracketOfFirstArg = [&]() -> std::string { + return attrs[FIRST_ARG_END_ATTR]; }; - auto const openBracketOfSecondArg = [&]() -> std::string { - return attrs[C_ATTR_POS]; + auto const OpenBracketOfSecondArg = [&]() -> std::string { + return attrs[SECOND_ARG_BEGIN_ATTR]; }; - auto const closedBracketOfSecondArg = [&]() -> std::string { - return attrs[D_ATTR_POS]; + auto const ClosedBracketOfSecondArg = [&]() -> std::string { + return attrs[SECOND_ARG_END_ATTR]; }; if (attrs.size() == COMMAND_SIZE_ONE_ARG) { - std::string const & first_argument = params.at(FIRST_PARAM_POS); + std::string const & firstArgument = params.at(FIRST_PARAM_POS); stream .Row([&]() -> SCsStream { - return {openBracketOfFirstArg(), first_argument, closedBracketOfFirstArg()}; + return {OpenBracketOfFirstArg(), firstArgument, ClosedBracketOfFirstArg()}; }); } else if (attrs.size() == COMMAND_SIZE_TWO_ARGS) { - std::string const & first_argument = params.at(FIRST_PARAM_POS); - std::string const & second_argument = params.at(SECOND_PARAM_POS); + std::string const & firstArgument = params.at(FIRST_PARAM_POS); + std::string const & secondArgument = params.at(SECOND_PARAM_POS); stream .Row([&]() -> SCsStream { - return {openBracketOfFirstArg(), first_argument, closedBracketOfFirstArg(), - openBracketOfSecondArg(), second_argument, closedBracketOfSecondArg()}; + return {OpenBracketOfFirstArg(), firstArgument, ClosedBracketOfFirstArg(), + OpenBracketOfSecondArg(), secondArgument, ClosedBracketOfSecondArg()}; }); } return ""; diff --git a/src/translator/commands/math/sc_scn_tex_operation_command.h b/src/translator/commands/math/sc_scn_tex_operation_command.h index 810045d..a20a886 100644 --- a/src/translator/commands/math/sc_scn_tex_operation_command.h +++ b/src/translator/commands/math/sc_scn_tex_operation_command.h @@ -2,7 +2,6 @@ #include #include -#include #include #include "../sc_scn_tex_command.h" @@ -14,22 +13,23 @@ class ScSCnTexOperationCommand : public ScSCnTexCommand uint8_t const FIRST_PARAM_POS = 1; uint8_t const SECOND_PARAM_POS = 2; - uint8_t const A_ATTR_POS = 0; - uint8_t const B_ATTR_POS = 1; - uint8_t const C_ATTR_POS = 2; - uint8_t const D_ATTR_POS = 3; + uint8_t const FIRST_ARG_BEGIN_ATTR = 0; + uint8_t const FIRST_ARG_END_ATTR = 1; + uint8_t const SECOND_ARG_BEGIN_ATTR = 2; + uint8_t const SECOND_ARG_END_ATTR = 3; uint8_t const COMMAND_SIZE_ZERO_ARG = 1; uint8_t const COMMAND_SIZE_ONE_ARG = 2; uint8_t const COMMAND_SIZE_TWO_ARGS = 4; std::unordered_map> m_mathTypes = { - { "frac", { "", "⁄", "", "" } }, - { "max", { "max( ", " )" } }, - { "min", { "min( ", " )" } }, - { "upperscore", { "", "" } }, - { "underscore", { "", "" } } + { "frac", { "", "⁄", "", "" } }, + { "max", { "max( ", " )" } }, + { "min", { "min( ", " )" } }, + { "upperscore", { "", "" } }, + { "underscore", { "", "" } } }; + std::unordered_map> m_symbolTypes = { { "newpage", { "\n" } }, @@ -77,20 +77,19 @@ class ScSCnTexOperationCommand : public ScSCnTexCommand { "textunderscore", { "_" } }, - {"times", { "×" } }, - {"'", { "'" } }, - {"percent", { "%" } }, + {"times", { "×" } }, + {"'", { "'" } }, + {"percent", { "%" } }, - {"alpha", { "α" } }, - {"beta", { "β" } }, - {"gamma", { "γ" } }, - {"Gamma", { "Γ" } }, - {"Sigma", { "Σ" } }, - {"Delta", { "Δ" } }, - {"delta", { "δ" } }, - {"Epsilon", { "Ε" } }, - {"epsilon", { "ε" } } - + {"alpha", { "α" } }, + {"beta", { "β" } }, + {"gamma", { "γ" } }, + {"Gamma", { "Γ" } }, + {"Sigma", { "Σ" } }, + {"Delta", { "Δ" } }, + {"delta", { "δ" } }, + {"Epsilon", { "Ε" } }, + {"epsilon", { "ε" } } }; };