Skip to content

Commit

Permalink
Support for complex numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomilist committed Jun 3, 2022
1 parent 3ecf42f commit f02562d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
26 changes: 16 additions & 10 deletions include/parsing/mathcad/MathcadParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,9 @@ namespace mcon
}
}

// Escape # characters
if (a_node->type == NodeType::Text)
{
std::size_t position = a_node->content.find(L"#");

if (position != std::wstring::npos)
{
a_node->content.replace(position, 1, L"\\#");
}
}
// Escape characters
EscapeCharacter(a_node, L"#", L"\\#");
EscapeCharacter(a_node, L"_", L"\\_");

// Correct type of matrix size nodes
if (a_node->type == NodeType::Matrix)
Expand All @@ -202,4 +195,17 @@ namespace mcon

return;
}

void MathcadParser::EscapeCharacter(std::shared_ptr<Node> a_node, std::wstring a_find, std::wstring a_replace)
{
if (a_node->type == NodeType::Text)
{
std::size_t position = a_node->content.find(a_find);

if (position != std::wstring::npos)
{
a_node->content.replace(position, a_find.length(), a_replace);
}
}
}
}
1 change: 1 addition & 0 deletions include/parsing/mathcad/MathcadParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace mcon
void Parse(std::shared_ptr<ParsingTree> a_parsing_tree);
void ParseExpression(std::shared_ptr<ParsingTree> a_parsing_tree);
void Clean(std::shared_ptr<Node> a_node);
void EscapeCharacter(std::shared_ptr<Node> a_node, std::wstring a_find, std::wstring a_replace);

private:
ParserState state = ParserState::LookingForExpression;
Expand Down
3 changes: 2 additions & 1 deletion userguide.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# User guide for math-converter-1.0.0
# User guide for math-converter-1.0.1

## Hotkeys

Expand Down Expand Up @@ -45,6 +45,7 @@ Mathcad is the starting point for the program, and the feature set reflects this
- Percentage
- Range and step range
- Element of
- Complex numbers

## Configuration

Expand Down

0 comments on commit f02562d

Please sign in to comment.