Skip to content

Commit b78d0b7

Browse files
committed
constants project
1 parent b906077 commit b78d0b7

File tree

15 files changed

+60
-22
lines changed

15 files changed

+60
-22
lines changed

ExtendedJavaScriptSubset.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HydraScript.Infrastructure.
100100
EndProject
101101
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HydraScript.Infrastructure.LexerRegexGenerator.UnitTests", "tests\HydraScript.Infrastructure.LexerRegexGenerator.UnitTests\HydraScript.Infrastructure.LexerRegexGenerator.UnitTests.csproj", "{829111AD-4A5C-4B3D-AC28-208309CE10D6}"
102102
EndProject
103+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HydraScript.Domain.Constants", "src\Domain\HydraScript.Domain.Constants\HydraScript.Domain.Constants.csproj", "{E3E558A3-1999-48F9-B53D-2E583C18F000}"
104+
EndProject
103105
Global
104106
GlobalSection(SolutionConfigurationPlatforms) = preSolution
105107
Debug|Any CPU = Debug|Any CPU
@@ -150,6 +152,10 @@ Global
150152
{829111AD-4A5C-4B3D-AC28-208309CE10D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
151153
{829111AD-4A5C-4B3D-AC28-208309CE10D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
152154
{829111AD-4A5C-4B3D-AC28-208309CE10D6}.Release|Any CPU.Build.0 = Release|Any CPU
155+
{E3E558A3-1999-48F9-B53D-2E583C18F000}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
156+
{E3E558A3-1999-48F9-B53D-2E583C18F000}.Debug|Any CPU.Build.0 = Debug|Any CPU
157+
{E3E558A3-1999-48F9-B53D-2E583C18F000}.Release|Any CPU.ActiveCfg = Release|Any CPU
158+
{E3E558A3-1999-48F9-B53D-2E583C18F000}.Release|Any CPU.Build.0 = Release|Any CPU
153159
EndGlobalSection
154160
GlobalSection(NestedProjects) = preSolution
155161
{54CBE5A7-3C3E-44ED-B877-7B08A818083B} = {86CF2A2F-4DFE-48E7-B062-EF824730916A}
@@ -169,5 +175,6 @@ Global
169175
{1CE98127-3027-4BD4-AAA3-63A589B09E73} = {3F131901-A9EC-451A-B7E9-726887CFE5FB}
170176
{74D1495B-12A4-4E1A-ABE0-93029ECDC5FE} = {B7DDF6C9-B67C-430A-948A-A380EF68DEF1}
171177
{829111AD-4A5C-4B3D-AC28-208309CE10D6} = {3F131901-A9EC-451A-B7E9-726887CFE5FB}
178+
{E3E558A3-1999-48F9-B53D-2E583C18F000} = {F0FC6D23-F932-4C11-8D0F-07894FC61511}
172179
EndGlobalSection
173180
EndGlobal

src/Application/HydraScript.Application.CodeGeneration/Visitors/InstructionProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using HydraScript.Domain.BackEnd.Impl.Instructions.WithAssignment;
55
using HydraScript.Domain.BackEnd.Impl.Instructions.WithJump;
66
using HydraScript.Domain.BackEnd.Impl.Values;
7+
using HydraScript.Domain.Constants;
78
using HydraScript.Domain.FrontEnd.Parser;
89
using HydraScript.Domain.FrontEnd.Parser.Impl.Ast.Nodes;
910
using HydraScript.Domain.FrontEnd.Parser.Impl.Ast.Nodes.Declarations.AfterTypesAreLoaded;
@@ -82,8 +83,8 @@ public AddressedInstructions Visit(InsideStatementJump visitable)
8283
{
8384
var jumpType = visitable.Keyword switch
8485
{
85-
InsideStatementJump.Break => InsideStatementJumpType.Break,
86-
InsideStatementJump.Continue => InsideStatementJumpType.Continue,
86+
InsideStatementJumpKeyword.Break => InsideStatementJumpType.Break,
87+
InsideStatementJumpKeyword.Continue => InsideStatementJumpType.Continue,
8788
_ => throw new ArgumentOutOfRangeException(
8889
nameof(visitable.Keyword), visitable.Keyword,
8990
"Unsupported keyword inside loop")

src/Application/HydraScript.Application.StaticAnalysis/Visitors/SemanticChecker.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using HydraScript.Application.StaticAnalysis.Exceptions;
2+
using HydraScript.Domain.Constants;
23
using HydraScript.Domain.FrontEnd.Parser;
34
using HydraScript.Domain.FrontEnd.Parser.Impl.Ast.Nodes;
45
using HydraScript.Domain.FrontEnd.Parser.Impl.Ast.Nodes.Declarations;
@@ -105,18 +106,18 @@ public Type Visit(InsideStatementJump visitable)
105106
{
106107
switch (visitable.Keyword)
107108
{
108-
case InsideStatementJump.Break:
109+
case InsideStatementJumpKeyword.Break:
109110
if (!(visitable.ChildOf<IfStatement>() || visitable.ChildOf<WhileStatement>()))
110111
throw new OutsideOfStatement(
111112
visitable.Segment,
112-
keyword: InsideStatementJump.Break,
113+
visitable.Keyword,
113114
statement: "if|while");
114115
break;
115-
case InsideStatementJump.Continue:
116+
case InsideStatementJumpKeyword.Continue:
116117
if (!visitable.ChildOf<WhileStatement>())
117118
throw new OutsideOfStatement(
118119
visitable.Segment,
119-
keyword: InsideStatementJump.Continue,
120+
visitable.Keyword,
120121
statement: "while");
121122
break;
122123
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace HydraScript.Domain.Constants;
2+
3+
public static class Eop
4+
{
5+
public const string Tag = "EOP";
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
</PropertyGroup>
6+
7+
</Project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace HydraScript.Domain.Constants;
2+
3+
public static class InsideStatementJumpKeyword
4+
{
5+
public const string Break = "break";
6+
7+
public const string Continue = "continue";
8+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace HydraScript.Domain.Constants;
2+
3+
internal class StringSyntaxAttribute(string syntax) : Attribute
4+
{
5+
public const string Json = nameof(Json);
6+
7+
public override string ToString() =>
8+
nameof(StringSyntaxAttribute) + "." + syntax;
9+
}

src/Domain/HydraScript.Domain.FrontEnd/Lexer/TokenTypesJson.cs renamed to src/Domain/HydraScript.Domain.Constants/TokenTypesJson.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using System.Diagnostics.CodeAnalysis;
2-
3-
namespace HydraScript.Domain.FrontEnd.Lexer;
1+
namespace HydraScript.Domain.Constants;
42

53
public static class TokenTypesJson
64
{

src/Domain/HydraScript.Domain.FrontEnd/HydraScript.Domain.FrontEnd.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
<PackageReference Include="Visitor.NET.AutoVisitableGen" PrivateAssets="all" />
66
</ItemGroup>
77

8+
<ItemGroup>
9+
<ProjectReference Include="..\HydraScript.Domain.Constants\HydraScript.Domain.Constants.csproj" />
10+
</ItemGroup>
11+
812
</Project>
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1+
using HydraScript.Domain.Constants;
2+
13
namespace HydraScript.Domain.FrontEnd.Lexer.TokenTypes;
24

3-
internal record EndOfProgramType() : TokenType(EopTag)
4-
{
5-
public const string EopTag = "EOP";
6-
}
5+
internal record EndOfProgramType() : TokenType(Eop.Tag);

0 commit comments

Comments
 (0)