...
This commit is contained in:
@@ -70,6 +70,16 @@ public sealed class Parser(List<Token> tokens)
|
||||
return new NodeStatementReturn(TokensFrom(startIndex), value);
|
||||
}
|
||||
|
||||
if (TryExpectKeyword(Keyword.Let))
|
||||
{
|
||||
var name = ExpectIdent();
|
||||
ExpectSymbol(Symbol.Colon);
|
||||
var type = ParseType();
|
||||
ExpectSymbol(Symbol.Equal);
|
||||
var value = ParseExpression();
|
||||
return new NodeStatementVariableDeclaration(TokensFrom(startIndex), name, type, value);
|
||||
}
|
||||
|
||||
var expression = ParseExpression();
|
||||
var parameters = new List<NodeExpression>();
|
||||
|
||||
@@ -324,6 +334,13 @@ internal class NodeStatementReturn(List<Token> tokens, NodeExpression value) : N
|
||||
public readonly NodeExpression Value = value;
|
||||
}
|
||||
|
||||
internal class NodeStatementVariableDeclaration(List<Token> tokens, TokenIdent name, NodeType type, NodeExpression value) : NodeStatement(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly NodeType Type = type;
|
||||
public readonly NodeExpression Value = value;
|
||||
}
|
||||
|
||||
public abstract class NodeExpression(List<Token> tokens) : Node(tokens);
|
||||
|
||||
public sealed class NodeExpressionIntLiteral(List<Token> tokens, TokenIntLiteral value) : NodeExpression(tokens)
|
||||
|
||||
Reference in New Issue
Block a user