Skip to content

Commit

Permalink
add ast structure for foreach statement #60
Browse files Browse the repository at this point in the history
  • Loading branch information
0xF6 committed Jun 26, 2021
1 parent d5cf246 commit 9892b58
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/ast/syntax/ast/ForeachStatementSyntax.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace mana.syntax
{
using System.Collections.Generic;
using Sprache;

public class ForeachStatementSyntax : StatementSyntax, IPositionAware<ForeachStatementSyntax>
{
public LocalVariableDeclaration Variable { get; }
public ExpressionSyntax Expression { get; }
public StatementSyntax Statement { get; }


public override SyntaxType Kind => SyntaxType.ForEachStatement;

public override IEnumerable<BaseSyntax> ChildNodes => new List<BaseSyntax> { Variable, Expression, Statement };

public ForeachStatementSyntax(LocalVariableDeclaration declaration, ExpressionSyntax exp, StatementSyntax statement)
{
Variable = declaration;
Expression = exp;
Statement = statement;
}

public new ForeachStatementSyntax SetPos(Position startPos, int length)
{
base.SetPos(startPos, length);
return this;
}
}
}

0 comments on commit 9892b58

Please sign in to comment.