...
This commit is contained in:
@@ -92,6 +92,13 @@ public sealed class Parser(List<Token> tokens)
|
||||
return new NodeStatementIf(TokensFrom(startIndex), condition, thenBlock, elseBlock);
|
||||
}
|
||||
|
||||
if (TryExpectKeyword(Keyword.While))
|
||||
{
|
||||
var condition = ParseExpression();
|
||||
var thenBlock = ParseStatement();
|
||||
return new NodeStatementWhile(TokensFrom(startIndex), condition, thenBlock);
|
||||
}
|
||||
|
||||
var target = ParseExpression();
|
||||
|
||||
if (TryExpectSymbol(Symbol.OpenParen))
|
||||
@@ -377,6 +384,12 @@ internal class NodeStatementIf(List<Token> tokens, NodeExpression condition, Nod
|
||||
public readonly NodeStatement? ElseBlock = elseBlock;
|
||||
}
|
||||
|
||||
internal class NodeStatementWhile(List<Token> tokens, NodeExpression condition, NodeStatement block) : NodeStatement(tokens)
|
||||
{
|
||||
public readonly NodeExpression Condition = condition;
|
||||
public readonly NodeStatement Block = block;
|
||||
}
|
||||
|
||||
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