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);
|
||||
case ')':
|
||||
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 ',':
|
||||
return new SimpleToken(TokenKind::CommaToken, this -> _position - 1, 1);
|
||||
case '.':
|
||||
return new SimpleToken(TokenKind::PeriodToken, this -> _position - 1, 1);
|
||||
case '=':
|
||||
if (Lexer::Peek() == '='){
|
||||
Lexer::Next();
|
||||
|
|
|
@ -139,9 +139,17 @@ ParsedStatement *Parser::ParseFunctionDeclaration(IToken *current) {
|
|||
|
||||
ParsedExpression* Parser::ParseExpression(IToken* current){
|
||||
auto expression = this -> ParseBinaryExpression(current, OperatorPrecedence::No);
|
||||
while (this -> Peek() -> GetKind() == TokenKind::OpenParenthesis){
|
||||
expression = this->ParseFunctionCallExpression(expression);
|
||||
//TODO: Function Evaluation
|
||||
auto peekKind = this->Peek()->GetKind();
|
||||
while (peekKind == TokenKind::OpenParenthesis ||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,10 @@ enum class TokenKind{
|
|||
InequalityToken,
|
||||
OpenParenthesis,
|
||||
CloseParenthesis,
|
||||
OpenSquareBracket,
|
||||
CloseSquareBracket,
|
||||
|
||||
PeriodToken,
|
||||
CommaToken,
|
||||
|
||||
Identifier,
|
||||
|
|
Loading…
Reference in New Issue