Skip to content

Commit 9ebaf7e

Browse files
committed
refresh!
1 parent c62e7c3 commit 9ebaf7e

File tree

9 files changed

+320
-260
lines changed

9 files changed

+320
-260
lines changed

General/SymbolicGrid.cs

Lines changed: 69 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,82 +10,79 @@ namespace MTLib.General;
1010
/// A grid of Symbols.
1111
/// </summary>
1212
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-
}
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+
}
3232

33-
public SymbolicGrid(Int32 size, T? fillWith) {
34-
this.size = size;
35-
this.symbols = new T[size, size];
36-
this.Clear(fillWith);
37-
}
33+
public SymbolicGrid(Int32 size, T? fillWith) {
34+
this.size = size;
35+
this.symbols = new T[size][];
36+
this.Clear(fillWith);
37+
}
3838

39-
public SymbolicGrid(Int32 size) {
40-
this.size = size;
41-
this.symbols = new T[size, size];
42-
}
39+
public SymbolicGrid(Int32 size) {
40+
this.size = size;
41+
this.symbols = new T[size][];
42+
}
4343

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-
}
44+
/// <inheritdoc/>
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) { _ = res.Append(' '); }
50+
_ = res.Append(this[x, y]);
51+
}
52+
if (x != 2) {
53+
_ = res.Append(" |");
54+
}
55+
}
56+
return res.ToString();
57+
}
6158

62-
public T? this[Int32 x, Int32 y] {
63-
get => this.symbols[x, y];
64-
set => this.symbols[x, y] = value;
65-
}
59+
public T? this[Int32 x, Int32 y] {
60+
get => this.symbols[x][y];
61+
set => this.symbols[x][y] = value;
62+
}
6663

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-
}
64+
/// <summary>
65+
/// Clears the Symbolic grid of all symbols.
66+
/// </summary>
67+
public void Clear(T? clearWith) {
68+
for (Int32 x = 0; x < 3; x++) {
69+
for (Int32 y = 0; y < 3; y++) {
70+
this[x, y] = clearWith;
71+
}
72+
}
73+
}
7774

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-
}
75+
/// <summary>
76+
/// Determines if the <paramref name="symbol"/> is in <c>this</c>.
77+
/// </summary>
78+
/// <returns><c>true</c>, if the <paramref name="symbol"/> is contained.</returns>
79+
public Boolean Contains(T? symbol) {
80+
for (Int32 x = 0; x < 3; x++) {
81+
for (Int32 y = 0; y < 3; y++) {
82+
if (this[x, y]?.Equals(symbol) ?? false) { return true; }
83+
if (this[x, y] is null && (symbol is null)) { return true; }
84+
}
85+
}
86+
return false;
87+
}
9188
}

Generative/SyntacticGenerator.cs

Lines changed: 104 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -5,87 +5,115 @@ namespace MTLib.Generative;
55
/// Provides a high level interface for sequential syntax generation.
66
/// </summary>
77
public sealed class SyntacticGenerator {
8-
public SyntacticGenerator() { }
8+
public SyntacticGenerator() { }
99

10-
public SyntacticGenerator(String languageName) {
11-
this.Language = languageName;
12-
}
10+
public SyntacticGenerator(String languageName) {
11+
this.Language = languageName;
12+
}
1313

14-
public enum TabType {
15-
MAINTAIN,
16-
INCREASE,
17-
DECREASE,
18-
}
14+
public enum TabType {
15+
MAINTAIN,
16+
INCREASE,
17+
DECREASE,
18+
}
1919

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-
}
20+
private String? language;
21+
public String? Language {
22+
get { return language; }
23+
set { language = value; }
24+
}
25+
private Dictionary<Byte, String> literals = [];
26+
public Dictionary<Byte, String> Literals {
27+
get { return literals; }
28+
}
2929

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-
}
30+
private StringBuilder result = new();
31+
public StringBuilder Result {
32+
get { return result; }
33+
set { result = value; }
34+
}
4635

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-
}
36+
private UInt16 tabCount;
37+
public UInt16 TabCount {
38+
get { return tabCount; }
39+
set { tabCount = value; }
40+
}
41+
public String TabString {
42+
get {
43+
return new String('\t', TabCount);
44+
}
45+
}
6746

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-
}
47+
public SyntacticGenerator WriteLine(
48+
Byte literal,
49+
TabType tabType = TabType.MAINTAIN
50+
) {
51+
ArgumentNullException.ThrowIfNull(
52+
Literals[literal], nameof(literal));
53+
Result.Append(TabString + Literals[literal] + "\n");
54+
switch (tabType) {
55+
case TabType.MAINTAIN:
56+
break;
57+
case TabType.INCREASE:
58+
TabCount++;
59+
break;
60+
case TabType.DECREASE:
61+
TabCount--;
62+
break;
63+
}
64+
return this;
65+
}
8666

