Skip to content

Commit 7614f85

Browse files
rename contexts
1 parent 386d640 commit 7614f85

5 files changed

Lines changed: 33 additions & 8 deletions

File tree

Code/ContextSystem/Contexts/FunctionDefinitionContext.cs renamed to Code/ContextSystem/Contexts/FuncStatement.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace SER.Code.ContextSystem.Contexts;
1515

1616
[UsedImplicitly]
17-
public class FunctionDefinitionContext :
17+
public class FuncStatement :
1818
StatementContext,
1919
INotRunningContext,
2020
IAcceptOptionalVariableDefinitionsContext,

Code/ContextSystem/Contexts/GlobalVariableContext.cs renamed to Code/ContextSystem/Contexts/GlobalKeyword.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace SER.Code.ContextSystem.Contexts;
1313

1414
[UsedImplicitly]
15-
public class GlobalVariableContext : YieldingContext, IKeywordContext
15+
public class GlobalKeyword : YieldingContext, IKeywordContext
1616
{
1717
protected override string FriendlyName =>
1818
$"global{(_variableToken is null ? "" : $" '{_variableToken.RawRep}'")} variable definition";

Code/ContextSystem/Contexts/RunFunctionContext.cs renamed to Code/ContextSystem/Contexts/RunKeyword.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
namespace SER.Code.ContextSystem.Contexts;
1212

1313
[UsedImplicitly]
14-
public class RunFunctionContext : YieldingContext, IMayReturnValueContext
14+
public class RunKeyword : YieldingContext, IMayReturnValueContext
1515
{
16-
private FunctionDefinitionContext? _functionDefinitionContext;
16+
private FuncStatement? _functionDefinitionContext;
1717
private readonly List<IValueToken> _providedValues = [];
1818

1919
public TypeOfValue? Returns => _functionDefinitionContext?.Returns;

Code/ContextSystem/Contexts/WithContext.cs renamed to Code/ContextSystem/Contexts/WithKeyword.cs

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using SER.Code.ContextSystem.BaseContexts;
1+
using JetBrains.Annotations;
2+
using SER.Code.ContextSystem.BaseContexts;
23
using SER.Code.ContextSystem.Interfaces;
34
using SER.Code.ContextSystem.Structures;
45
using SER.Code.Helpers.ResultSystem;
@@ -7,7 +8,8 @@
78

89
namespace SER.Code.ContextSystem.Contexts;
910

10-
public class WithContext : StandardContext, IKeywordContext, INotRunningContext, IRequirePreviousStatementContext
11+
[UsedImplicitly]
12+
public class WithKeyword : StandardContext, IKeywordContext, INotRunningContext, IRequirePreviousStatementContext
1113
{
1214
private readonly List<VariableToken> _variables = [];
1315
private IAcceptOptionalVariableDefinitionsContext _receiver = null!;
@@ -18,7 +20,30 @@ public class WithContext : StandardContext, IKeywordContext, INotRunningContext,
1820
"This keyword is designed to provide a variable or a collection of variables to a statement.";
1921

2022
public string[] Arguments => ["[variables...]"];
21-
public string? Example => null;
23+
24+
public string Example =>
25+
"""
26+
# CORRECT
27+
over @all
28+
with @plr
29+
30+
Print {@plr name}
31+
end
32+
33+
# WRONG - "with" keyword does not add indentation
34+
over @all
35+
with @plr
36+
Print {@plr name}
37+
end
38+
39+
# WRONG - with keyword is not a statement that can be closed
40+
# this causes an error
41+
# over @all
42+
# with @plr
43+
# Print {@plr name}
44+
# end
45+
# end
46+
""";
2247

2348
public Result AcceptStatement(StatementContext context)
2449
{

Code/TokenSystem/Tokens/RunFunctionToken.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class RunFunctionToken : BaseToken, IContextableToken
99
{
1010
public Context GetContext(Script scr)
1111
{
12-
return new RunFunctionContext
12+
return new RunKeyword
1313
{
1414
LineNum = LineNum,
1515
Script = scr

0 commit comments

Comments
 (0)