add: for & if & while support.
This commit is contained in:
20
CanonSharp.Pascal/SyntaxTree/ForNode.cs
Normal file
20
CanonSharp.Pascal/SyntaxTree/ForNode.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using CanonSharp.Pascal.Scanner;
|
||||
|
||||
namespace CanonSharp.Pascal.SyntaxTree;
|
||||
|
||||
public sealed class ForNode(
|
||||
LexicalToken identifier,
|
||||
SyntaxNodeBase leftCondition,
|
||||
SyntaxNodeBase rightCondition,
|
||||
SyntaxNodeBase statement) : SyntaxNodeBase
|
||||
{
|
||||
public override SyntaxNodeType NodeType => SyntaxNodeType.For;
|
||||
|
||||
public LexicalToken Identifier => identifier;
|
||||
|
||||
public SyntaxNodeBase LeftCondition => leftCondition;
|
||||
|
||||
public SyntaxNodeBase RightCondition => rightCondition;
|
||||
|
||||
public SyntaxNodeBase Statement => statement;
|
||||
}
|
26
CanonSharp.Pascal/SyntaxTree/IfNode.cs
Normal file
26
CanonSharp.Pascal/SyntaxTree/IfNode.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace CanonSharp.Pascal.SyntaxTree;
|
||||
|
||||
public sealed class IfNode : SyntaxNodeBase
|
||||
{
|
||||
public override SyntaxNodeType NodeType => SyntaxNodeType.If;
|
||||
|
||||
public SyntaxNodeBase Condition { get; }
|
||||
|
||||
public SyntaxNodeBase Statement { get; }
|
||||
|
||||
public SyntaxNodeBase? ElseStatement { get; }
|
||||
|
||||
public IfNode(SyntaxNodeBase condition, SyntaxNodeBase statement)
|
||||
{
|
||||
Condition = condition;
|
||||
Statement = statement;
|
||||
ElseStatement = null;
|
||||
}
|
||||
|
||||
public IfNode(SyntaxNodeBase condition, SyntaxNodeBase statement, SyntaxNodeBase elseStatement)
|
||||
{
|
||||
Condition = condition;
|
||||
Statement = statement;
|
||||
ElseStatement = elseStatement;
|
||||
}
|
||||
}
|
@@ -14,6 +14,9 @@ public enum SyntaxNodeType
|
||||
Block,
|
||||
Constant,
|
||||
VariableDeclaration,
|
||||
If,
|
||||
While,
|
||||
For,
|
||||
ProgramBody,
|
||||
ProgramHead,
|
||||
Program
|
||||
|
10
CanonSharp.Pascal/SyntaxTree/WhileNode.cs
Normal file
10
CanonSharp.Pascal/SyntaxTree/WhileNode.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace CanonSharp.Pascal.SyntaxTree;
|
||||
|
||||
public sealed class WhileNode(SyntaxNodeBase condition, SyntaxNodeBase statement) : SyntaxNodeBase
|
||||
{
|
||||
public override SyntaxNodeType NodeType => SyntaxNodeType.While;
|
||||
|
||||
public SyntaxNodeBase Condition => condition;
|
||||
|
||||
public SyntaxNodeBase Statement => statement;
|
||||
}
|
Reference in New Issue
Block a user