mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare] Rename Expression:parse in Parse
This commit is contained in:
@@ -36,7 +36,7 @@ void Calculation::setContent(const char * c, Context * context, Expression ansEx
|
||||
reset();
|
||||
{
|
||||
Symbol ansSymbol = Symbol::Ans();
|
||||
Expression input = Expression::parse(c).replaceSymbolWithExpression(ansSymbol, ansExpression);
|
||||
Expression input = Expression::Parse(c).replaceSymbolWithExpression(ansSymbol, ansExpression);
|
||||
/* We do not store directly the text enter by the user because we do not want
|
||||
* to keep Ans symbol in the calculation store. */
|
||||
PoincareHelpers::Serialize(input, m_inputText, sizeof(m_inputText));
|
||||
@@ -82,7 +82,7 @@ const char * Calculation::approximateOutputText() {
|
||||
}
|
||||
|
||||
Expression Calculation::input() {
|
||||
return Expression::parse(m_inputText);
|
||||
return Expression::Parse(m_inputText);
|
||||
}
|
||||
|
||||
Layout Calculation::createInputLayout() {
|
||||
@@ -114,7 +114,7 @@ Expression Calculation::exactOutput() {
|
||||
* thereby avoid turning cos(Pi/4) into sqrt(2)/2 and displaying
|
||||
* 'sqrt(2)/2 = 0.999906' (which is totally wrong) instead of
|
||||
* 'cos(pi/4) = 0.999906' (which is true in degree). */
|
||||
Expression exactOutput = Expression::parse(m_exactOutputText);
|
||||
Expression exactOutput = Expression::Parse(m_exactOutputText);
|
||||
if (exactOutput.isUninitialized()) {
|
||||
return Undefined();
|
||||
}
|
||||
@@ -128,7 +128,7 @@ Layout Calculation::createExactOutputLayout() {
|
||||
Expression Calculation::approximateOutput(Context * context) {
|
||||
/* To ensure that the expression 'm_output' is a matrix or a complex, we
|
||||
* call 'evaluate'. */
|
||||
Expression exp = Expression::parse(m_approximateOutputText);
|
||||
Expression exp = Expression::Parse(m_approximateOutputText);
|
||||
return PoincareHelpers::Approximate<double>(exp, *context);
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ Poincare::Expression Sequence::secondInitialConditionExpression(Context * contex
|
||||
|
||||
Poincare::Layout Sequence::firstInitialConditionLayout() {
|
||||
if (m_firstInitialConditionLayout.isUninitialized()) {
|
||||
Expression nonSimplifedExpression = Expression::parse(m_firstInitialConditionText);
|
||||
Expression nonSimplifedExpression = Expression::Parse(m_firstInitialConditionText);
|
||||
if (!nonSimplifedExpression.isUninitialized()) {
|
||||
m_firstInitialConditionLayout = PoincareHelpers::CreateLayout(nonSimplifedExpression);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ Poincare::Layout Sequence::firstInitialConditionLayout() {
|
||||
|
||||
Poincare::Layout Sequence::secondInitialConditionLayout() {
|
||||
if (m_secondInitialConditionLayout.isUninitialized()) {
|
||||
Expression nonSimplifedExpression = Expression::parse(m_secondInitialConditionText);
|
||||
Expression nonSimplifedExpression = Expression::Parse(m_secondInitialConditionText);
|
||||
if (!nonSimplifedExpression.isUninitialized()) {
|
||||
m_secondInitialConditionLayout = PoincareHelpers::CreateLayout(nonSimplifedExpression);
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ const char * ExpressionModel::text() const {
|
||||
|
||||
Poincare::Expression ExpressionModel::expression(Poincare::Context * context) const {
|
||||
if (m_expression.isUninitialized()) {
|
||||
m_expression = Expression::parse(m_text);
|
||||
m_expression = Expression::Parse(m_text);
|
||||
}
|
||||
return m_expression;
|
||||
}
|
||||
|
||||
Layout ExpressionModel::layout() {
|
||||
if (m_layout.isUninitialized()) {
|
||||
Expression nonSimplifiedExpression = Expression::parse(m_text);
|
||||
Expression nonSimplifiedExpression = Expression::Parse(m_text);
|
||||
m_layout = PoincareHelpers::CreateLayout(nonSimplifiedExpression);
|
||||
}
|
||||
return m_layout;
|
||||
|
||||
@@ -80,7 +80,7 @@ Ion::Storage::Record::ErrorStatus StorageExpressionModel::setContent(const char
|
||||
// if c = "", we want to reinit the Expression
|
||||
if (c && *c != 0) {
|
||||
// Compute the expression to store, without replacing symbols
|
||||
expressionToStore = Expression::parse(c);
|
||||
expressionToStore = Expression::Parse(c);
|
||||
if (!expressionToStore.isUninitialized()) {
|
||||
Symbol xUnknown = Symbol(Symbol::SpecialSymbols::UnknownX);
|
||||
expressionToStore = expressionToStore.replaceSymbolWithExpression(Symbol("x", 1), xUnknown);
|
||||
|
||||
@@ -84,7 +84,7 @@ bool StoreController::textFieldShouldFinishEditing(TextField * textField, Ion::E
|
||||
bool StoreController::textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) {
|
||||
if (textField == m_contentView.formulaInputView()->textField()) {
|
||||
// Handle formula input
|
||||
Expression expression = Expression::parse(textField->text());
|
||||
Expression expression = Expression::Parse(textField->text());
|
||||
if (expression.isUninitialized()) {
|
||||
app()->displayWarning(I18n::Message::SyntaxError);
|
||||
return false;
|
||||
|
||||
@@ -36,7 +36,7 @@ bool TextFieldDelegateApp::textFieldDidReceiveEvent(TextField * textField, Ion::
|
||||
|
||||
|
||||
bool TextFieldDelegateApp::isAcceptableText(const char * text) {
|
||||
Expression exp = Expression::parse(text);
|
||||
Expression exp = Expression::Parse(text);
|
||||
return isAcceptableExpression(exp);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ bool TextFieldDelegateApp::ExpressionCanBeSerialized(const Expression expression
|
||||
return false;
|
||||
}
|
||||
if (replaceAns) {
|
||||
exp = Expression::parse(buffer);
|
||||
exp = Expression::Parse(buffer);
|
||||
if (exp.isUninitialized()) {
|
||||
// The ans replacement made the expression unparsable
|
||||
return false;
|
||||
|
||||
@@ -22,7 +22,7 @@ EquationModelsParameterController::EquationModelsParameterController(Responder *
|
||||
m_selectableTableView.setMargins(0);
|
||||
m_selectableTableView.setShowsIndicators(false);
|
||||
for (int i = 0; i < k_numberOfExpressionCells; i++) {
|
||||
Poincare::Expression e = Expression::parse(k_models[i+1]);
|
||||
Poincare::Expression e = Expression::Parse(k_models[i+1]);
|
||||
m_layouts[i] = e.createLayout(Poincare::Preferences::PrintFloatMode::Decimal, Constant::ShortNumberOfSignificantDigits);
|
||||
m_modelCells[i].setLayout(m_layouts[i]);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ bool LayoutField::handleEventWithText(const char * text, bool indentation, bool
|
||||
} else if ((strcmp(text, "[") == 0) || (strcmp(text, "]") == 0)) {
|
||||
m_contentView.cursor()->addEmptyMatrixLayout();
|
||||
} else {
|
||||
Expression resultExpression = Expression::parse(text);
|
||||
Expression resultExpression = Expression::Parse(text);
|
||||
if (resultExpression.isUninitialized()) {
|
||||
KDSize previousLayoutSize = minimalSizeForOptimalDisplay();
|
||||
m_contentView.cursor()->insertText(text);
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
/* Constructor & Destructor */
|
||||
Expression() : TreeHandle() {}
|
||||
Expression clone() const;
|
||||
static Expression parse(char const * string);
|
||||
static Expression Parse(char const * string);
|
||||
static Expression ExpressionFromAddress(const void * address, size_t size);
|
||||
|
||||
/* Circuit breaker */
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Poincare {
|
||||
|
||||
Expression Expression::clone() const { TreeHandle c = TreeHandle::clone(); return static_cast<Expression&>(c); }
|
||||
|
||||
Expression Expression::parse(char const * string) {
|
||||
Expression Expression::Parse(char const * string) {
|
||||
if (string[0] == 0) {
|
||||
return Expression();
|
||||
}
|
||||
@@ -307,7 +307,7 @@ int Expression::serialize(char * buffer, int bufferSize, Preferences::PrintFloat
|
||||
/* Simplification */
|
||||
|
||||
Expression Expression::ParseAndSimplify(const char * text, Context & context, Preferences::AngleUnit angleUnit, bool replaceSymbols) {
|
||||
Expression exp = parse(text);
|
||||
Expression exp = Parse(text);
|
||||
if (exp.isUninitialized()) {
|
||||
return Undefined();
|
||||
}
|
||||
@@ -315,7 +315,7 @@ Expression Expression::ParseAndSimplify(const char * text, Context & context, Pr
|
||||
/* simplify might have been interrupted, in which case the resulting
|
||||
* expression is uninitialized, so we need to check that. */
|
||||
if (exp.isUninitialized()) {
|
||||
return parse(text);
|
||||
return Parse(text);
|
||||
}
|
||||
return exp;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ int Layout::serializeParsedExpression(char * buffer, int bufferSize) const {
|
||||
return 0;
|
||||
}
|
||||
serializeForParsing(buffer, bufferSize);
|
||||
Poincare::Expression e = Poincare::Expression::parse(buffer);
|
||||
Poincare::Expression e = Poincare::Expression::Parse(buffer);
|
||||
if (e.isUninitialized()) {
|
||||
buffer[0] = 0;
|
||||
return 0;
|
||||
|
||||
@@ -302,14 +302,14 @@ Expression Trigonometry::table(const Expression e, ExpressionNode::Type type, Co
|
||||
return Expression();
|
||||
}
|
||||
for (int i = 0; i < k_numberOfEntries; i++) {
|
||||
Expression input = Expression::parse(cheatTable[i][inputIndex]);
|
||||
Expression input = Expression::Parse(cheatTable[i][inputIndex]);
|
||||
if (input.isUninitialized()) {
|
||||
continue;
|
||||
}
|
||||
input = input.deepReduce(context, angleUnit);
|
||||
bool rightInput = input.isIdenticalTo(e);
|
||||
if (rightInput) {
|
||||
Expression output = Expression::parse(cheatTable[i][outputIndex]);
|
||||
Expression output = Expression::Parse(cheatTable[i][outputIndex]);
|
||||
if (output.isUninitialized()) {
|
||||
return Expression();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ static inline void assert_approximation_equals(const Expression i, float f) {
|
||||
}
|
||||
|
||||
static inline void assert_parsed_expression_is_equal_to(const char * exp, Expression e) {
|
||||
Expression result = Expression::parse(exp);
|
||||
Expression result = Expression::Parse(exp);
|
||||
quiz_assert(!result.isUninitialized());
|
||||
quiz_assert(result.isIdenticalTo(e));
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ Expression parse_expression(const char * expression, bool canBeUnparsable) {
|
||||
char buffer[500];
|
||||
strlcpy(buffer, expression, sizeof(buffer));
|
||||
translate_in_special_chars(buffer);
|
||||
Expression result = Expression::parse(buffer);
|
||||
Expression result = Expression::Parse(buffer);
|
||||
if (!canBeUnparsable) {
|
||||
quiz_assert(!result.isUninitialized());
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ QUIZ_CASE(poincare_parser_memory_exhaustion) {
|
||||
if (ExceptionRun(ecp)) {
|
||||
Addition a = Addition();
|
||||
while (true) {
|
||||
Expression e = Expression::parse("1+2+3+4+5+6+7+8+9+10");
|
||||
Expression e = Expression::Parse("1+2+3+4+5+6+7+8+9+10");
|
||||
a.addChildAtIndexInPlace(e, 0, a.numberOfChildren());
|
||||
}
|
||||
} else {
|
||||
@@ -117,7 +117,7 @@ QUIZ_CASE(poincare_parser_memory_exhaustion) {
|
||||
|
||||
quiz_assert(memoryFailureHasBeenHandled);
|
||||
assert_pool_size(initialPoolSize);
|
||||
Expression e = Expression::parse("1+1");
|
||||
Expression e = Expression::Parse("1+1");
|
||||
/* Stupid check to make sure the global variable generated by Bison is not
|
||||
* ruining everything */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user