Parse and bind strings
This commit is contained in:
@@ -40,6 +40,8 @@ BoundExpression* Binder::BindExpression(ParsedExpression* expression){
|
||||
return new BoundLiteralIntegerExpression(((LiteralIntegerExpression*)expression)->GetValue(), expression->GetStartPosition(), expression->GetLength());
|
||||
case ParsedExpressionKind ::LiteralFloat:
|
||||
return new BoundLiteralFloatExpression(((LiteralFloatExpression*)expression)->GetValue(), expression->GetStartPosition(), expression->GetLength());
|
||||
case ParsedExpressionKind ::LiteralString:
|
||||
return new BoundLiteralStringExpression(((LiteralStringExpression*)expression)->GetValue(), expression->GetStartPosition(), expression->GetLength());
|
||||
case ParsedExpressionKind ::LiteralBool:
|
||||
return new BoundLiteralBoolExpression(((LiteralBoolExpression*)expression)->GetValue(), expression->GetStartPosition(), expression->GetLength());
|
||||
|
||||
|
||||
@@ -83,6 +83,21 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class LiteralStringExpression : public ParsedExpression{
|
||||
string _value;
|
||||
public:
|
||||
ParsedExpressionKind GetKind() final{
|
||||
return ParsedExpressionKind::LiteralString;
|
||||
}
|
||||
explicit LiteralStringExpression(StringToken* token) : ParsedExpression(token -> GetStartPosition(), token -> GetLength()){
|
||||
_value = std::move(token->Value);
|
||||
}
|
||||
|
||||
string GetValue(){
|
||||
return _value;
|
||||
}
|
||||
};
|
||||
|
||||
class LiteralBoolExpression : public ParsedExpression{
|
||||
bool _value;
|
||||
public:
|
||||
|
||||
@@ -108,6 +108,7 @@ ParsedExpression *Parser::ParsePrimaryExpression(IToken *current) {
|
||||
switch (current -> GetKind()){
|
||||
case TokenKind ::Integer: return new LiteralIntegerExpression((IntegerToken*)current);
|
||||
case TokenKind ::Float: return new LiteralFloatExpression((FloatToken*)current);
|
||||
case TokenKind ::String: return new LiteralStringExpression((StringToken*)current);
|
||||
case TokenKind ::TrueKeyword: return new LiteralBoolExpression(current);
|
||||
case TokenKind ::FalseKeyword: return new LiteralBoolExpression(current);
|
||||
case TokenKind ::OpenParenthesis: return this -> ParseParenthesizedExpression(current);
|
||||
|
||||
Reference in New Issue
Block a user