Skip to content

Commit c62e7c3

Browse files
committed
014
1 parent 200ffa0 commit c62e7c3

File tree

12 files changed

+281
-253
lines changed

12 files changed

+281
-253
lines changed

General/SymbolicGrid.cs

Lines changed: 80 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -5,84 +5,87 @@ namespace MTLib.General;
55
// 0 | § | ¡
66
// £ | ¥ | µ
77
// ¶ | ¢ | ¿
8+
89
/// <summary>
910
/// A grid of Symbols.
1011
/// </summary>
11-
public class SymbolicGrid<T> { // TODO: TEST
12-
private Int32 size;
13-
private T?[,] symbols;
14-
public Single Area => size * size;
15-
public Single Perimeter => 4 * size;
16-
/// <summary>
17-
/// Counts all non-null Symbols.
18-
/// </summary>
19-
public Int32 Count {
20-
get {
21-
Int32 n = 0;
22-
for (Int32 x = 0; x < size; x++) {
23-
for (Int32 y = 0; y < size; y++) {
24-
if (symbols[x, y] is not null)
25-
continue;
26-
n++;
27-
}
28-
}
29-
return n;
30-
}
31-
}
32-
public SymbolicGrid(Int32 size, T? fillWith) {
33-
this.size = size;
34-
this.symbols = new T[size, size];
35-
this.Clear(fillWith);
36-
}
37-
public SymbolicGrid(Int32 size) {
38-
this.size = size;
39-
this.symbols = new T[size, size];
40-
}
41-
/// <summary>
42-
///
43-
/// </summary>
44-
/// <returns></returns>
45-
public override string ToString() {
46-
StringBuilder res = new();
47-
for (Int32 x = 0; x < 3; x++) {
48-
for (Int32 y = 0; y < 3; y++) {
49-
if (x > 0)
50-
_ = res.Append(' ');
51-
_ = res.Append(this[x, y]);
52-
}
53-
if (x != 2) {
54-
_ = res.Append(" |");
55-
}
56-
}
57-
return res.ToString();
58-
}
59-
public T? this[Int32 x, Int32 y] {
60-
get => this.symbols[x, y];
61-
set => this.symbols[x, y] = value;
62-
}
63-
/// <summary>
64-
/// Clears the Symbolic grid of all symbols.
65-
/// </summary>
66-
public void Clear(T? clearWith) {
67-
for (Int32 x = 0; x < 3; x++) {
68-
for (Int32 y = 0; y < 3; y++) {
69-
this[x, y] = clearWith;
70-
}
71-
}
72-
}
73-
/// <summary>
74-
/// Determines if the <paramref name="symbol"/> is in this <see cref="SymbolicGrid"/>.
75-
/// </summary>
76-
/// <returns><c>true</c>, if the <paramref name="symbol"/> is contained.</returns>
77-
public Boolean Contains(T? symbol) {
78-
for (Int32 x = 0; x < 3; x++) {
79-
for (Int32 y = 0; y < 3; y++) {
80-
if (this[x, y]?.Equals(symbol) ?? false)
81-
return true;
82-
if (this[x, y] is null && (symbol is null))
83-
return true;
84-
}
85-
}
86-
return false;
87-
}
12+
public class SymbolicGrid<T> { // TODO: TEST ME
13+
private Int32 size;
14+
private T?[,] symbols;
15+
public Single Area => size * size;
16+
public Single Perimeter => 4 * size;
17+
/// <summary>
18+
/// Counts all non-null Symbols.
19+
/// </summary>
20+
public Int32 Count {
21+
get {
22+
Int32 n = 0;
23+
for (Int32 x = 0; x < size; x++) {
24+
for (Int32 y = 0; y < size; y++) {
25+
if (symbols[x, y] is not null) { continue; }
26+
n++;
27+
}
28+
}
29+
return n;
30+
}
31+
}
32+
33+
public SymbolicGrid(Int32 size, T? fillWith) {
34+
this.size = size;
35+
this.symbols = new T[size, size];
36+
this.Clear(fillWith);
37+
}
38+
39+
public SymbolicGrid(Int32 size) {
40+
this.size = size;
41+
this.symbols = new T[size, size];
42+
}
43+
44+
/// <summary>
45+
///
46+
/// </summary>
47+
/// <returns></returns>
48+
public override string ToString() {
49+
StringBuilder res = new();
50+
for (Int32 x = 0; x < 3; x++) {
51+
for (Int32 y = 0; y < 3; y++) {
52+
if (x > 0) { _ = res.Append(' '); }
53+
_ = res.Append(this[x, y]);
54+
}
55+
if (x != 2) {
56+
_ = res.Append(" |");
57+
}
58+
}
59+
return res.ToString();
60+
}
61+
62+
public T? this[Int32 x, Int32 y] {
63+
get => this.symbols[x, y];
64+
set => this.symbols[x, y] = value;
65+
}
66+
67+
/// <summary>
68+
/// Clears the Symbolic grid of all symbols.
69+
/// </summary>
70+
public void Clear(T? clearWith) {
71+
for (Int32 x = 0; x < 3; x++) {
72+
for (Int32 y = 0; y < 3; y++) {
73+
this[x, y] = clearWith;
74+
}
75+
}
76+
}
77+
78+
/// <summary>
79+
/// Determines if the <paramref name="symbol"/> is in this <see cref="SymbolicGrid"/>.
80+
/// </summary>
81+
/// <returns><c>true</c>, if the <paramref name="symbol"/> is contained.</returns>
82+
public Boolean Contains(T? symbol) {
83+
for (Int32 x = 0; x < 3; x++) {
84+
for (Int32 y = 0; y < 3; y++) {
85+
if (this[x, y]?.Equals(symbol) ?? false) { return true; }
86+
if (this[x, y] is null && (symbol is null)) { return true; }
87+
}
88+
}
89+
return false;
90+
}
8891
}

Generative/SyntacticGenerator.cs

Lines changed: 83 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -5,80 +5,87 @@ namespace MTLib.Generative;
55
/// Provides a high level interface for sequential syntax generation.
66
/// </summary>
77
public sealed class SyntacticGenerator {
8-
public SyntacticGenerator() { }
9-
public SyntacticGenerator(String languageName) {
10-
this.Language = languageName;
11-
}
12-
public enum TabType {
13-
MAINTAIN,
14-
INCREASE,
15-
DECREASE,
16-
}
17-
public String? Language;
18-
public Dictionary<Byte, String> Literals = [];
19-
public StringBuilder Result = new();
20-
public UInt16 TabCount;
21-
public String TabString {
22-
get {
23-
return new String('\t', TabCount);
24-
}
25-
}
26-
public SyntacticGenerator WriteLine(Byte literal, TabType tabType = TabType.MAINTAIN) {
27-
ArgumentNullException.ThrowIfNull(
28-
Literals[literal], nameof(literal));
29-
Result.Append(TabString + Literals[literal] + "\n");
30-
switch (tabType) {
31-
case TabType.MAINTAIN:
32-
break;
33-
case TabType.INCREASE:
34-
TabCount++;
35-
break;
36-
case TabType.DECREASE:
37-
TabCount--;
38-
break;
39-
}
40-
return this;
41-
}
42-
/// <summary>
43-
/// Writes the given <c>Literal</c> to the <see cref="StringBuilder"/>.
44-
/// </summary>
45-
/// <returns><c>this</c> instance, for consecutive calls.</returns>
46-
public SyntacticGenerator Write(Byte literal, Boolean putTab = false, TabType tabType = TabType.MAINTAIN) {
47-
ArgumentNullException.ThrowIfNull(
48-
Literals[literal], nameof(literal));
49-
Result.Append((putTab ? TabString : "") + Literals[literal]);
50-
switch (tabType) {
51-
case TabType.MAINTAIN:
52-
break;
53-
case TabType.INCREASE:
54-
TabCount++;
55-
break;
56-
case TabType.DECREASE:
57-
TabCount--;
58-
break;
59-
}
60-
return this;
61-
}
62-
/// <summary>
63-
/// Writes the given <see cref="String"/> to the <see cref="StringBuilder"/>.
64-
/// </summary>
65-
/// <returns><c>this</c> instance, for consecutive calls.</returns>
66-
public SyntacticGenerator Write(String data, Boolean putTab = false, TabType tabType = TabType.MAINTAIN) {
67-
Result.Append((putTab ? TabString : "") + data);
68-
switch (tabType) {
69-
case TabType.MAINTAIN:
70-
break;
71-
case TabType.INCREASE:
72-
TabCount++;
73-
break;
74-
case TabType.DECREASE:
75-
TabCount--;
76-
break;
77-
}
78-
return this;
79-
}
80-
/// <inheritdoc/>
81-
public override String ToString() {
82-
return Result.ToString();
83-
}
8+
public SyntacticGenerator() { }
9+
10+
public SyntacticGenerator(String languageName) {
11+
this.Language = languageName;
12+
}
13+
14+
public enum TabType {
15+
MAINTAIN,
16+
INCREASE,
17+
DECREASE,
18+
}
19+
20+
public String? Language;
21+
public Dictionary<Byte, String> Literals = [];
22+
public StringBuilder Result = new();
23+
public UInt16 TabCount;
24+
public String TabString {
25+
get {
26+
return new String('\t', TabCount);
27+
}
28+
}
29+
30+
public SyntacticGenerator WriteLine(Byte literal, TabType tabType = TabType.MAINTAIN) {
31+
ArgumentNullException.ThrowIfNull(
32+
Literals[literal], nameof(literal));
33+
Result.Append(TabString + Literals[literal] + "\n");
34+
switch (tabType) {
35+
case TabType.MAINTAIN:
36+
break;
37+
case TabType.INCREASE:
38+
TabCount++;
39+
break;
40+
case TabType.DECREASE:
41+
TabCount--;
42+
break;
43+
}
44+
return this;
45+
}
46+
47+
/// <summary>
48+
/// Writes the given <c>Literal</c> to the <see cref="StringBuilder"/>.
49+
/// </summary>
50+
/// <returns><c>this</c> instance, for consecutive calls.</returns>
51+
public SyntacticGenerator Write(Byte literal, Boolean putTab = false, TabType tabType = TabType.MAINTAIN) {
52+
ArgumentNullException.ThrowIfNull(
53+
Literals[literal], nameof(literal));
54+
Result.Append((putTab ? TabString : "") + Literals[literal]);
55+
switch (tabType) {
56+
case TabType.MAINTAIN:
57+
break;
58+
case TabType.INCREASE:
59+
TabCount++;
60+
break;
61+
case TabType.DECREASE:
62+
TabCount--;
63+
break;
64+
}
65+
return this;
66+
}
67+
68+
/// <summary>
69+
/// Writes the given <see cref="String"/> to the <see cref="StringBuilder"/>.
70+
/// </summary>
71+
/// <returns><c>this</c> instance, for consecutive calls.</returns>
72+
public SyntacticGenerator Write(String data, Boolean putTab = false, TabType tabType = TabType.MAINTAIN) {
73+
Result.Append((putTab ? TabString : "") + data);
74+
switch (tabType) {
75+
case TabType.MAINTAIN:
76+
break;
77+
case TabType.INCREASE:
78+
TabCount++;
79+
break;
80+
case TabType.DECREASE:
81+
TabCount--;
82+
break;
83+
}
84+
return this;
85+
}
86+
87+
/// <inheritdoc/>
88+
public override String ToString() {
89+
return Result.ToString();
90+
}
8491
}

MTLib.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -24,7 +24,6 @@
2424
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
2525
<AssemblyName>MTLibrary</AssemblyName>
2626
<RootNamespace>MTLib</RootNamespace>
27-
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
2827
<ApplicationIcon>icon.ico</ApplicationIcon>
2928
<PackageId>MTLib</PackageId>
3029
<PackageIcon>icon.png</PackageIcon>

MetaInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
namespace MTLib;
22
public static class MetaInfo {
3-
public static readonly String VersionString = "Kloe";
4-
public static readonly String VersionNumber = "0.1.3";
3+
public static readonly String VersionString = "Criminogenic";
4+
public static readonly String VersionNumber = "0.1.4";
55
}

Metaconstructs/Amplitudes.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace MTLib.Metaconstructs.Amplitudes;
22
public class Amplitude {
3-
public Amplitude(Flavor dynamic) {
3+
public Amplitude(Flavor dynamic) {
44

5-
}
5+
}
66
}

0 commit comments

Comments
 (0)