Skip to content

Commit ebcd8a6

Browse files
committed
Add project files.
1 parent d89ed6b commit ebcd8a6

File tree

3 files changed

+166
-0
lines changed

3 files changed

+166
-0
lines changed

CBIASIPOSLESWRAOTTHNRTBTSS.SATLCD.sln

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31702.278
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CBIASIPOSLESWRAOTTHNRTBTSS.SATLCD", "CBIASIPOSLESWRAOTTHNRTBTSS.SATLCD\CBIASIPOSLESWRAOTTHNRTBTSS.SATLCD.csproj", "{A490E161-D331-4D70-92B1-680E9D6F6C24}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{A490E161-D331-4D70-92B1-680E9D6F6C24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A490E161-D331-4D70-92B1-680E9D6F6C24}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A490E161-D331-4D70-92B1-680E9D6F6C24}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A490E161-D331-4D70-92B1-680E9D6F6C24}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {2C1DD364-3848-4BE9-8DC1-473B35E030D0}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.IO;
5+
using System.Text;
6+
7+
namespace CBIASIPOSLESWRAOTTHNRTBTSS.SATLCD
8+
{
9+
class Program
10+
{
11+
static List<string> codeLines = new List<string>();
12+
static string filename = "code";
13+
14+
static Dictionary<string, int> vars = new Dictionary<string, int>();
15+
16+
static int codeLine = 1;
17+
static void Main(string[] args)
18+
{
19+
TextReader tr = new StreamReader(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + @"\" + @filename + ".coballs");
20+
21+
string line = tr.ReadLine();
22+
while (line != null)
23+
{
24+
codeLines.Add(line);
25+
line = tr.ReadLine();
26+
}
27+
28+
while (codeLine <= codeLines.Count)
29+
{
30+
string[] split = codeLines[codeLine - 1].Trim().Split(" ");
31+
string fullLine = codeLines[codeLine - 1].Trim();
32+
string lower = fullLine.ToLower();
33+
switch (split[0])
34+
{
35+
case "write":
36+
if (lower.Contains("write the string:")) {
37+
Console.Write(fullLine.Substring(fullLine.IndexOf(":")).Remove(0, 1));
38+
}
39+
if (lower.Contains("write the ascii character for the variable:"))
40+
{
41+
Console.Write(Encoding.ASCII.GetString(new byte[] { (byte) vars[fullLine.Substring(fullLine.IndexOf(":")).Remove(0, 1)] }));
42+
}
43+
break;
44+
case "set":
45+
if (lower.Contains("set the variable called ") && lower.Contains("to:"))
46+
{
47+
if (vars.ContainsKey(split[4]))
48+
{
49+
vars[split[4]] = int.Parse(fullLine.Substring(fullLine.IndexOf(":")).Remove(0, 1));
50+
} else
51+
{
52+
vars.Add(split[4], int.Parse(fullLine.Substring(fullLine.IndexOf(":")).Remove(0, 1)));
53+
}
54+
} else if (lower.Contains("set the value of ") && lower.Contains("to the value of:"))
55+
{
56+
if (vars.ContainsKey(split[4]))
57+
{
58+
vars[split[4]] = vars[fullLine.Substring(fullLine.IndexOf(":")).Remove(0, 1)];
59+
}
60+
else
61+
{
62+
vars.Add(split[4], vars[fullLine.Substring(fullLine.IndexOf(":")).Remove(0, 1)]);
63+
}
64+
}
65+
else if (lower.Contains("set the value of ") && lower.Contains("to the ascii value of a user input character"))
66+
{
67+
if (vars.ContainsKey(split[4]))
68+
{
69+
vars[split[4]] = (int) Console.ReadKey().KeyChar;
70+
}
71+
else
72+
{
73+
vars.Add(split[4], (int)Console.ReadKey().KeyChar);
74+
}
75+
Console.Write("\n");
76+
}
77+
else if (lower.Contains("set the title of the application to:"))
78+
{
79+
Console.Title = fullLine.Substring(fullLine.IndexOf(":")).Remove(0, 1);
80+
}
81+
break;
82+
case "preform":
83+
if (lower.Contains("preform operation ") && lower.Contains(" on ") && lower.Contains(" by:"))
84+
{
85+
string varname = split[4];
86+
string type = split[2];
87+
int by = int.Parse(fullLine.Substring(fullLine.IndexOf(":")).Remove(0, 1));
88+
if (type.Equals("+"))
89+
{
90+
vars[varname] += by;
91+
}
92+
if (type.Equals("-"))
93+
{
94+
vars[varname] -= by;
95+
}
96+
if (type.Equals("*"))
97+
{
98+
vars[varname] *= by;
99+
}
100+
if (type.Equals("/"))
101+
{
102+
vars[varname] /= by;
103+
}
104+
if (type.Equals("%"))
105+
{
106+
vars[varname] %= by;
107+
}
108+
}
109+
break;
110+
case "goto":
111+
if (lower.Contains("goto line of the number:"))
112+
{
113+
codeLine = int.Parse(fullLine.Substring(fullLine.IndexOf(":")).Remove(0, 1)) - 1;
114+
}
115+
break;
116+
case "if:":
117+
if (lower.Contains("if variable is not 0:"))
118+
{
119+
if (vars[fullLine.Substring(fullLine.IndexOf(":")).Remove(0, 1)] == 0)
120+
{
121+
codeLine += 5;
122+
}
123+
}
124+
break;
125+
126+
}
127+
codeLine += 1;
128+
}
129+
130+
Console.ReadLine();
131+
}
132+
}
133+
}

0 commit comments

Comments
 (0)