Skip to content

Commit 78e3b55

Browse files
committed
all system functions are now documented
1 parent 67a92b4 commit 78e3b55

5 files changed

Lines changed: 42 additions & 21 deletions

File tree

7Sharp/7Sharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<OutputType>Exe</OutputType>
99
<RootNamespace>_7Sharp</RootNamespace>
1010
<AssemblyName>7Sharp</AssemblyName>
11-
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
1212
<FileAlignment>512</FileAlignment>
1313
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1414
<TargetFrameworkProfile />

7Sharp/App.config

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.1" />
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
55
</startup>
66
<runtime>
77
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
88
<dependentAssembly>
9-
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
10-
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1" />
9+
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
10+
<bindingRedirect oldVersion="0.0.0.0-4.0.1.1" newVersion="4.0.1.1"/>
1111
</dependentAssembly>
1212
<dependentAssembly>
13-
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
14-
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
13+
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
14+
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0"/>
1515
</dependentAssembly>
1616
<dependentAssembly>
17-
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
18-
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
17+
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
18+
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
1919
</dependentAssembly>
2020
<dependentAssembly>
21-
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
22-
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
21+
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
22+
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0"/>
2323
</dependentAssembly>
2424
</assemblyBinding>
2525
</runtime>

7Sharp/Intrerpreter/Sysfunctions.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace _7Sharp.Intrerpreter
77
{
88
internal class SysFunctions
99
{
10+
[ManualDocs("double", "{\"title\":\"double(o)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"double(<object>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Convert \"},{\"text\":\"o\",\"color\":\"Green\"},{\"text\":\" to a double (64-bit floating-point number)\"}]}]}")]
1011
public static double Double(object value)
1112
{
1213
try
@@ -27,6 +28,27 @@ public static double Double(object value)
2728
}
2829
}
2930

31+
[ManualDocs("int", "{\"title\":\"int(o)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"int(<object>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Convert \"},{\"text\":\"o\",\"color\":\"Green\"},{\"text\":\" to an int (32-bit integer)\"}]}]}")]
32+
public static int Int(object value)
33+
{
34+
try
35+
{
36+
return Convert.ToInt32(value);
37+
}
38+
catch (OverflowException)
39+
{
40+
throw new InterpreterException("int: Number is too big!");
41+
}
42+
catch (FormatException)
43+
{
44+
throw new InterpreterException("int: Invalid number!");
45+
}
46+
catch (Exception e)
47+
{
48+
throw new InterpreterException("int: Unkown error", e);
49+
}
50+
}
51+
3052
[ManualDocs("write", "{\"title\":\"write(value)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"Outputs \"},{\"text\":\"value\",\"color\":\"Green\"},{\"text\":\" to the console, followed by a newline.\"}]}]}")]
3153
public static void Write(object obj) => Console.WriteLine(obj);
3254

@@ -124,10 +146,13 @@ public static object[] ArrayRemove(object[] arr, int index)
124146
return arr.Take(index).Concat(arr.Skip(index + 1)).ToArray();
125147
}
126148

149+
[ManualDocs("sqrt", "{\"title\":\"sqrt(x)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"sqrt(<number>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Takes the square root of\"},{\"text\":\"x\",\"color\":\"Green\"},{\"text\":\".\"}]}]}")]
127150
public static double Sqrt(double x) => Math.Sqrt(x);
128151

152+
[ManualDocs("pow", "{\"title\":\"pow(x, n)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"pow(<number>, <number>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Raise \"},{\"text\":\"x\",\"color\":\"Green\"},{\"text\":\" to the power of \"},{\"text\":\"n\",\"color\":\"Green\"}]}]}")]
129153
public static double Pow(double x, double y) => Math.Pow(x, y);
130154

155+
[ManualDocs("fgColor", "{\"title\":\"fgColor(color)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"fgColor(<color number or name>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Set the text color to \"},{\"text\":\"color\",\"color\":\"Green\"}]},{\"header\":\"Valid colors\",\"text\":[{\"text\":\"BLACK BLUE CYAN DARK_BLUE DARK_CYAN DARK_GRAY DARK_GREEN DARK_MAGENTA DARK_RED DARK_YELLOW GRAY GREEN MAGENTA RED WHITE YELLOW\",\"color\":\"Cyan\"}]}]}")]
131156
public static void FgColor(int color)
132157
{
133158
if (color < 0 || color > 15)
@@ -137,6 +162,7 @@ public static void FgColor(int color)
137162
Console.ForegroundColor = (ConsoleColor)color;
138163
}
139164

165+
[ManualDocs("bgColor", "{\"title\":\"bgColor(color)\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"bgColor(<color number or name>);\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Set the background color to \"},{\"text\":\"color\",\"color\":\"Green\"},{\"text\":\". call \"},{\"text\":\"clear()\",\"color\":\"Yellow\"},{\"text\":\"to if you want to set the background color of the whole screen, because \"},{\"text\":\"bgColor(color)\",\"color\":\"Yellow\"},{\"text\":\" only affects the background color of new printed text.\"}]},{\"header\":\"Valid colors\",\"text\":[{\"text\":\"BLACK BLUE CYAN DARK_BLUE DARK_CYAN DARK_GRAY DARK_GREEN DARK_MAGENTA DARK_RED DARK_YELLOW GRAY GREEN MAGENTA RED WHITE YELLOW\",\"color\":\"Cyan\"}]}]}")]
140166
public static void BgColor(int color)
141167
{
142168
if (color < 0 || color > 15)
@@ -146,6 +172,7 @@ public static void BgColor(int color)
146172
Console.BackgroundColor = (ConsoleColor)color;
147173
}
148174

175+
[ManualDocs("resetColor", "{\"title\":\"resetColor()\",\"sections\":[{\"header\":\"Syntax\",\"text\":[{\"text\":\"resetColor();\"}]},{\"header\":\"Behavior\",\"text\":[{\"text\":\"Reset the console colors back to their defaults.\"}]}]}")]
149176
public static void ResetColor() => Console.ResetColor();
150177
}
151178
}

7Sharp/Program.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,19 @@ internal sealed class Program
2323
[STAThread]
2424
private static void Main(string[] args)
2525
{
26-
if (args.Length > 1)
27-
{
28-
WriteLineColor("You may only pass 1 script file to read!", Red);
29-
Read();
30-
return;
31-
}
3226
//title
3327
Title = "7Sharp";
34-
if (args.Length == 1)
28+
if (args.Length > 1)
3529
{
3630
try
3731
{
38-
using (StreamReader sr = new StreamReader(args[0]))
32+
using (StreamReader sr = new StreamReader(string.Join(" ", args)))
3933
{
4034
shell.SetCode(sr.ReadToEnd());
4135
shell.Execute("run");
4236
#if DEBUG
4337
#else
44-
shell.Execute("exit -s");
38+
return;
4539
#endif
4640
}
4741
}

7Sharp/Properties/Settings.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)