Added basics for lexing index expressions
This commit is contained in:
parent
7f79c4d8bb
commit
b275e1fbd6
|
@ -65,8 +65,14 @@ IToken* Lexer::LexNext(char c){
|
||||||
return new SimpleToken(TokenKind::OpenParenthesis, this -> _position - 1, 1);
|
return new SimpleToken(TokenKind::OpenParenthesis, this -> _position - 1, 1);
|
||||||
case ')':
|
case ')':
|
||||||
return new SimpleToken(TokenKind::CloseParenthesis, this -> _position - 1, 1);
|
return new SimpleToken(TokenKind::CloseParenthesis, this -> _position - 1, 1);
|
||||||
|
case '[':
|
||||||
|
return new SimpleToken(TokenKind::OpenSquareBracket, this -> _position - 1, 1);
|
||||||
|
case ']':
|
||||||
|
return new SimpleToken(TokenKind::CloseSquareBracket, this -> _position - 1, 1);
|
||||||
case ',':
|
case ',':
|
||||||
return new SimpleToken(TokenKind::CommaToken, this -> _position - 1, 1);
|
return new SimpleToken(TokenKind::CommaToken, this -> _position - 1, 1);
|
||||||
|
case '.':
|
||||||
|
return new SimpleToken(TokenKind::PeriodToken, this -> _position - 1, 1);
|
||||||
case '=':
|
case '=':
|
||||||
if (Lexer::Peek() == '='){
|
if (Lexer::Peek() == '='){
|
||||||
Lexer::Next();
|
Lexer::Next();
|
||||||
|
|
|
@ -139,9 +139,17 @@ ParsedStatement *Parser::ParseFunctionDeclaration(IToken *current) {
|
||||||
|
|
||||||
ParsedExpression* Parser::ParseExpression(IToken* current){
|
ParsedExpression* Parser::ParseExpression(IToken* current){
|
||||||
auto expression = this -> ParseBinaryExpression(current, OperatorPrecedence::No);
|
auto expression = this -> ParseBinaryExpression(current, OperatorPrecedence::No);
|
||||||
while (this -> Peek() -> GetKind() == TokenKind::OpenParenthesis){
|
auto peekKind = this->Peek()->GetKind();
|
||||||
expression = this->ParseFunctionCallExpression(expression);
|
while (peekKind == TokenKind::OpenParenthesis ||
|
||||||
//TODO: Function Evaluation
|
peekKind == TokenKind::OpenSquareBracket ||
|
||||||
|
peekKind == TokenKind::PeriodToken){
|
||||||
|
if (peekKind == TokenKind::OpenParenthesis){
|
||||||
|
expression = this->ParseFunctionCallExpression(expression);
|
||||||
|
} else if (peekKind == TokenKind::OpenSquareBracket){
|
||||||
|
//TODO: index expression
|
||||||
|
} else {
|
||||||
|
//TODO: index period expression
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,10 @@ enum class TokenKind{
|
||||||
InequalityToken,
|
InequalityToken,
|
||||||
OpenParenthesis,
|
OpenParenthesis,
|
||||||
CloseParenthesis,
|
CloseParenthesis,
|
||||||
|
OpenSquareBracket,
|
||||||
|
CloseSquareBracket,
|
||||||
|
|
||||||
|
PeriodToken,
|
||||||
CommaToken,
|
CommaToken,
|
||||||
|
|
||||||
Identifier,
|
Identifier,
|
||||||
|
|
Loading…
Reference in New Issue