mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/reader] Refactoring the parser
This commit is contained in:
@@ -113,425 +113,26 @@ Layout TexParser::popCommand() {
|
||||
return popSqrtCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_timesCommand, m_text, strlen(k_timesCommand)) == 0) {
|
||||
m_text += strlen(k_timesCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poptimesCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_divCommand, m_text, strlen(k_divCommand)) == 0) {
|
||||
m_text += strlen(k_divCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popdivCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_forallCommand, m_text, strlen(k_forallCommand)) == 0) {
|
||||
m_text += strlen(k_forallCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popforallCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_partialCommand, m_text, strlen(k_partialCommand)) == 0) {
|
||||
m_text += strlen(k_partialCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poppartialCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_existsCommand, m_text, strlen(k_existsCommand)) == 0) {
|
||||
m_text += strlen(k_existsCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popexistsCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_pmCommand, m_text, strlen(k_pmCommand)) == 0) {
|
||||
m_text += strlen(k_pmCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poppmCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_inftyCommand, m_text, strlen(k_inftyCommand)) == 0) {
|
||||
m_text += strlen(k_inftyCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popinftyCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_approxCommand, m_text, strlen(k_approxCommand)) == 0) {
|
||||
m_text += strlen(k_approxCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popapproxCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_neqCommand, m_text, strlen(k_neqCommand)) == 0) {
|
||||
m_text += strlen(k_neqCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popneqCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_equivCommand, m_text, strlen(k_equivCommand)) == 0) {
|
||||
m_text += strlen(k_equivCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popequivCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_leqCommand, m_text, strlen(k_leqCommand)) == 0) {
|
||||
m_text += strlen(k_leqCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popleqCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_geqCommand, m_text, strlen(k_geqCommand)) == 0) {
|
||||
m_text += strlen(k_geqCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popgeqCommand();
|
||||
}
|
||||
}
|
||||
|
||||
else if (strncmp(k_leftarrowCommand, m_text, strlen(k_leftarrowCommand)) == 0) {
|
||||
m_text += strlen(k_leftarrowCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popleftarrowCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_uparrowCommand, m_text, strlen(k_uparrowCommand)) == 0) {
|
||||
m_text += strlen(k_uparrowCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popuparrowCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_rightarrowCommand, m_text, strlen(k_rightarrowCommand)) == 0) {
|
||||
m_text += strlen(k_rightarrowCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poprightarrowCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_downarrowCommand, m_text, strlen(k_downarrowCommand)) == 0) {
|
||||
m_text += strlen(k_downarrowCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popdownarrowCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_leftrightarrowCommand, m_text, strlen(k_leftrightarrowCommand)) == 0) {
|
||||
m_text += strlen(k_leftrightarrowCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popleftrightarrowCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_updownarrowCommand, m_text, strlen(k_updownarrowCommand)) == 0) {
|
||||
m_text += strlen(k_updownarrowCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popupdownarrowCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_LeftarrowCommand, m_text, strlen(k_LeftarrowCommand)) == 0) {
|
||||
m_text += strlen(k_LeftarrowCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popLeftarrowCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_UparrowCommand, m_text, strlen(k_UparrowCommand)) == 0) {
|
||||
m_text += strlen(k_UparrowCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popUparrowCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_RightarrowCommand, m_text, strlen(k_RightarrowCommand)) == 0) {
|
||||
m_text += strlen(k_RightarrowCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popRightarrowCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_DownarrowCommand, m_text, strlen(k_DownarrowCommand)) == 0) {
|
||||
m_text += strlen(k_DownarrowCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popDownarrowCommand();
|
||||
|
||||
for (int i = 0; i < k_NumberOfSymbols; i++) {
|
||||
if (strncmp(k_SymbolsCommands[i], m_text, strlen(k_SymbolsCommands[i])) == 0) {
|
||||
m_text += strlen(m_text);
|
||||
if (*m_text == ' ' || *m_text == '{') {
|
||||
return popSymbolCommand(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Greek capital letters
|
||||
else if (strncmp(k_AlphaCommand, m_text, strlen(k_AlphaCommand)) == 0) {
|
||||
m_text += strlen(k_AlphaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popAlphaCommand();
|
||||
for (int i = 0; i < k_NumberOfFunctionCommands; i++) {
|
||||
if (strncmp(k_FunctionCommands[i], m_text, strlen(k_FunctionCommands[i])) == 0) {
|
||||
m_text += strlen(k_FunctionCommands[i]);
|
||||
if (*m_text == ' ' || *m_text == '(' || *m_text == '{') {
|
||||
return LayoutHelper::String(k_FunctionCommands[i], strlen(k_FunctionCommands[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_BetaCommand, m_text, strlen(k_BetaCommand)) == 0) {
|
||||
m_text += strlen(k_BetaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popBetaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_GammaCommand, m_text, strlen(k_GammaCommand)) == 0) {
|
||||
m_text += strlen(k_GammaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popGammaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_DeltaCommand, m_text, strlen(k_DeltaCommand)) == 0) {
|
||||
m_text += strlen(k_DeltaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popDeltaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_EpsilonCommand, m_text, strlen(k_EpsilonCommand)) == 0) {
|
||||
m_text += strlen(k_EpsilonCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popEpsilonCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_ZetaCommand, m_text, strlen(k_ZetaCommand)) == 0) {
|
||||
m_text += strlen(k_ZetaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popZetaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_EtaCommand, m_text, strlen(k_EtaCommand)) == 0) {
|
||||
m_text += strlen(k_EtaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popEtaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_ThetaCommand, m_text, strlen(k_ThetaCommand)) == 0) {
|
||||
m_text += strlen(k_ThetaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popThetaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_IotaCommand, m_text, strlen(k_IotaCommand)) == 0) {
|
||||
m_text += strlen(k_IotaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popIotaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_KappaCommand, m_text, strlen(k_KappaCommand)) == 0) {
|
||||
m_text += strlen(k_KappaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popKappaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_LambdaCommand, m_text, strlen(k_LambdaCommand)) == 0) {
|
||||
m_text += strlen(k_LambdaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popLambdaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_MuCommand, m_text, strlen(k_MuCommand)) == 0) {
|
||||
m_text += strlen(k_MuCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popMuCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_NuCommand, m_text, strlen(k_NuCommand)) == 0) {
|
||||
m_text += strlen(k_NuCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popNuCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_XiCommand, m_text, strlen(k_XiCommand)) == 0) {
|
||||
m_text += strlen(k_XiCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popXiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_PiCommand, m_text, strlen(k_PiCommand)) == 0) {
|
||||
m_text += strlen(k_PiCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popPiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_OmicronCommand, m_text, strlen(k_OmicronCommand)) == 0) {
|
||||
m_text += strlen(k_OmicronCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popOmicronCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_RhoCommand, m_text, strlen(k_RhoCommand)) == 0) {
|
||||
m_text += strlen(k_RhoCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popRhoCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_SigmaCommand, m_text, strlen(k_SigmaCommand)) == 0) {
|
||||
m_text += strlen(k_SigmaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popSigmaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_TauCommand, m_text, strlen(k_TauCommand)) == 0) {
|
||||
m_text += strlen(k_TauCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popTauCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_UpsilonCommand, m_text, strlen(k_UpsilonCommand)) == 0) {
|
||||
m_text += strlen(k_UpsilonCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popUpsilonCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_PhiCommand, m_text, strlen(k_PhiCommand)) == 0) {
|
||||
m_text += strlen(k_PhiCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popPhiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_ChiCommand, m_text, strlen(k_ChiCommand)) == 0) {
|
||||
m_text += strlen(k_ChiCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popChiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_PsiCommand, m_text, strlen(k_PsiCommand)) == 0) {
|
||||
m_text += strlen(k_PsiCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popPsiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_OmegaCommand, m_text, strlen(k_OmegaCommand)) == 0) {
|
||||
m_text += strlen(k_OmegaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popOmegaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_alphaCommand, m_text, strlen(k_alphaCommand)) == 0) {
|
||||
m_text += strlen(k_alphaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popalphaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_betaCommand, m_text, strlen(k_betaCommand)) == 0) {
|
||||
m_text += strlen(k_betaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popbetaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_gammaCommand, m_text, strlen(k_gammaCommand)) == 0) {
|
||||
m_text += strlen(k_gammaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popgammaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_deltaCommand, m_text, strlen(k_deltaCommand)) == 0) {
|
||||
m_text += strlen(k_deltaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popdeltaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_epsilonCommand, m_text, strlen(k_epsilonCommand)) == 0) {
|
||||
m_text += strlen(k_epsilonCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popepsilonCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_zetaCommand, m_text, strlen(k_zetaCommand)) == 0) {
|
||||
m_text += strlen(k_zetaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popzetaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_etaCommand, m_text, strlen(k_etaCommand)) == 0) {
|
||||
m_text += strlen(k_etaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popetaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_thetaCommand, m_text, strlen(k_thetaCommand)) == 0) {
|
||||
m_text += strlen(k_thetaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popthetaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_iotaCommand, m_text, strlen(k_iotaCommand)) == 0) {
|
||||
m_text += strlen(k_iotaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popiotaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_kappaCommand, m_text, strlen(k_kappaCommand)) == 0) {
|
||||
m_text += strlen(k_kappaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popkappaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_lambdaCommand, m_text, strlen(k_lambdaCommand)) == 0) {
|
||||
m_text += strlen(k_lambdaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poplambdaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_muCommand, m_text, strlen(k_muCommand)) == 0) {
|
||||
m_text += strlen(k_muCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popmuCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_nuCommand, m_text, strlen(k_nuCommand)) == 0) {
|
||||
m_text += strlen(k_nuCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popnuCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_xiCommand, m_text, strlen(k_xiCommand)) == 0) {
|
||||
m_text += strlen(k_xiCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popxiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_piCommand, m_text, strlen(k_piCommand)) == 0) {
|
||||
m_text += strlen(k_piCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poppiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_rhoCommand, m_text, strlen(k_rhoCommand)) == 0) {
|
||||
m_text += strlen(k_rhoCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poprhoCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_sigmaCommand, m_text, strlen(k_sigmaCommand)) == 0) {
|
||||
m_text += strlen(k_sigmaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popsigmaCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_tauCommand, m_text, strlen(k_tauCommand)) == 0) {
|
||||
m_text += strlen(k_tauCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poptauCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_upsilonCommand, m_text, strlen(k_upsilonCommand)) == 0) {
|
||||
m_text += strlen(k_upsilonCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popupsilonCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_phiCommand, m_text, strlen(k_phiCommand)) == 0) {
|
||||
m_text += strlen(k_phiCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popphiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_chiCommand, m_text, strlen(k_chiCommand)) == 0) {
|
||||
m_text += strlen(k_chiCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popchiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_psiCommand, m_text, strlen(k_psiCommand)) == 0) {
|
||||
m_text += strlen(k_psiCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return poppsiCommand();
|
||||
}
|
||||
}
|
||||
else if (strncmp(k_omegaCommand, m_text, strlen(k_omegaCommand)) == 0) {
|
||||
m_text += strlen(k_omegaCommand);
|
||||
if (*m_text == ' ' || *m_text == '\\' || *m_text == '$') {
|
||||
return popomegaCommand();
|
||||
}
|
||||
}
|
||||
|
||||
m_hasError = true;
|
||||
}
|
||||
|
||||
m_hasError = true;
|
||||
return LayoutHelper::String(m_text, strlen(m_text));
|
||||
}
|
||||
|
||||
@@ -558,283 +159,9 @@ Layout TexParser::popSqrtCommand() {
|
||||
}
|
||||
}
|
||||
|
||||
// Symbols
|
||||
Layout TexParser::poptimesCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0xd7));
|
||||
}
|
||||
|
||||
Layout TexParser::popdivCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0xf7));
|
||||
}
|
||||
|
||||
Layout TexParser::popforallCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2200));
|
||||
}
|
||||
|
||||
Layout TexParser::poppartialCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2202));
|
||||
}
|
||||
|
||||
Layout TexParser::popexistsCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2203));
|
||||
}
|
||||
|
||||
Layout TexParser::poppmCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0xb1));
|
||||
}
|
||||
|
||||
Layout TexParser::popapproxCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2248));
|
||||
}
|
||||
|
||||
Layout TexParser::popinftyCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x221e));
|
||||
}
|
||||
|
||||
Layout TexParser::popneqCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2260));
|
||||
}
|
||||
|
||||
Layout TexParser::popequivCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2261));
|
||||
}
|
||||
|
||||
Layout TexParser::popleqCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2264));
|
||||
}
|
||||
|
||||
Layout TexParser::popgeqCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2265));
|
||||
}
|
||||
|
||||
Layout TexParser::popleftarrowCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2190));
|
||||
}
|
||||
|
||||
Layout TexParser::popuparrowCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2191));
|
||||
}
|
||||
|
||||
Layout TexParser::poprightarrowCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2192));
|
||||
}
|
||||
|
||||
Layout TexParser::popdownarrowCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2193));
|
||||
}
|
||||
|
||||
Layout TexParser::popleftrightarrowCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2194));
|
||||
}
|
||||
|
||||
Layout TexParser::popupdownarrowCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x2195));
|
||||
}
|
||||
|
||||
Layout TexParser::popLeftarrowCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x21d0));
|
||||
}
|
||||
|
||||
Layout TexParser::popUparrowCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x21d1));
|
||||
}
|
||||
|
||||
Layout TexParser::popRightarrowCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x21d2));
|
||||
}
|
||||
|
||||
Layout TexParser::popDownarrowCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x21d3));
|
||||
}
|
||||
|
||||
// Greek Capital letters
|
||||
Layout TexParser::popAlphaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x391));
|
||||
}
|
||||
|
||||
Layout TexParser::popBetaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x392));
|
||||
}
|
||||
|
||||
Layout TexParser::popGammaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x393));
|
||||
}
|
||||
|
||||
Layout TexParser::popDeltaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x394));
|
||||
}
|
||||
|
||||
Layout TexParser::popEpsilonCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x395));
|
||||
}
|
||||
|
||||
Layout TexParser::popZetaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x396));
|
||||
}
|
||||
|
||||
Layout TexParser::popEtaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x397));
|
||||
}
|
||||
|
||||
Layout TexParser::popThetaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x398));
|
||||
}
|
||||
|
||||
Layout TexParser::popIotaCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x399));
|
||||
}
|
||||
|
||||
Layout TexParser::popKappaCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x39a));
|
||||
}
|
||||
|
||||
Layout TexParser::popLambdaCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x39b));
|
||||
}
|
||||
|
||||
Layout TexParser::popMuCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x39c));
|
||||
}
|
||||
|
||||
Layout TexParser::popNuCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x39d));
|
||||
}
|
||||
|
||||
Layout TexParser::popXiCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x39e));
|
||||
}
|
||||
|
||||
Layout TexParser::popOmicronCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x39f));
|
||||
}
|
||||
|
||||
Layout TexParser::popPiCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3a0));
|
||||
}
|
||||
|
||||
Layout TexParser::popRhoCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3a1));
|
||||
}
|
||||
|
||||
Layout TexParser::popSigmaCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3a3));
|
||||
}
|
||||
|
||||
Layout TexParser::popTauCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3a4));
|
||||
}
|
||||
|
||||
Layout TexParser::popUpsilonCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3a5));
|
||||
}
|
||||
|
||||
Layout TexParser::popPhiCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3a6));
|
||||
}
|
||||
|
||||
Layout TexParser::popChiCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3a7));
|
||||
}
|
||||
|
||||
Layout TexParser::popPsiCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3a8));
|
||||
}
|
||||
|
||||
Layout TexParser::popOmegaCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3a9));
|
||||
}
|
||||
|
||||
// Greek small letters
|
||||
Layout TexParser::popalphaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3b1));
|
||||
}
|
||||
|
||||
Layout TexParser::popbetaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3b2));
|
||||
}
|
||||
|
||||
Layout TexParser::popgammaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3b3));
|
||||
}
|
||||
|
||||
Layout TexParser::popdeltaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3b4));
|
||||
}
|
||||
|
||||
Layout TexParser::popepsilonCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3b5));
|
||||
}
|
||||
|
||||
Layout TexParser::popzetaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3b6));
|
||||
}
|
||||
|
||||
Layout TexParser::popetaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3b7));
|
||||
}
|
||||
|
||||
Layout TexParser::popthetaCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3b8));
|
||||
}
|
||||
|
||||
Layout TexParser::popiotaCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3b9));
|
||||
}
|
||||
|
||||
Layout TexParser::popkappaCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3ba));
|
||||
}
|
||||
|
||||
Layout TexParser::poplambdaCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3bb));
|
||||
}
|
||||
|
||||
Layout TexParser::popmuCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3bc));
|
||||
}
|
||||
|
||||
Layout TexParser::popnuCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3bd));
|
||||
}
|
||||
|
||||
Layout TexParser::popxiCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3be));
|
||||
}
|
||||
|
||||
Layout TexParser::poppiCommand() {
|
||||
return CodePointLayout::Builder(CodePoint(0x3c0));
|
||||
}
|
||||
|
||||
Layout TexParser::poprhoCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3c1));
|
||||
}
|
||||
|
||||
Layout TexParser::popsigmaCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3c3));
|
||||
}
|
||||
|
||||
Layout TexParser::poptauCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3c4));
|
||||
}
|
||||
|
||||
Layout TexParser::popupsilonCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3c5));
|
||||
}
|
||||
|
||||
Layout TexParser::popphiCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3c6));
|
||||
}
|
||||
|
||||
Layout TexParser::popchiCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3c7));
|
||||
}
|
||||
|
||||
Layout TexParser::poppsiCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3c8));
|
||||
}
|
||||
|
||||
Layout TexParser::popomegaCommand(){
|
||||
return CodePointLayout::Builder(CodePoint(0x3c9));
|
||||
Layout TexParser::popSymbolCommand(int SymbolIndex) {
|
||||
uint32_t codePoint = k_SymbolsCodePoints[SymbolIndex];
|
||||
return CodePointLayout::Builder(codePoint);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,170 +23,47 @@ private:
|
||||
Layout popFracCommand();
|
||||
Layout popSqrtCommand();
|
||||
|
||||
// Symbols
|
||||
Layout poptimesCommand();
|
||||
Layout popdivCommand();
|
||||
Layout popforallCommand();
|
||||
Layout poppartialCommand();
|
||||
Layout popexistsCommand();
|
||||
Layout poppmCommand();
|
||||
Layout popinftyCommand();
|
||||
Layout popapproxCommand();
|
||||
Layout popneqCommand();
|
||||
Layout popequivCommand();
|
||||
Layout popleqCommand();
|
||||
Layout popgeqCommand();
|
||||
|
||||
// Arrows
|
||||
Layout popleftarrowCommand();
|
||||
Layout popuparrowCommand();
|
||||
Layout poprightarrowCommand();
|
||||
Layout popdownarrowCommand();
|
||||
Layout popleftrightarrowCommand();
|
||||
Layout popupdownarrowCommand();
|
||||
Layout popLeftarrowCommand();
|
||||
Layout popUparrowCommand();
|
||||
Layout popRightarrowCommand();
|
||||
Layout popDownarrowCommand();
|
||||
|
||||
// Greek capital letters
|
||||
|
||||
Layout popAlphaCommand();
|
||||
Layout popBetaCommand();
|
||||
Layout popGammaCommand();
|
||||
Layout popDeltaCommand();
|
||||
Layout popEpsilonCommand();
|
||||
Layout popZetaCommand();
|
||||
Layout popEtaCommand();
|
||||
Layout popThetaCommand();
|
||||
Layout popIotaCommand();
|
||||
Layout popKappaCommand();
|
||||
Layout popLambdaCommand();
|
||||
Layout popMuCommand();
|
||||
Layout popNuCommand();
|
||||
Layout popXiCommand();
|
||||
Layout popOmicronCommand();
|
||||
Layout popPiCommand();
|
||||
Layout popRhoCommand();
|
||||
Layout popSigmaCommand();
|
||||
Layout popTauCommand();
|
||||
Layout popUpsilonCommand();
|
||||
Layout popPhiCommand();
|
||||
Layout popChiCommand();
|
||||
Layout popPsiCommand();
|
||||
Layout popOmegaCommand();
|
||||
|
||||
// Greek small letters
|
||||
Layout popalphaCommand();
|
||||
Layout popbetaCommand();
|
||||
Layout popgammaCommand();
|
||||
Layout popdeltaCommand();
|
||||
Layout popepsilonCommand();
|
||||
Layout popzetaCommand();
|
||||
Layout popetaCommand();
|
||||
Layout popthetaCommand();
|
||||
Layout popiotaCommand();
|
||||
Layout popkappaCommand();
|
||||
Layout poplambdaCommand();
|
||||
Layout popmuCommand();
|
||||
Layout popnuCommand();
|
||||
Layout popxiCommand();
|
||||
Layout poppiCommand();
|
||||
Layout poprhoCommand();
|
||||
Layout popsigmaCommand();
|
||||
Layout poptauCommand();
|
||||
Layout popupsilonCommand();
|
||||
Layout popphiCommand();
|
||||
Layout popchiCommand();
|
||||
Layout poppsiCommand();
|
||||
Layout popomegaCommand();
|
||||
//Symbols
|
||||
Layout popSymbolCommand(int SymbolIndex);
|
||||
|
||||
const char * m_text;
|
||||
const char * m_endOfText;
|
||||
bool m_hasError;
|
||||
|
||||
// Expressions
|
||||
// Expressions that require specific handling
|
||||
static constexpr char const * k_fracCommand = "frac";
|
||||
static constexpr char const * k_sqrtCommand = "sqrt";
|
||||
|
||||
// Symbols
|
||||
static constexpr char const * k_timesCommand = "times";
|
||||
static constexpr char const * k_divCommand = "div";
|
||||
static constexpr char const * k_forallCommand = "forall";
|
||||
static constexpr char const * k_partialCommand = "partial";
|
||||
static constexpr char const * k_existsCommand = "exists";
|
||||
static constexpr char const * k_pmCommand = "pm";
|
||||
static constexpr char const * k_inftyCommand = "infty";
|
||||
static constexpr char const * k_approxCommand = "approx";
|
||||
static constexpr char const * k_neqCommand = "neq";
|
||||
static constexpr char const * k_equivCommand = "equiv";
|
||||
static constexpr char const * k_leqCommand = "leq";
|
||||
static constexpr char const * k_geqCommand = "geq";
|
||||
static constexpr int const k_NumberOfSymbols = 70;
|
||||
static constexpr int const k_NumberOfFunctionCommands = 32;
|
||||
|
||||
// List of available Symbols
|
||||
static constexpr char const * k_SymbolsCommands[k_NumberOfSymbols] = {
|
||||
"times", "div", "forall", "partial", "exists", "pm", "approx", "infty", "neq", "equiv", "leq", "geq",
|
||||
"leftarrow", "uparrow", "rightarrow", "downarrow", "leftrightarrow", "updownarrow", "Leftarrow", "Uparrow", "Rightarrow", "Downarrow",
|
||||
"Alpha", "Beta", "Gamma", "Delta", "Epsilon", "Zeta", "Eta", "Theta", "Iota", "Kappa", "Lambda",
|
||||
"Mu", "Nu", "Xi", "Omicron", "Pi", "Rho", "Sigma", "Tau", "Upsilon", "Phi", "Chi", "Psi","Omega",
|
||||
"alpha", "beta", "gamma", "delta", "epsilon", "zeta", "eta", "theta", "iota", "kappa", "lambda",
|
||||
"mu", "nu", "xi", "omicron", "pi", "rho", "sigma", "tau", "upsilon", "phi", "chi", "psi", "omega",
|
||||
};
|
||||
|
||||
// Arrows
|
||||
static constexpr char const * k_leftarrowCommand = "leftarrow";
|
||||
static constexpr char const * k_uparrowCommand = "uparrow";
|
||||
static constexpr char const * k_rightarrowCommand = "rightarrow";
|
||||
static constexpr char const * k_downarrowCommand = "downarrow";
|
||||
static constexpr char const * k_leftrightarrowCommand = "leftrightarrow";
|
||||
static constexpr char const * k_updownarrowCommand = "updownarrow";
|
||||
static constexpr char const * k_LeftarrowCommand = "Leftarrow";
|
||||
static constexpr char const * k_UparrowCommand = "Uparrow";
|
||||
static constexpr char const * k_RightarrowCommand = "Rightarrow";
|
||||
static constexpr char const * k_DownarrowCommand = "Downarrow";
|
||||
// Greek capital letters
|
||||
|
||||
static constexpr char const * k_AlphaCommand = "Alpha";
|
||||
static constexpr char const * k_BetaCommand = "Beta";
|
||||
static constexpr char const * k_GammaCommand = "Gamma";
|
||||
static constexpr char const * k_DeltaCommand = "Delta";
|
||||
static constexpr char const * k_EpsilonCommand = "Epsilon";
|
||||
static constexpr char const * k_ZetaCommand = "Zeta";
|
||||
static constexpr char const * k_EtaCommand = "Eta";
|
||||
static constexpr char const * k_ThetaCommand = "Theta";
|
||||
static constexpr char const * k_IotaCommand = "Iota";
|
||||
static constexpr char const * k_KappaCommand = "Kappa";
|
||||
static constexpr char const * k_LambdaCommand = "Lambda";
|
||||
static constexpr char const * k_MuCommand = "Mu";
|
||||
static constexpr char const * k_NuCommand = "Nu";
|
||||
static constexpr char const * k_XiCommand = "Xi";
|
||||
static constexpr char const * k_OmicronCommand = "Omicron";
|
||||
static constexpr char const * k_PiCommand = "Pi";
|
||||
static constexpr char const * k_RhoCommand = "Rho";
|
||||
static constexpr char const * k_SigmaCommand = "Sigma";
|
||||
static constexpr char const * k_TauCommand = "Tau";
|
||||
static constexpr char const * k_UpsilonCommand = "Upsilon";
|
||||
static constexpr char const * k_PhiCommand = "Phi";
|
||||
static constexpr char const * k_ChiCommand = "Chi";
|
||||
static constexpr char const * k_PsiCommand = "Psi";
|
||||
static constexpr char const * k_OmegaCommand = "Omega";
|
||||
|
||||
// Greek small letters
|
||||
static constexpr char const * k_alphaCommand = "alpha";
|
||||
static constexpr char const * k_betaCommand = "beta";
|
||||
static constexpr char const * k_gammaCommand = "gamma";
|
||||
static constexpr char const * k_deltaCommand = "delta";
|
||||
static constexpr char const * k_epsilonCommand = "epsilon";
|
||||
static constexpr char const * k_zetaCommand = "zeta";
|
||||
static constexpr char const * k_etaCommand = "eta";
|
||||
static constexpr char const * k_thetaCommand = "theta";
|
||||
static constexpr char const * k_iotaCommand = "iota";
|
||||
static constexpr char const * k_kappaCommand = "kappa";
|
||||
static constexpr char const * k_lambdaCommand = "lambda";
|
||||
static constexpr char const * k_muCommand = "mu";
|
||||
static constexpr char const * k_nuCommand = "nu";
|
||||
static constexpr char const * k_xiCommand = "xi";
|
||||
// static constexpr char const * k_omicronCommand = "omicron"; // just write "o"
|
||||
static constexpr char const * k_piCommand = "pi";
|
||||
static constexpr char const * k_rhoCommand = "rho";
|
||||
static constexpr char const * k_sigmaCommand = "sigma";
|
||||
static constexpr char const * k_tauCommand = "tau";
|
||||
static constexpr char const * k_upsilonCommand = "upsilon";
|
||||
static constexpr char const * k_phiCommand = "phi";
|
||||
static constexpr char const * k_chiCommand = "chi";
|
||||
static constexpr char const * k_psiCommand = "psi";
|
||||
static constexpr char const * k_omegaCommand = "omega";
|
||||
//List of the available Symbol's CodePoints in the same order of the Symbol's list
|
||||
static constexpr uint32_t const k_SymbolsCodePoints[k_NumberOfSymbols] = {
|
||||
0xd7, 0xf7, 0x2200, 0x2202, 0x2203, 0xb1, 0x2248, 0x221e, 0x2260, 0x2261, 0x2264, 0x2265,
|
||||
0x2190, 0x2191, 0x2192, 0x2193, 0x2194, 0x2195, 0x21d0, 0x21d1, 0x21d2, 0x21d3,
|
||||
0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, 0x398, 0x399, 0x39a, 0x39b,
|
||||
0x39c, 0x39d, 0x39e, 0x39f, 0x3a0, 0x3a1, 0x3a3, 0x3a4, 0x3a5, 0x3a6, 0x3a7, 0x3a8, 0x3a9,
|
||||
0x3b1, 0x3b2, 0x3b3, 0x3b4, 0x3b5, 0x3b6, 0x3b7, 0x3b8, 0x3b9, 0x3ba, 0x3bb,
|
||||
0x3bc, 0x3bd, 0x3be, 0x3bf, 0x3c0, 0x3c1, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7, 0x3c8, 0x3c9
|
||||
};
|
||||
|
||||
// List of available Function Commands that don't require a specific handling
|
||||
static constexpr char const * k_FunctionCommands[k_NumberOfFunctionCommands] = {
|
||||
"arcos", "arcsin", "arctan", "arg", "cos", "cosh", "cot", "coth",
|
||||
"csc", "deg", "det", "dim", "exp", "gcd", "hom", "inf",
|
||||
"ker", "lg", "lim", "liminf", "limsup", "ln", "log", "max",
|
||||
"min", "Pr", "sec", "sin", "sinh", "sup", "tan", "tanh"
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user