mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/reader] Adding new symbols and functions in the TexParser (#237)
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Reader {
|
|||||||
"Mu", "Nu", "Xi", "Omicron", "Pi", "Rho", "Sigma", "Tau", "Upsilon", "Phi", "Chi", "Psi","Omega",
|
"Mu", "Nu", "Xi", "Omicron", "Pi", "Rho", "Sigma", "Tau", "Upsilon", "Phi", "Chi", "Psi","Omega",
|
||||||
"alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa", "lambda",
|
"alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa", "lambda",
|
||||||
"mu", "nu", "xi", "omicron", "pi", "rho", "sigma", "tau", "upsilon", "phi", "chi", "psi", "omega",
|
"mu", "nu", "xi", "omicron", "pi", "rho", "sigma", "tau", "upsilon", "phi", "chi", "psi", "omega",
|
||||||
"sim",
|
"sim", "f", "i",
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr int const k_NumberOfSymbols = sizeof(k_SymbolsCommands) / sizeof(char *);
|
static constexpr int const k_NumberOfSymbols = sizeof(k_SymbolsCommands) / sizeof(char *);
|
||||||
@@ -26,7 +26,7 @@ namespace Reader {
|
|||||||
0x39c, 0x39d, 0x39e, 0x39f, 0x3a0, 0x3a1, 0x3a3, 0x3a4, 0x3a5, 0x3a6, 0x3a7, 0x3a8, 0x3a9,
|
0x39c, 0x39d, 0x39e, 0x39f, 0x3a0, 0x3a1, 0x3a3, 0x3a4, 0x3a5, 0x3a6, 0x3a7, 0x3a8, 0x3a9,
|
||||||
0x3b1, 0x3b2, 0x3b3, 0x3b4, 0x3b5, 0x3b6, 0x3b7, 0x3b8, 0x3b9, 0x3ba, 0x3bb,
|
0x3b1, 0x3b2, 0x3b3, 0x3b4, 0x3b5, 0x3b6, 0x3b7, 0x3b8, 0x3b9, 0x3ba, 0x3bb,
|
||||||
0x3bc, 0x3bd, 0x3be, 0x3bf, 0x3c0, 0x3c1, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7, 0x3c8, 0x3c9,
|
0x3bc, 0x3bd, 0x3be, 0x3bf, 0x3c0, 0x3c1, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7, 0x3c8, 0x3c9,
|
||||||
0x7e,
|
0x7e, 0x192, 0x1d422,
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(k_SymbolsCodePoints) / sizeof(uint32_t) == k_NumberOfSymbols);
|
static_assert(sizeof(k_SymbolsCodePoints) / sizeof(uint32_t) == k_NumberOfSymbols);
|
||||||
@@ -141,6 +141,12 @@ Layout TexParser::popText(char stop) {
|
|||||||
|
|
||||||
Layout TexParser::popCommand() {
|
Layout TexParser::popCommand() {
|
||||||
// TODO: Factorize this code
|
// TODO: Factorize this code
|
||||||
|
if (strncmp(k_binomCommand, m_text, strlen(k_binomCommand)) == 0) {
|
||||||
|
if (isCommandEnded(*(m_text + strlen(k_binomCommand)))) {
|
||||||
|
m_text += strlen(k_binomCommand);
|
||||||
|
return popBinomCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (strncmp(k_ceilCommand, m_text, strlen(k_ceilCommand)) == 0) {
|
if (strncmp(k_ceilCommand, m_text, strlen(k_ceilCommand)) == 0) {
|
||||||
if (isCommandEnded(*(m_text + strlen(k_ceilCommand)))) {
|
if (isCommandEnded(*(m_text + strlen(k_ceilCommand)))) {
|
||||||
m_text += strlen(k_ceilCommand);
|
m_text += strlen(k_ceilCommand);
|
||||||
@@ -190,10 +196,16 @@ Layout TexParser::popCommand() {
|
|||||||
return popOverrightarrowCommand();
|
return popOverrightarrowCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (strncmp(k_binomCommand, m_text, strlen(k_binomCommand)) == 0) {
|
if (strncmp(k_overlineCommand, m_text, strlen(k_overlineCommand)) == 0) {
|
||||||
if (isCommandEnded(*(m_text + strlen(k_binomCommand)))) {
|
if (isCommandEnded(*(m_text + strlen(k_overlineCommand)))) {
|
||||||
m_text += strlen(k_binomCommand);
|
m_text += strlen(k_overlineCommand);
|
||||||
return popBinomCommand();
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < k_NumberOfSymbols; i++) {
|
for (int i = 0; i < k_NumberOfSymbols; i++) {
|
||||||
@@ -219,6 +231,13 @@ Layout TexParser::popCommand() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Expressions
|
// Expressions
|
||||||
|
Layout TexParser::popBinomCommand() {
|
||||||
|
Layout numerator = popBlock();
|
||||||
|
Layout denominator = popBlock();
|
||||||
|
BinomialCoefficientLayout b = BinomialCoefficientLayout::Builder(numerator, denominator);
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
Layout TexParser::popCeilCommand() {
|
Layout TexParser::popCeilCommand() {
|
||||||
Layout ceil = popBlock();
|
Layout ceil = popBlock();
|
||||||
return CeilingLayout::Builder(ceil);
|
return CeilingLayout::Builder(ceil);
|
||||||
@@ -236,6 +255,14 @@ Layout TexParser::popFracCommand() {
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Layout TexParser::popIntsetCommand() {
|
||||||
|
HorizontalLayout intset = HorizontalLayout::Builder();
|
||||||
|
intset.addOrMergeChildAtIndex(CodePointLayout::Builder(0x27e6), 0, false);
|
||||||
|
intset.addOrMergeChildAtIndex(popBlock(), intset.numberOfChildren(), false);
|
||||||
|
intset.addOrMergeChildAtIndex(CodePointLayout::Builder(0x27e7), intset.numberOfChildren(), false);
|
||||||
|
return intset;
|
||||||
|
}
|
||||||
|
|
||||||
Layout TexParser::popLeftCommand() {
|
Layout TexParser::popLeftCommand() {
|
||||||
m_text++;
|
m_text++;
|
||||||
return LeftParenthesisLayout::Builder();
|
return LeftParenthesisLayout::Builder();
|
||||||
@@ -269,11 +296,8 @@ Layout TexParser::popOverrightarrowCommand() {
|
|||||||
return VectorLayout::Builder(popBlock());
|
return VectorLayout::Builder(popBlock());
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout TexParser::popBinomCommand() {
|
Layout TexParser::popOverlineCommand() {
|
||||||
Layout numerator = popBlock();
|
return ConjugateLayout::Builder(popBlock());
|
||||||
Layout denominator = popBlock();
|
|
||||||
BinomialCoefficientLayout b = BinomialCoefficientLayout::Builder(numerator, denominator);
|
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout TexParser::popSymbolCommand(int SymbolIndex) {
|
Layout TexParser::popSymbolCommand(int SymbolIndex) {
|
||||||
|
|||||||
@@ -20,15 +20,17 @@ private:
|
|||||||
Layout popCommand();
|
Layout popCommand();
|
||||||
|
|
||||||
// Expressions
|
// Expressions
|
||||||
|
Layout popBinomCommand();
|
||||||
Layout popCeilCommand();
|
Layout popCeilCommand();
|
||||||
Layout popFloorCommand();
|
Layout popFloorCommand();
|
||||||
Layout popFracCommand();
|
Layout popFracCommand();
|
||||||
|
Layout popIntsetCommand();
|
||||||
Layout popLeftCommand();
|
Layout popLeftCommand();
|
||||||
Layout popRightCommand();
|
Layout popRightCommand();
|
||||||
Layout popSqrtCommand();
|
Layout popSqrtCommand();
|
||||||
Layout popSpaceCommand();
|
Layout popSpaceCommand();
|
||||||
Layout popOverrightarrowCommand();
|
Layout popOverrightarrowCommand();
|
||||||
Layout popBinomCommand();
|
Layout popOverlineCommand();
|
||||||
|
|
||||||
//Symbols
|
//Symbols
|
||||||
Layout popSymbolCommand(int SymbolIndex);
|
Layout popSymbolCommand(int SymbolIndex);
|
||||||
@@ -40,15 +42,18 @@ private:
|
|||||||
inline bool isCommandEnded(char c) const;
|
inline bool isCommandEnded(char c) const;
|
||||||
|
|
||||||
// Expressions that require specific handling
|
// Expressions that require specific handling
|
||||||
|
static constexpr char const * k_binomCommand = "binom";
|
||||||
static constexpr char const * k_ceilCommand = "ceil";
|
static constexpr char const * k_ceilCommand = "ceil";
|
||||||
static constexpr char const * k_floorCommand = "floor";
|
static constexpr char const * k_floorCommand = "floor";
|
||||||
static constexpr char const * k_fracCommand = "frac";
|
static constexpr char const * k_fracCommand = "frac";
|
||||||
|
static constexpr char const * k_intsetCommand = "intset";
|
||||||
static constexpr char const * k_leftCommand = "left";
|
static constexpr char const * k_leftCommand = "left";
|
||||||
static constexpr char const * k_rightCommand = "right";
|
static constexpr char const * k_rightCommand = "right";
|
||||||
static constexpr char const * k_sqrtCommand = "sqrt";
|
static constexpr char const * k_sqrtCommand = "sqrt";
|
||||||
static constexpr char const * k_spaceCommand = "space";
|
static constexpr char const * k_spaceCommand = "space";
|
||||||
static constexpr char const * k_overrightArrowCommand = "overrightarrow";
|
static constexpr char const * k_overrightArrowCommand = "overrightarrow";
|
||||||
static constexpr char const * k_binomCommand = "binom";
|
static constexpr char const * k_overlineCommand = "overline";
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -266,6 +266,8 @@ uint32_t ExtendedCodePoints[] = {
|
|||||||
0xf8, // ø // LATIN SMALL LETTER O WITH STROKE
|
0xf8, // ø // LATIN SMALL LETTER O WITH STROKE
|
||||||
0xfe, // þ // LATIN SMALL LETTER THORN
|
0xfe, // þ // LATIN SMALL LETTER THORN
|
||||||
|
|
||||||
|
0x192, // ƒ // LATIN SMALL LETTER F WITH HOOK
|
||||||
|
|
||||||
0x300, // ̀ // COMBINING GRAVE ACCENT
|
0x300, // ̀ // COMBINING GRAVE ACCENT
|
||||||
0x301, // ́ // COMBINING ACUTE ACCENT
|
0x301, // ́ // COMBINING ACUTE ACCENT
|
||||||
0x302, // ̂ // COMBINING CIRCUMFLEX ACCENT
|
0x302, // ̂ // COMBINING CIRCUMFLEX ACCENT
|
||||||
@@ -355,6 +357,8 @@ uint32_t ExtendedCodePoints[] = {
|
|||||||
0x2264, // ≤ // LESS-THAN OR EQUAL TO
|
0x2264, // ≤ // LESS-THAN OR EQUAL TO
|
||||||
0x2265, // ≥ // GREATER-THAN OR EQUAL TO
|
0x2265, // ≥ // GREATER-THAN OR EQUAL TO
|
||||||
0x2505, // ┅ // BOX DRAWING EQU HEAVY DASH HORIZONTAL
|
0x2505, // ┅ // BOX DRAWING EQU HEAVY DASH HORIZONTAL
|
||||||
|
0x27e6, // ⟦ // MATHEMATICAL LEFT INT BRACKET SET
|
||||||
|
0x27e7, // ⟧ // MATHEMATICAL RIGHT INT BRACKET SET
|
||||||
0xFFFD, // <20> // REPLACEMENT CHARACTER
|
0xFFFD, // <20> // REPLACEMENT CHARACTER
|
||||||
0x1d422, // 𝐢 // MATHEMATICAL BOLD SMALL I"
|
0x1d422, // 𝐢 // MATHEMATICAL BOLD SMALL I"
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user