mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[TexParser] Adding Sum, Product and Integral (#252)
This commit is contained in:
@@ -153,6 +153,18 @@ Layout TexParser::popCommand() {
|
||||
return popCeilCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_integralCommand, m_text, strlen(k_integralCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_integralCommand)))) {
|
||||
m_text += strlen(k_integralCommand);
|
||||
return popIntegralCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_intsetCommand, m_text, strlen(k_intsetCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_intsetCommand)))) {
|
||||
m_text += strlen(k_intsetCommand);
|
||||
return popIntsetCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_floorCommand, m_text, strlen(k_floorCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_floorCommand)))) {
|
||||
m_text += strlen(k_floorCommand);
|
||||
@@ -171,25 +183,6 @@ Layout TexParser::popCommand() {
|
||||
return popLeftCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_rightCommand, m_text, strlen(k_rightCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_rightCommand)))) {
|
||||
m_text += strlen(k_rightCommand);
|
||||
return popRightCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_sqrtCommand, m_text, strlen(k_sqrtCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_sqrtCommand)))) {
|
||||
m_text += strlen(k_sqrtCommand);
|
||||
return popSqrtCommand();
|
||||
}
|
||||
}
|
||||
|
||||
if (strncmp(k_spaceCommand, m_text, strlen(k_spaceCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_spaceCommand)))) {
|
||||
m_text += strlen(k_spaceCommand);
|
||||
return popSpaceCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_overrightArrowCommand, m_text, strlen(k_overrightArrowCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_overrightArrowCommand)))) {
|
||||
m_text += strlen(k_overrightArrowCommand);
|
||||
@@ -202,12 +195,37 @@ Layout TexParser::popCommand() {
|
||||
return popOverlineCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_intsetCommand, m_text, strlen(k_intsetCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_intsetCommand)))) {
|
||||
m_text += strlen(k_intsetCommand);
|
||||
return popIntsetCommand();
|
||||
if (strncmp(k_productCommand, m_text, strlen(k_productCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_productCommand)))) {
|
||||
m_text += strlen(k_productCommand);
|
||||
return popProductCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_rightCommand, m_text, strlen(k_rightCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_rightCommand)))) {
|
||||
m_text += strlen(k_rightCommand);
|
||||
return popRightCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_spaceCommand, m_text, strlen(k_spaceCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_spaceCommand)))) {
|
||||
m_text += strlen(k_spaceCommand);
|
||||
return popSpaceCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_sqrtCommand, m_text, strlen(k_sqrtCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_sqrtCommand)))) {
|
||||
m_text += strlen(k_sqrtCommand);
|
||||
return popSqrtCommand();
|
||||
}
|
||||
}
|
||||
if (strncmp(k_sumCommand, m_text, strlen(k_sumCommand)) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_sumCommand)))) {
|
||||
m_text += strlen(k_sumCommand);
|
||||
return popSumCommand();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < k_NumberOfSymbols; i++) {
|
||||
if (strncmp(k_SymbolsCommands[i], m_text, strlen(k_SymbolsCommands[i])) == 0) {
|
||||
if (isCommandEnded(*(m_text + strlen(k_SymbolsCommands[i])))) {
|
||||
@@ -255,6 +273,14 @@ Layout TexParser::popFracCommand() {
|
||||
return l;
|
||||
}
|
||||
|
||||
Layout TexParser::popIntegralCommand() {
|
||||
Layout arg = popBlock();
|
||||
Layout var = popBlock();
|
||||
Layout start = popBlock();
|
||||
Layout end = popBlock();
|
||||
return IntegralLayout::Builder(arg, var, start, end);
|
||||
}
|
||||
|
||||
Layout TexParser::popIntsetCommand() {
|
||||
HorizontalLayout intset = HorizontalLayout::Builder();
|
||||
intset.addOrMergeChildAtIndex(CodePointLayout::Builder(0x27e6), 0, false);
|
||||
@@ -268,6 +294,15 @@ Layout TexParser::popLeftCommand() {
|
||||
return LeftParenthesisLayout::Builder();
|
||||
}
|
||||
|
||||
Layout TexParser::popProductCommand() {
|
||||
Layout arg = popBlock();
|
||||
Layout var = popBlock();
|
||||
Layout start = popBlock();
|
||||
Layout end = popBlock();
|
||||
return ProductLayout::Builder(arg, var, start, end);
|
||||
}
|
||||
|
||||
|
||||
Layout TexParser::popRightCommand() {
|
||||
m_text++;
|
||||
return RightParenthesisLayout::Builder();
|
||||
@@ -288,6 +323,14 @@ Layout TexParser::popSqrtCommand() {
|
||||
}
|
||||
}
|
||||
|
||||
Layout TexParser::popSumCommand() {
|
||||
Layout arg = popBlock();
|
||||
Layout var = popBlock();
|
||||
Layout start = popBlock();
|
||||
Layout end = popBlock();
|
||||
return SumLayout::Builder(arg, var, start, end);
|
||||
}
|
||||
|
||||
Layout TexParser::popSpaceCommand() {
|
||||
return LayoutHelper::String(" ", 1);
|
||||
}
|
||||
|
||||
@@ -24,13 +24,17 @@ private:
|
||||
Layout popCeilCommand();
|
||||
Layout popFloorCommand();
|
||||
Layout popFracCommand();
|
||||
Layout popIntegralCommand();
|
||||
Layout popIntsetCommand();
|
||||
Layout popLeftCommand();
|
||||
Layout popRightCommand();
|
||||
Layout popSqrtCommand();
|
||||
Layout popSpaceCommand();
|
||||
Layout popOverrightarrowCommand();
|
||||
Layout popOverlineCommand();
|
||||
Layout popProductCommand();
|
||||
Layout popRightCommand();
|
||||
Layout popSqrtCommand();
|
||||
Layout popSumCommand();
|
||||
Layout popSpaceCommand();
|
||||
|
||||
|
||||
//Symbols
|
||||
Layout popSymbolCommand(int SymbolIndex);
|
||||
@@ -46,13 +50,17 @@ private:
|
||||
static constexpr char const * k_ceilCommand = "ceil";
|
||||
static constexpr char const * k_floorCommand = "floor";
|
||||
static constexpr char const * k_fracCommand = "frac";
|
||||
static constexpr char const * k_integralCommand = "int";
|
||||
static constexpr char const * k_intsetCommand = "intset";
|
||||
static constexpr char const * k_leftCommand = "left";
|
||||
static constexpr char const * k_rightCommand = "right";
|
||||
static constexpr char const * k_sqrtCommand = "sqrt";
|
||||
static constexpr char const * k_spaceCommand = "space";
|
||||
static constexpr char const * k_overrightArrowCommand = "overrightarrow";
|
||||
static constexpr char const * k_overlineCommand = "overline";
|
||||
static constexpr char const * k_productCommand = "prod";
|
||||
static constexpr char const * k_rightCommand = "right";
|
||||
static constexpr char const * k_spaceCommand = "space";
|
||||
static constexpr char const * k_sqrtCommand = "sqrt";
|
||||
static constexpr char const * k_sumCommand = "sum";
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user