BadScript 2
Loading...
Searching...
No Matches
BadEmptyIfBranchValidator.cs
Go to the documentation of this file.
3
5
9public class BadEmptyIfBranchValidator : BadExpressionValidator<BadIfExpression>
10{
12 protected override void Validate(BadExpressionValidatorContext context, BadIfExpression expr)
13 {
14 foreach (KeyValuePair<BadExpression, BadExpression[]> branch in expr.ConditionalBranches)
15 {
16 if (branch.Value.Length == 0)
17 {
18 context.AddError(
19 "If branch has no expressions",
20 expr,
21 branch.Key,
22 this
23 );
24 }
25 }
26
27 if (expr.ElseBranch == null)
28 {
29 return;
30 }
31
32 if (!expr.ElseBranch.Any())
33 {
34 context.AddError(
35 "Else statement has no expressions",
36 expr,
37 expr,
38 this
39 );
40 }
41 }
42}
Base Implementation for all Expressions used inside the Script.
Implements the If Statement Expression.
Checks if there are any expressions in the if branches block.
override void Validate(BadExpressionValidatorContext context, BadIfExpression expr)
Contains the Block Expressions for the BadScript2 Language.
Contains the Expressions for the BadScript2 Language.
Contains the Expression Validators for the BadScript2 Language.