From f992253ceccf97f4e38ba87ec2554566ad022629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 30 May 2018 17:58:05 +0200 Subject: [PATCH] [ion] Add a special char: CapitalDelta --- apps/i18n.py | 1 + ion/include/ion/charset.h | 37 +++++++------ kandinsky/fonts/unicode_for_symbol.c | 4 +- kandinsky/fonts/unicode_for_symbol.h | 2 +- poincare/src/expression_lexer.l | 16 +++--- poincare/src/layout/nth_root_layout.cpp | 6 +- poincare/src/square_root.cpp | 4 +- poincare/src/store.cpp | 4 +- poincare/src/trigonometry.cpp | 74 ++++++++++++------------- 9 files changed, 74 insertions(+), 74 deletions(-) diff --git a/apps/i18n.py b/apps/i18n.py index 7a6a71ede..da39113c7 100644 --- a/apps/i18n.py +++ b/apps/i18n.py @@ -7,6 +7,7 @@ import argparse import io ion_special_characters = { + u'Δ': "Ion::Charset::CapitalDelta", u'Σ': "Ion::Charset::CapitalSigma", u'λ': "Ion::Charset::SmallLambda", u'μ': "Ion::Charset::SmallMu", diff --git a/ion/include/ion/charset.h b/ion/include/ion/charset.h index 333c2c4c6..e7a36f5b2 100644 --- a/ion/include/ion/charset.h +++ b/ion/include/ion/charset.h @@ -8,24 +8,25 @@ enum Charset : char { XBar = (char)128, YBar = (char)130, CapitalGamma = (char)132, - CapitalSigma = (char)133, - SmallTheta = (char)134, - SmallLambda = (char)135, - SmallMu = (char)136, - SmallPi = (char)137, - SmallSigma = (char)138, - IComplex = (char)139, - Exponent = (char)140, - Prime = (char)141, - Exponential = (char)142, - Sto = (char)143, - Root = (char)144, - LessEqual = (char)145, - GreaterEqual = (char)146, - MultiplicationSign = (char)147, - MiddleDot = (char)148, - AlmostEqual = (char)149, - Empty = (char)150 // This char is used to be parsed into EmptyExpression. + CapitalDelta = (char)133, + CapitalSigma = (char)134, + SmallTheta = (char)135, + SmallLambda = (char)136, + SmallMu = (char)137, + SmallPi = (char)138, + SmallSigma = (char)139, + IComplex = (char)140, + Exponent = (char)141, + Prime = (char)142, + Exponential = (char)143, + Sto = (char)144, + Root = (char)145, + LessEqual = (char)146, + GreaterEqual = (char)147, + MultiplicationSign = (char)148, + MiddleDot = (char)149, + AlmostEqual = (char)150, + Empty = (char)151 // This char is used to be parsed into EmptyExpression. }; } diff --git a/kandinsky/fonts/unicode_for_symbol.c b/kandinsky/fonts/unicode_for_symbol.c index 150ba9f04..7dc8f24e4 100644 --- a/kandinsky/fonts/unicode_for_symbol.c +++ b/kandinsky/fonts/unicode_for_symbol.c @@ -1,5 +1,3 @@ #include "unicode_for_symbol.h" -wchar_t codePointForSymbol[NUMBER_OF_SYMBOLS] = {0x222b, 0x0078, 0x0305, - 0x0079, 0x0305, 0x0393, 0x03a3, 0x03b8, 0x03bb, 0x03bc, 0x03c0, 0x03c3, 0x0456, - 0x1D07, 0x2032, 0x212e, 0x2192, 0x221A, 0x2264, 0x2265, 0x00D7, 0x00B7, 0x2248}; +wchar_t codePointForSymbol[NUMBER_OF_SYMBOLS] = {0x222b, 0x0078, 0x0305, 0x0079, 0x0305, 0x0393, 0x0394, 0x03a3, 0x03b8, 0x03bb, 0x03bc, 0x03c0, 0x03c3, 0x0456, 0x1D07, 0x2032, 0x212e, 0x2192, 0x221A, 0x2264, 0x2265, 0x00D7, 0x00B7, 0x2248}; diff --git a/kandinsky/fonts/unicode_for_symbol.h b/kandinsky/fonts/unicode_for_symbol.h index 4a76c5da2..17543313a 100644 --- a/kandinsky/fonts/unicode_for_symbol.h +++ b/kandinsky/fonts/unicode_for_symbol.h @@ -3,7 +3,7 @@ #include -#define NUMBER_OF_SYMBOLS 23 +#define NUMBER_OF_SYMBOLS 24 extern wchar_t codePointForSymbol[NUMBER_OF_SYMBOLS]; diff --git a/poincare/src/expression_lexer.l b/poincare/src/expression_lexer.l index be1537876..0dd8fc4d2 100644 --- a/poincare/src/expression_lexer.l +++ b/poincare/src/expression_lexer.l @@ -141,17 +141,17 @@ trace { poincare_expression_yylval.expression = new MatrixTrace(); return FUNCTI transpose { poincare_expression_yylval.expression = new MatrixTranspose(); return FUNCTION; } undef { poincare_expression_yylval.expression = new Undefined(); return UNDEFINED; } inf { poincare_expression_yylval.expression = new Undefined(); return UNDEFINED; } -\x89 { poincare_expression_yylval.character = yytext[0]; return SYMBOL; } -\x8c { return EE; } -\x90 { poincare_expression_yylval.expression = new SquareRoot(); return FUNCTION; } -\x8b { poincare_expression_yylval.character = yytext[0]; return SYMBOL; } -\x8e { poincare_expression_yylval.character = yytext[0]; return SYMBOL; } -\x8f { return STO; } +\x8a { poincare_expression_yylval.character = yytext[0]; return SYMBOL; } +\x8d { return EE; } +\x91 { poincare_expression_yylval.expression = new SquareRoot(); return FUNCTION; } +\x8c { poincare_expression_yylval.character = yytext[0]; return SYMBOL; } +\x8f { poincare_expression_yylval.character = yytext[0]; return SYMBOL; } +\x90 { return STO; } = { return EQUAL; } \+ { return PLUS; } \- { return MINUS; } -\x93 { return MULTIPLY; } \x94 { return MULTIPLY; } +\x95 { return MULTIPLY; } \* { return MULTIPLY; } \/ { return DIVIDE; } \^ { return POW; } @@ -165,7 +165,7 @@ inf { poincare_expression_yylval.expression = new Undefined(); return UNDEFINED; \, { return COMMA; } \. { return DOT; } \_ { return UNDERSCORE; } -\x96 { poincare_expression_yylval.expression = new EmptyExpression(); return EMPTY; } +\x97 { poincare_expression_yylval.expression = new EmptyExpression(); return EMPTY; } [ ]+ /* Ignore whitespaces */ . { return UNDEFINED_SYMBOL; } diff --git a/poincare/src/layout/nth_root_layout.cpp b/poincare/src/layout/nth_root_layout.cpp index 987862239..cb398eb40 100644 --- a/poincare/src/layout/nth_root_layout.cpp +++ b/poincare/src/layout/nth_root_layout.cpp @@ -149,7 +149,7 @@ ExpressionLayoutCursor NthRootLayout::cursorUnder(ExpressionLayoutCursor cursor, return ExpressionLayout::cursorUnder(cursor, shouldRecomputeLayout, equivalentPositionVisited); } -static_assert('\x90' == Ion::Charset::Root, "Unicode error"); +static_assert('\x91' == Ion::Charset::Root, "Unicode error"); int NthRootLayout::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const { // Case: root(x,n) if (numberOfChildren() == 2 @@ -160,7 +160,7 @@ int NthRootLayout::writeTextInBuffer(char * buffer, int bufferSize, int numberOf } // Case: squareRoot(x) if (numberOfChildren() == 1) { - return LayoutEngine::writePrefixExpressionLayoutTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "\x90"); + return LayoutEngine::writePrefixExpressionLayoutTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "\x91"); } // Case: root(x,empty) // Write "'SquareRootSymbol'('radicandLayout')". @@ -171,7 +171,7 @@ int NthRootLayout::writeTextInBuffer(char * buffer, int bufferSize, int numberOf buffer[bufferSize-1] = 0; int numberOfChar = 0; - buffer[numberOfChar++] = '\x90'; + buffer[numberOfChar++] = '\x91'; if (numberOfChar >= bufferSize-1) { return bufferSize-1; } diff --git a/poincare/src/square_root.cpp b/poincare/src/square_root.cpp index 2681a8037..7b8105b7a 100644 --- a/poincare/src/square_root.cpp +++ b/poincare/src/square_root.cpp @@ -20,9 +20,9 @@ Expression * SquareRoot::clone() const { return a; } -static_assert('\x90' == Ion::Charset::Root, "Unicode error"); +static_assert('\x91' == Ion::Charset::Root, "Unicode error"); int SquareRoot::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const { - return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "\x90"); + return LayoutEngine::writePrefixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "\x91"); } template diff --git a/poincare/src/store.cpp b/poincare/src/store.cpp index 778d2639f..31164a008 100644 --- a/poincare/src/store.cpp +++ b/poincare/src/store.cpp @@ -24,9 +24,9 @@ int Store::polynomialDegree(char symbolName) const { return -1; } -static_assert('\x8F' == Ion::Charset::Sto, "Incorrect"); +static_assert('\x90' == Ion::Charset::Sto, "Incorrect"); int Store::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const { - return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "\x8F"); + return LayoutEngine::writeInfixExpressionTextInBuffer(this, buffer, bufferSize, numberOfSignificantDigits, "\x90"); } Expression * Store::shallowReduce(Context& context, AngleUnit angleUnit) { diff --git a/poincare/src/trigonometry.cpp b/poincare/src/trigonometry.cpp index d5da745f6..f6e8fccc0 100644 --- a/poincare/src/trigonometry.cpp +++ b/poincare/src/trigonometry.cpp @@ -163,45 +163,45 @@ Expression * Trigonometry::shallowReduceInverseFunction(Expression * e, Context& return e; } -static_assert('\x89' == Ion::Charset::SmallPi, "Unicode error"); +static_assert('\x8A' == Ion::Charset::SmallPi, "Unicode error"); constexpr const char * cheatTable[Trigonometry::k_numberOfEntries][5] = -{{"-90", "\x89*(-2)^(-1)", "", "-1", "undef"}, - {"-75", "\x89*(-5)*12^(-1)", "", "(-1)*6^(1/2)*4^(-1)-2^(1/2)*4^(-1)", "-(3^(1/2)+2)"}, - {"-72", "\x89*2*(-5)^(-1)", "", "-(5/8+5^(1/2)/8)^(1/2)", "-(5+2*5^(1/2))^(1/2)"}, - {"-135/2", "\x89*(-3)*8^(-1)", "", "-(2+2^(1/2))^(1/2)*2^(-1)", "-1-2^(1/2)"}, - {"-60", "\x89*(-3)^(-1)", "", "-3^(1/2)*2^(-1)", "-3^(1/2)"}, - {"-54", "\x89*(-3)*10^(-1)", "", "4^(-1)*(-1-5^(1/2))", "-(1+2*5^(-1/2))^(1/2)"}, - {"-45", "\x89*(-4)^(-1)", "", "(-1)*(2^(-1/2))", "-1"}, - {"-36", "\x89*(-5)^(-1)", "", "-(5/8-5^(1/2)/8)^(1/2)", "-(5-2*5^(1/2))^(1/2)"}, - {"-30", "\x89*(-6)^(-1)", "", "-0.5", "-3^(-1/2)"}, - {"-45/2", "\x89*(-8)^(-1)", "", "(2-2^(1/2))^(1/2)*(-2)^(-1)", "1-2^(1/2)"}, - {"-18", "\x89*(-10)^(-1)", "", "4^(-1)*(1-5^(1/2))", "-(1-2*5^(-1/2))^(1/2)"}, - {"-15", "\x89*(-12)^(-1)", "", "-6^(1/2)*4^(-1)+2^(1/2)*4^(-1)", "3^(1/2)-2"}, +{{"-90", "\x8A*(-2)^(-1)", "", "-1", "undef"}, + {"-75", "\x8A*(-5)*12^(-1)", "", "(-1)*6^(1/2)*4^(-1)-2^(1/2)*4^(-1)", "-(3^(1/2)+2)"}, + {"-72", "\x8A*2*(-5)^(-1)", "", "-(5/8+5^(1/2)/8)^(1/2)", "-(5+2*5^(1/2))^(1/2)"}, + {"-135/2", "\x8A*(-3)*8^(-1)", "", "-(2+2^(1/2))^(1/2)*2^(-1)", "-1-2^(1/2)"}, + {"-60", "\x8A*(-3)^(-1)", "", "-3^(1/2)*2^(-1)", "-3^(1/2)"}, + {"-54", "\x8A*(-3)*10^(-1)", "", "4^(-1)*(-1-5^(1/2))", "-(1+2*5^(-1/2))^(1/2)"}, + {"-45", "\x8A*(-4)^(-1)", "", "(-1)*(2^(-1/2))", "-1"}, + {"-36", "\x8A*(-5)^(-1)", "", "-(5/8-5^(1/2)/8)^(1/2)", "-(5-2*5^(1/2))^(1/2)"}, + {"-30", "\x8A*(-6)^(-1)", "", "-0.5", "-3^(-1/2)"}, + {"-45/2", "\x8A*(-8)^(-1)", "", "(2-2^(1/2))^(1/2)*(-2)^(-1)", "1-2^(1/2)"}, + {"-18", "\x8A*(-10)^(-1)", "", "4^(-1)*(1-5^(1/2))", "-(1-2*5^(-1/2))^(1/2)"}, + {"-15", "\x8A*(-12)^(-1)", "", "-6^(1/2)*4^(-1)+2^(1/2)*4^(-1)", "3^(1/2)-2"}, {"0", "0", "1", "0", "0"}, - {"15", "\x89*12^(-1)", "6^(1/2)*4^(-1)+2^(1/2)*4^(-1)", "6^(1/2)*4^(-1)+2^(1/2)*(-4)^(-1)", "-(3^(1/2)-2)"}, - {"18", "\x89*10^(-1)", "(5/8+5^(1/2)/8)^(1/2)", "4^(-1)*(5^(1/2)-1)", "(1-2*5^(-1/2))^(1/2)"}, - {"45/2", "\x89*8^(-1)", "(2+2^(1/2))^(1/2)*2^(-1)", "(2-2^(1/2))^(1/2)*2^(-1)", "2^(1/2)-1"}, - {"30", "\x89*6^(-1)", "3^(1/2)*2^(-1)", "0.5", "3^(-1/2)"}, - {"36", "\x89*5^(-1)", "(5^(1/2)+1)*4^(-1)", "(5/8-5^(1/2)/8)^(1/2)", "(5-2*5^(1/2))^(1/2)"}, - {"45", "\x89*4^(-1)", "2^(-1/2)", "2^(-1/2)", "1"}, - {"54", "\x89*3*10^(-1)", "(5/8-5^(1/2)/8)^(1/2)", "4^(-1)*(5^(1/2)+1)", "(1+2*5^(-1/2))^(1/2)"}, - {"60", "\x89*3^(-1)", "0.5", "3^(1/2)*2^(-1)", "3^(1/2)"}, - {"135/2", "\x89*3*8^(-1)", "(2-2^(1/2))^(1/2)*2^(-1)", "(2+2^(1/2))^(1/2)*2^(-1)", "1+2^(1/2)"}, - {"72", "\x89*2*5^(-1)", "(5^(1/2)-1)*4^(-1)", "(5/8+5^(1/2)/8)^(1/2)", "(5+2*5^(1/2))^(1/2)"}, - {"75", "\x89*5*12^(-1)", "6^(1/2)*4^(-1)+2^(1/2)*(-4)^(-1)", "6^(1/2)*4^(-1)+2^(1/2)*4^(-1)", "3^(1/2)+2"}, - {"90", "\x89*2^(-1)", "0", "1", "undef"}, - {"105", "\x89*7*12^(-1)", "-6^(1/2)*4^(-1)+2^(1/2)*4^(-1)", "", ""}, - {"108", "\x89*3*5^(-1)", "(1-5^(1/2))*4^(-1)", "", ""}, - {"225/2", "\x89*5*8^(-1)", "(2-2^(1/2))^(1/2)*(-2)^(-1)", "", ""}, - {"120", "\x89*2*3^(-1)", "-0.5", "", ""}, - {"126", "\x89*7*10^(-1)", "-(5*8^(-1)-5^(1/2)*8^(-1))^(1/2)", "", ""}, - {"135", "\x89*3*4^(-1)", "(-1)*(2^(-1/2))", "", ""}, - {"144", "\x89*4*5^(-1)", "(-5^(1/2)-1)*4^(-1)", "", ""}, - {"150", "\x89*5*6^(-1)", "-3^(1/2)*2^(-1)", "", ""}, - {"315/2", "\x89*7*8^(-1)", "-(2+2^(1/2))^(1/2)*2^(-1)", "", ""}, - {"162", "\x89*9*10^(-1)", "-(5*8^(-1)+5^(1/2)*8^(-1))^(1/2)", "", ""}, - {"165", "\x89*11*12^(-1)", "(-1)*6^(1/2)*4^(-1)-2^(1/2)*4^(-1)", "", ""}, - {"180", "\x89", "-1", "0", "0"}}; + {"15", "\x8A*12^(-1)", "6^(1/2)*4^(-1)+2^(1/2)*4^(-1)", "6^(1/2)*4^(-1)+2^(1/2)*(-4)^(-1)", "-(3^(1/2)-2)"}, + {"18", "\x8A*10^(-1)", "(5/8+5^(1/2)/8)^(1/2)", "4^(-1)*(5^(1/2)-1)", "(1-2*5^(-1/2))^(1/2)"}, + {"45/2", "\x8A*8^(-1)", "(2+2^(1/2))^(1/2)*2^(-1)", "(2-2^(1/2))^(1/2)*2^(-1)", "2^(1/2)-1"}, + {"30", "\x8A*6^(-1)", "3^(1/2)*2^(-1)", "0.5", "3^(-1/2)"}, + {"36", "\x8A*5^(-1)", "(5^(1/2)+1)*4^(-1)", "(5/8-5^(1/2)/8)^(1/2)", "(5-2*5^(1/2))^(1/2)"}, + {"45", "\x8A*4^(-1)", "2^(-1/2)", "2^(-1/2)", "1"}, + {"54", "\x8A*3*10^(-1)", "(5/8-5^(1/2)/8)^(1/2)", "4^(-1)*(5^(1/2)+1)", "(1+2*5^(-1/2))^(1/2)"}, + {"60", "\x8A*3^(-1)", "0.5", "3^(1/2)*2^(-1)", "3^(1/2)"}, + {"135/2", "\x8A*3*8^(-1)", "(2-2^(1/2))^(1/2)*2^(-1)", "(2+2^(1/2))^(1/2)*2^(-1)", "1+2^(1/2)"}, + {"72", "\x8A*2*5^(-1)", "(5^(1/2)-1)*4^(-1)", "(5/8+5^(1/2)/8)^(1/2)", "(5+2*5^(1/2))^(1/2)"}, + {"75", "\x8A*5*12^(-1)", "6^(1/2)*4^(-1)+2^(1/2)*(-4)^(-1)", "6^(1/2)*4^(-1)+2^(1/2)*4^(-1)", "3^(1/2)+2"}, + {"90", "\x8A*2^(-1)", "0", "1", "undef"}, + {"105", "\x8A*7*12^(-1)", "-6^(1/2)*4^(-1)+2^(1/2)*4^(-1)", "", ""}, + {"108", "\x8A*3*5^(-1)", "(1-5^(1/2))*4^(-1)", "", ""}, + {"225/2", "\x8A*5*8^(-1)", "(2-2^(1/2))^(1/2)*(-2)^(-1)", "", ""}, + {"120", "\x8A*2*3^(-1)", "-0.5", "", ""}, + {"126", "\x8A*7*10^(-1)", "-(5*8^(-1)-5^(1/2)*8^(-1))^(1/2)", "", ""}, + {"135", "\x8A*3*4^(-1)", "(-1)*(2^(-1/2))", "", ""}, + {"144", "\x8A*4*5^(-1)", "(-5^(1/2)-1)*4^(-1)", "", ""}, + {"150", "\x8A*5*6^(-1)", "-3^(1/2)*2^(-1)", "", ""}, + {"315/2", "\x8A*7*8^(-1)", "-(2+2^(1/2))^(1/2)*2^(-1)", "", ""}, + {"162", "\x8A*9*10^(-1)", "-(5*8^(-1)+5^(1/2)*8^(-1))^(1/2)", "", ""}, + {"165", "\x8A*11*12^(-1)", "(-1)*6^(1/2)*4^(-1)-2^(1/2)*4^(-1)", "", ""}, + {"180", "\x8A", "-1", "0", "0"}}; Expression * Trigonometry::table(const Expression * e, Expression::Type type, Context & context, Expression::AngleUnit angleUnit) { assert(type == Expression::Type::Sine || type == Expression::Type::Cosine || type == Expression::Type::Tangent || type == Expression::Type::ArcCosine || type == Expression::Type::ArcSine || type == Expression::Type::ArcTangent);