Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MakarenkoAI committed Jul 29, 2024
1 parent ee537b5 commit 3208db4
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 51 deletions.
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
2 changes: 1 addition & 1 deletion src/grammar/SCnTexLexer.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/grammar/SCnTexLexer.h
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/grammar/SCnTexParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
2 changes: 1 addition & 1 deletion src/grammar/SCnTexParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 14 additions & 18 deletions src/translator/commands/math/sc_scn_tex_math_command.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "sc_scn_tex_math_command.h"

#include "../../helper/scs_helper.h"

#include "../../log/sc_log.hpp"

/// 0: command 1: <expression> 2: <expression>
ScScnTexCommandResult ScSCnTexMathCommand::Complete(
ScSCnCommandsHistory & history,
Expand All @@ -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 "";
Expand Down
45 changes: 22 additions & 23 deletions src/translator/commands/math/sc_scn_tex_operation_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <string>
#include <vector>
#include <unordered_set>
#include <unordered_map>

#include "../sc_scn_tex_command.h"
Expand All @@ -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<std::string, std::vector<std::string>> m_mathTypes = {
{ "frac", { "<sup>", "</sup>&frasl;", "<sub>", "</sub>" } },
{ "max", { "max( ", " )" } },
{ "min", { "min( ", " )" } },
{ "upperscore", { "<sup>", "</sup>" } },
{ "underscore", { "<sub>", "</sub>" } }
{ "frac", { "<sup>", "</sup>&frasl;", "<sub>", "</sub>" } },
{ "max", { "max( ", " )" } },
{ "min", { "min( ", " )" } },
{ "upperscore", { "<sup>", "</sup>" } },
{ "underscore", { "<sub>", "</sub>" } }
};


std::unordered_map<std::string, std::vector<std::string>> m_symbolTypes = {
{ "newpage", { "\n" } },
Expand Down Expand Up @@ -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", { "ε" } }
};

};

0 comments on commit 3208db4

Please sign in to comment.