mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
[poincare/parser] Rename Store with RightwardsArrow
This commit is contained in:
@@ -60,7 +60,7 @@ Expression Parser::parseUntil(Token::Type stoppingType) {
|
||||
typedef void (Parser::*TokenParser)(Expression & leftHandSide, Token::Type stoppingType);
|
||||
static constexpr TokenParser tokenParsers[] = {
|
||||
&Parser::parseUnexpected, // Token::EndOfStream
|
||||
&Parser::parseStoreOrUnitConvert, // Token::Store
|
||||
&Parser::parseRightwardsArrow, // Token::RightwardsArrow
|
||||
&Parser::parseEqual, // Token::Equal
|
||||
&Parser::parseUnexpected, // Token::RightSystemParenthesis
|
||||
&Parser::parseUnexpected, // Token::RightBracket
|
||||
@@ -266,7 +266,7 @@ void Parser::parseEqual(Expression & leftHandSide, Token::Type stoppingType) {
|
||||
Expression rightHandSide;
|
||||
if (parseBinaryOperator(leftHandSide, rightHandSide, Token::Equal)) {
|
||||
/* We parse until finding a token of lesser precedence than Equal. The next
|
||||
* token is thus either EndOfStream or Store. */
|
||||
* token is thus either EndOfStream or RightwardsArrow. */
|
||||
leftHandSide = Equal::Builder(leftHandSide, rightHandSide);
|
||||
}
|
||||
if (!m_nextToken.is(Token::EndOfStream)) {
|
||||
@@ -275,12 +275,12 @@ void Parser::parseEqual(Expression & leftHandSide, Token::Type stoppingType) {
|
||||
}
|
||||
}
|
||||
|
||||
void Parser::parseStoreOrUnitConvert(Expression & leftHandSide, Token::Type stoppingType) {
|
||||
void Parser::parseRightwardsArrow(Expression & leftHandSide, Token::Type stoppingType) {
|
||||
if (leftHandSide.isUninitialized()) {
|
||||
m_status = Status::Error; // Left-hand side missing.
|
||||
return;
|
||||
}
|
||||
// At this point, m_currentToken is Token::Store.
|
||||
// At this point, m_currentToken is Token::RightwardsArrow.
|
||||
bool parseId = m_nextToken.is(Token::Identifier) && !IsReservedName(m_nextToken.text(), m_nextToken.length());
|
||||
if (parseId) {
|
||||
popToken();
|
||||
@@ -307,7 +307,7 @@ void Parser::parseStoreOrUnitConvert(Expression & leftHandSide, Token::Type stop
|
||||
return;
|
||||
}
|
||||
if (!m_nextToken.is(Token::EndOfStream) || !rightHandSide.isUnitsOnly(m_context)) {
|
||||
m_status = Status::Error; // Store expects a single symbol or function or a unit.
|
||||
m_status = Status::Error; // UnitConvert expects "units only" on the right.
|
||||
return;
|
||||
}
|
||||
leftHandSide = UnitConvert::Builder(leftHandSide, rightHandSide);
|
||||
|
||||
@@ -64,7 +64,7 @@ private:
|
||||
void parseCaret(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parseCaretWithParenthesis(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parseEqual(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parseStoreOrUnitConvert(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parseRightwardsArrow(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
void parseLeftSuperscript(Expression & leftHandSide, Token::Type stoppingType = (Token::Type)0);
|
||||
|
||||
// Parsing helpers
|
||||
|
||||
@@ -17,13 +17,13 @@ public:
|
||||
enum Type {
|
||||
// Ordered from lower to higher precedence to make Parser's job easier
|
||||
EndOfStream = 0, // Must be the first
|
||||
Store,
|
||||
RightwardsArrow,
|
||||
Equal,
|
||||
/* Equal should have a higher precedence than Store, because
|
||||
/* Equal should have a higher precedence than RightArrow, because
|
||||
* Tokenizer::parseEqual looks for a right hand side until it finds a
|
||||
* token of lesser precedence than Equal, and this prevents expressions
|
||||
* such as "3=4>a". Tokenizer::parseStore uses a special algorithm that
|
||||
* prevents (3>4=a). */
|
||||
* token of lesser precedence than EqualSymbolAbstract, and this prevents
|
||||
* expressions such as "3=4>a". Tokenizer::parseRightArrow uses a special
|
||||
* algorithm that prevents (3>4=a). */
|
||||
RightSystemParenthesis,
|
||||
RightBracket,
|
||||
RightParenthesis,
|
||||
|
||||
@@ -233,7 +233,7 @@ Token Tokenizer::popToken() {
|
||||
return Token(Token::Empty);
|
||||
}
|
||||
if (c == UCodePointRightwardsArrow) {
|
||||
return Token(Token::Store);
|
||||
return Token(Token::RightwardsArrow);
|
||||
}
|
||||
if (c == 0) {
|
||||
return Token(Token::EndOfStream);
|
||||
|
||||
Reference in New Issue
Block a user