[ion] Add a special char: CapitalDelta

This commit is contained in:
Émilie Feral
2018-05-30 17:58:05 +02:00
parent cfb891d7bd
commit f992253cec
9 changed files with 74 additions and 74 deletions

View File

@@ -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",

View File

@@ -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.
};
}

View File

@@ -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};

View File

@@ -3,7 +3,7 @@
#include <stddef.h>
#define NUMBER_OF_SYMBOLS 23
#define NUMBER_OF_SYMBOLS 24
extern wchar_t codePointForSymbol[NUMBER_OF_SYMBOLS];

View File

@@ -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; }

View File

@@ -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;
}

View File

@@ -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<typename T>

View File

@@ -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) {

View File

@@ -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);