mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[Poincare/parser] support ' as derivative
This commit is contained in:
@@ -68,7 +68,8 @@ Expression Parser::parseUntil(Token::Type stoppingType) {
|
||||
&Parser::parseTimes, // Token::Times
|
||||
&Parser::parseSlash, // Token::Slash
|
||||
&Parser::parseImplicitTimes, // Token::ImplicitTimes
|
||||
&Parser::parseCaret, // Token::Power
|
||||
&Parser::parseCaret, // Token::Power,
|
||||
&Parser::parseSingleQuote, // Token::SingleQuote
|
||||
&Parser::parseBang, // Token::Bang
|
||||
&Parser::parseCaretWithParenthesis, // Token::CaretWithParenthesis
|
||||
&Parser::parseMatrix, // Token::LeftBracket
|
||||
@@ -330,6 +331,15 @@ void Parser::parseLeftSystemParenthesis(Expression & leftHandSide, Token::Type s
|
||||
defaultParseLeftParenthesis(true, leftHandSide, stoppingType);
|
||||
}
|
||||
|
||||
void Parser::parseSingleQuote(Expression & leftHandSide, Token::Type stoppingType) {
|
||||
if (leftHandSide.isUninitialized()) {
|
||||
m_status = Status::Error; // Left-hand side missing
|
||||
} else {
|
||||
leftHandSide = Derivative::Builder(leftHandSide, Symbol::Builder('x'), Symbol::Builder('x'));
|
||||
}
|
||||
isThereImplicitMultiplication();
|
||||
}
|
||||
|
||||
void Parser::parseBang(Expression & leftHandSide, Token::Type stoppingType) {
|
||||
if (leftHandSide.isUninitialized()) {
|
||||
m_status = Status::Error; // Left-hand side missing
|
||||
|
||||
@@ -56,6 +56,7 @@ private:
|
||||
void parseMatrix(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parseLeftParenthesis(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parseLeftSystemParenthesis(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parseSingleQuote(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parseBang(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parsePlus(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parseMinus(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
* the ImplicitTimes Token Type is defined here with the desired precedence,
|
||||
* in order to allow the Parser to insert such Tokens where needed. */
|
||||
Caret,
|
||||
SingleQuote,
|
||||
Bang,
|
||||
CaretWithParenthesis,
|
||||
LeftBracket,
|
||||
|
||||
@@ -206,6 +206,9 @@ Token Tokenizer::popToken() {
|
||||
}
|
||||
return Token(Token::Caret);
|
||||
}
|
||||
if (c == '\'') {
|
||||
return Token(Token::SingleQuote);
|
||||
}
|
||||
if (c == '!') {
|
||||
return Token(Token::Bang);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user