87-
/// <inheritdoc/>
88-
public override String ToString() {
89-
return Result.ToString();
90-
}
67+
/// <summary>
68+
/// Writes the given <c>Literal</c> to the <see cref="StringBuilder"/>.
69+
/// </summary>
70+
/// <returns><c>this</c> instance, for consecutive calls.</returns>
71+
public SyntacticGenerator Write(
72+
Byte literal,
73+
Boolean putTab = false,
74+
TabType tabType = TabType.MAINTAIN
75+
) {
76+
ArgumentNullException.ThrowIfNull(
77+
Literals[literal], nameof(literal));
78+
Result.Append((putTab ? TabString : "") + Literals[literal]);
79+
switch (tabType) {
80+
case TabType.MAINTAIN:
81+
break;
82+
case TabType.INCREASE:
83+
TabCount++;
84+
break;
85+
case TabType.DECREASE:
86+
TabCount--;
87+
break;
88+
}
89+
return this;
90+
}
91+
92+
/// <summary>
93+
/// Writes the given <see cref="String"/> to the <see cref="StringBuilder"/>.
94+
/// </summary>
95+
/// <returns><c>this</c> instance, for consecutive calls.</returns>
96+
public SyntacticGenerator Write(
97+
String data,
98+
Boolean putTab = false,
99+
TabType tabType = TabType.MAINTAIN
100+
) {
101+
Result.Append((putTab ? TabString : "") + data);
102+
switch (tabType) {
103+
case TabType.MAINTAIN:
104+
break;
105+
case TabType.INCREASE:
106+
TabCount++;
107+
break;
108+
case TabType.DECREASE:
109+
TabCount--;
110+
break;
111+
}
112+
return this;
113+
}
114+
115+
/// <inheritdoc/>
116+
public override String ToString() {
117+
return Result.ToString();
118+
}
91119
}

MTLib.csproj

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<!--
99
ver. format: major.minor.build.revision
1010
-->
11-
<AssemblyVersion>0.1.0.0</AssemblyVersion>
12-
<Version>0.1.4.0</Version>
11+
<AssemblyVersion></AssemblyVersion>
12+
<Version>0.1.5.0</Version>
1313
<Authors>MTadder</Authors>
1414
<Company>MTLaboratory</Company>
1515
<Title>MTLibrary</Title>
@@ -20,7 +20,7 @@
2020
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
2121
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
2222
<IncludeSymbols>True</IncludeSymbols>
23-
<AnalysisLevel>latest-recommended</AnalysisLevel>
23+
<AnalysisLevel>latest-all</AnalysisLevel>
2424
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
2525
<AssemblyName>MTLibrary</AssemblyName>
2626
<RootNamespace>MTLib</RootNamespace>
@@ -33,10 +33,16 @@
3333

3434
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
3535
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
36+
<NoWarn>1701;1702;1591</NoWarn>
37+
<WarningLevel>9999</WarningLevel>
38+
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
3639
</PropertyGroup>
3740

3841
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
3942
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
43+
<NoWarn>1701;1702;1591</NoWarn>
44+
<WarningLevel>9999</WarningLevel>
45+
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
4046
</PropertyGroup>
4147

4248
<ItemGroup>

0 commit comments

Comments
 (0)