Rename all to ZSharp

This commit is contained in:
sam-astro 2022-01-29 18:10:56 -05:00
parent d1a27129d2
commit 8c296f182d
56 changed files with 87 additions and 86 deletions

View File

@ -1,5 +1,5 @@
# Z#, Z-Sharp # Slang, or StuLang
Z-Sharp is a custom programming language I made because I don't like c++ very much (Z-Sharp's interpreter is written in c++ though). It used to be called Slang, standing for "Stupid Lang", but another programmig langauge called Slang already exists :(. Z-Sharp scripts have the file extension .zs. The base syntax and formatting I would say is quite similar to C#, but differs as task complexity increases. It has support for graphics using SDL2, and by default is not enabled. Here is some example code. Slang, or StuLang, which stands for ***Stu****pid **Lang**uage* is a custom programming language I made because I don't like c++ very much (Slang's interpreter is written in c++ though). Slang scripts have the file extension .slg. The base syntax and formatting I would say is quite similar to C#, but differs as task complexity increases. It has support for graphics using SDL2, and by default is not enabled. Here is some example code.
```c# ```c#
// Comments are indicated by two forward slashes // Comments are indicated by two forward slashes
// They can only be on their own line // They can only be on their own line

View File

@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.0.31612.314 VisualStudioVersion = 17.0.31612.314
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Slang", "Slang\Slang.vcxproj", "{D5F150F8-1F83-41EB-A195-1B5C3CA9322A}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ZSharp", "ZSharp\ZSharp.vcxproj", "{D5F150F8-1F83-41EB-A195-1B5C3CA9322A}"
EndProject EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Slang-Installer", "Slang-Installer\Slang-Installer.vdproj", "{42EA0B7A-2068-4065-B9EB-041F32933A66}" Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "ZSharp Installer", "ZSharp-Installer\ZSharp-Installer.vdproj", "{42EA0B7A-2068-4065-B9EB-041F32933A66}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@ -3,7 +3,7 @@
"VSVersion" = "3:800" "VSVersion" = "3:800"
"ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}" "ProjectType" = "8:{978C614F-708E-4E1A-B201-565925725DBA}"
"IsWebType" = "8:FALSE" "IsWebType" = "8:FALSE"
"ProjectName" = "8:Slang-Installer" "ProjectName" = "8:ZSharp Installer"
"LanguageId" = "3:1033" "LanguageId" = "3:1033"
"CodePage" = "3:1252" "CodePage" = "3:1252"
"UILanguageId" = "3:1033" "UILanguageId" = "3:1033"
@ -93,7 +93,7 @@
"DisplayName" = "8:Debug" "DisplayName" = "8:Debug"
"IsDebugOnly" = "11:TRUE" "IsDebugOnly" = "11:TRUE"
"IsReleaseOnly" = "11:FALSE" "IsReleaseOnly" = "11:FALSE"
"OutputFilename" = "8:..\\Releases\\Slang-Installer\\Slang-Installer.msi" "OutputFilename" = "8:..\\Releases\\ZSharp-Installer\\ZSharp-Installer.msi"
"PackageFilesAs" = "3:2" "PackageFilesAs" = "3:2"
"PackageFileSize" = "3:-2147483648" "PackageFileSize" = "3:-2147483648"
"CabType" = "3:1" "CabType" = "3:1"
@ -125,7 +125,7 @@
"DisplayName" = "8:Release" "DisplayName" = "8:Release"
"IsDebugOnly" = "11:FALSE" "IsDebugOnly" = "11:FALSE"
"IsReleaseOnly" = "11:TRUE" "IsReleaseOnly" = "11:TRUE"
"OutputFilename" = "8:..\\Releases\\Slang-Installer-Win-x64\\Slang-Installer.msi" "OutputFilename" = "8:..\\Releases\\ZSharp-Installer-Win-x64\\ZSharp-Installer.msi"
"PackageFilesAs" = "3:2" "PackageFilesAs" = "3:2"
"PackageFileSize" = "3:-2147483648" "PackageFileSize" = "3:-2147483648"
"CabType" = "3:1" "CabType" = "3:1"
@ -174,7 +174,7 @@
{ {
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1BBDEA811E8A494DB30AB0E778BEF5B3" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1BBDEA811E8A494DB30AB0E778BEF5B3"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\Pong-Example-Project\\square.png" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\Pong-Example-Project\\square.png"
"TargetName" = "8:square.png" "TargetName" = "8:square.png"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_AB72F4F4665144CA990532BBC3679E36" "Folder" = "8:_AB72F4F4665144CA990532BBC3679E36"
@ -194,7 +194,7 @@
} }
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_29CB0EFE95A142F4A149E51FAE871DDE" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_29CB0EFE95A142F4A149E51FAE871DDE"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\libtiff-5.dll" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\libtiff-5.dll"
"TargetName" = "8:libtiff-5.dll" "TargetName" = "8:libtiff-5.dll"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2" "Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2"
@ -214,7 +214,7 @@
} }
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_38EBD2EEB8C34316A3249C9D9873B1C2" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_38EBD2EEB8C34316A3249C9D9873B1C2"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\zlib1.dll" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\zlib1.dll"
"TargetName" = "8:zlib1.dll" "TargetName" = "8:zlib1.dll"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2" "Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2"
@ -234,7 +234,7 @@
} }
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4B23F888FF8342319507C8AAA3334953" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_4B23F888FF8342319507C8AAA3334953"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\libpng16-16.dll" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\libpng16-16.dll"
"TargetName" = "8:libpng16-16.dll" "TargetName" = "8:libpng16-16.dll"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2" "Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2"
@ -254,7 +254,7 @@
} }
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_5F99C783A5A5405FAEED16B4899E66A3" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_5F99C783A5A5405FAEED16B4899E66A3"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\Pong-Example-Project\\net.png" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\Pong-Example-Project\\net.png"
"TargetName" = "8:net.png" "TargetName" = "8:net.png"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_AB72F4F4665144CA990532BBC3679E36" "Folder" = "8:_AB72F4F4665144CA990532BBC3679E36"
@ -294,7 +294,7 @@
} }
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8116B924B2DC45BB901E89A2EEB674E6" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8116B924B2DC45BB901E89A2EEB674E6"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\libjpeg-9.dll" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\libjpeg-9.dll"
"TargetName" = "8:libjpeg-9.dll" "TargetName" = "8:libjpeg-9.dll"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2" "Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2"
@ -314,7 +314,7 @@
} }
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_84E97BEFD3C240DC822DAEF66BB20D79" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_84E97BEFD3C240DC822DAEF66BB20D79"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\Pong-Example-Project\\arial.ttf" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\Pong-Example-Project\\arial.ttf"
"TargetName" = "8:arial.ttf" "TargetName" = "8:arial.ttf"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_AB72F4F4665144CA990532BBC3679E36" "Folder" = "8:_AB72F4F4665144CA990532BBC3679E36"
@ -334,7 +334,7 @@
} }
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8D4524D8D2654AF28CD2B8483A2B2505" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_8D4524D8D2654AF28CD2B8483A2B2505"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\libwebp-7.dll" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\libwebp-7.dll"
"TargetName" = "8:libwebp-7.dll" "TargetName" = "8:libwebp-7.dll"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2" "Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2"
@ -354,7 +354,7 @@
} }
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F1964A3FC0114E58A81978C4C7107596" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_F1964A3FC0114E58A81978C4C7107596"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\Pong-Example-Project\\script.slg" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\Pong-Example-Project\\script.slg"
"TargetName" = "8:script.slg" "TargetName" = "8:script.slg"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_AB72F4F4665144CA990532BBC3679E36" "Folder" = "8:_AB72F4F4665144CA990532BBC3679E36"
@ -374,7 +374,7 @@
} }
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_FEA298B841784CB2933DCEB504513792" "{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_FEA298B841784CB2933DCEB504513792"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\libfreetype-6.dll" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\libfreetype-6.dll"
"TargetName" = "8:libfreetype-6.dll" "TargetName" = "8:libfreetype-6.dll"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2" "Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2"
@ -422,7 +422,7 @@
} }
"{3C67513D-01DD-4637-8A68-80971EB9504F}:_BCDF457FF4564F7BBFD6AEF054FE16C2" "{3C67513D-01DD-4637-8A68-80971EB9504F}:_BCDF457FF4564F7BBFD6AEF054FE16C2"
{ {
"DefaultLocation" = "8:[ProgramFiles64Folder]\\Slang" "DefaultLocation" = "8:[ProgramFiles64Folder]\\ZSharp"
"Name" = "8:#1925" "Name" = "8:#1925"
"AlwaysCreate" = "11:FALSE" "AlwaysCreate" = "11:FALSE"
"Condition" = "8:" "Condition" = "8:"
@ -458,24 +458,24 @@
"Product" "Product"
{ {
"Name" = "8:Microsoft Visual Studio" "Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Slang" "ProductName" = "8:ZSharp"
"ProductCode" = "8:{A5629CD2-46CB-4945-BBA2-BAC60F2DDFC4}" "ProductCode" = "8:{4E83312A-4C42-44BD-8604-E55F7D1B005B}"
"PackageCode" = "8:{DEE267E6-C968-4059-8F0F-4560CF270A35}" "PackageCode" = "8:{A82E7BE4-0442-482B-A5CB-CC097C9915DF}"
"UpgradeCode" = "8:{8ABDE53F-7FF9-455B-A777-B4C1C624FA13}" "UpgradeCode" = "8:{8ABDE53F-7FF9-455B-A777-B4C1C624FA13}"
"AspNetVersion" = "8:2.0.50727.0" "AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE" "RestartWWWService" = "11:FALSE"
"RemovePreviousVersions" = "11:TRUE" "RemovePreviousVersions" = "11:TRUE"
"DetectNewerInstalledVersion" = "11:TRUE" "DetectNewerInstalledVersion" = "11:TRUE"
"InstallAllUsers" = "11:FALSE" "InstallAllUsers" = "11:FALSE"
"ProductVersion" = "8:1.2.2" "ProductVersion" = "8:1.3.0"
"Manufacturer" = "8:Sam-Astro" "Manufacturer" = "8:Sam-Astro"
"ARPHELPTELEPHONE" = "8:" "ARPHELPTELEPHONE" = "8:"
"ARPHELPLINK" = "8:" "ARPHELPLINK" = "8:"
"Title" = "8:Slang" "Title" = "8:ZSharp"
"Subject" = "8:" "Subject" = "8:"
"ARPCONTACT" = "8:Sam-Astro" "ARPCONTACT" = "8:Sam-Astro"
"Keywords" = "8:" "Keywords" = "8:"
"ARPCOMMENTS" = "8:Installer for Slang interpreter" "ARPCOMMENTS" = "8:Installer for ZSharp interpreter"
"ARPURLINFOABOUT" = "8:" "ARPURLINFOABOUT" = "8:"
"ARPPRODUCTICON" = "8:_7C9D3FE3584D494F807EBD12C93E2FC5" "ARPPRODUCTICON" = "8:_7C9D3FE3584D494F807EBD12C93E2FC5"
"ARPIconIndex" = "3:0" "ARPIconIndex" = "3:0"
@ -981,7 +981,7 @@
{ {
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_2441313DD4DA406BBC1915DDEE0AC74C" "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_2441313DD4DA406BBC1915DDEE0AC74C"
{ {
"SourcePath" = "8:..\\Releases\\Slang-Win-x64\\Slang.exe" "SourcePath" = "8:..\\Releases\\ZSharp-Win-x64\\ZSharp.exe"
"TargetName" = "8:" "TargetName" = "8:"
"Tag" = "8:" "Tag" = "8:"
"Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2" "Folder" = "8:_BCDF457FF4564F7BBFD6AEF054FE16C2"

View File

Before

Width:  |  Height:  |  Size: 800 KiB

After

Width:  |  Height:  |  Size: 800 KiB

View File

@ -2,12 +2,12 @@ cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(Slang) project(ZSharp)
SET(programName Slang) SET(programName Slang)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeFiles/") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeFiles/")
add_executable (Slang Main.cpp main.h anyops.h builtin.h strops.cpp strops.h eval.cpp eval.h graphics.h SLB.h) add_executable (ZSharp Main.cpp main.h anyops.h builtin.h strops.cpp strops.h eval.cpp eval.h graphics.h ZS.h)
find_package(SDL2 REQUIRED) find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED) find_package(SDL2_image REQUIRED)
@ -31,4 +31,4 @@ FIND_PACKAGE(Boost REQUIRED COMPONENTS system)
include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(Slang m ${Boost_LIBRARIES} ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_TTF_LIBRARIES}) target_link_libraries(ZSharp m ${Boost_LIBRARIES} ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_TTF_LIBRARIES})

View File

@ -36,7 +36,7 @@
#include "main.h" #include "main.h"
#include "anyops.h" #include "anyops.h"
#include "SLB.h" #include "ZS.h"
using namespace std; using namespace std;
using namespace boost; using namespace boost;
@ -74,7 +74,7 @@ boost::any GetVariableValue(const string& varName, const unordered_map<string, b
bool IsVar(const string& varName, const unordered_map<string, boost::any>& variableValues) bool IsVar(const string& varName, const unordered_map<string, boost::any>& variableValues)
{ {
if (variableValues.find(split(varName, '.')[0]) != variableValues.end() && split(varName, '.')[0] != "SLB") if (variableValues.find(split(varName, '.')[0]) != variableValues.end() && split(varName, '.')[0] != "ZS")
return true; return true;
else else
return false; return false;
@ -114,7 +114,7 @@ bool IsFunction(const string& funcName)
else else
return false; return false;
} }
bool IsSLBFunction(const string& funcName) bool IsZSFunction(const string& funcName)
{ {
if (funcName[0] == 'S' && funcName[1] == 'L' && funcName[2] == 'B' && funcName[3] == '.') if (funcName[0] == 'S' && funcName[1] == 'L' && funcName[2] == 'B' && funcName[3] == '.')
return true; return true;
@ -132,9 +132,9 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
#endif #endif
bool isFunc = IsFunction(split(expression, '(')[0]); bool isFunc = IsFunction(split(expression, '(')[0]);
bool isSLB = split(expression, '.')[0] == "SLB"; bool isZS = split(expression, '.')[0] == "ZS";
// If no operations are applied, then return self // If no operations are applied, then return self
if ((countOutsideParenthesis(expression, '+') == 0 && countOutsideParenthesis(expression, '-') == 0 && countOutsideParenthesis(expression, '*') == 0 && countOutsideParenthesis(expression, '/') == 0 && countOutsideParenthesis(expression, '^') == 0) || split(expression, '.')[0] == "SLB") if ((countOutsideParenthesis(expression, '+') == 0 && countOutsideParenthesis(expression, '-') == 0 && countOutsideParenthesis(expression, '*') == 0 && countOutsideParenthesis(expression, '/') == 0 && countOutsideParenthesis(expression, '^') == 0) || split(expression, '.')[0] == "ZS")
{ {
bool isFunc = IsFunction(split(expression, '(')[0]); bool isFunc = IsFunction(split(expression, '(')[0]);
if (isFunc && !inQuotes) if (isFunc && !inQuotes)
@ -150,7 +150,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
} }
return ExecuteFunction(split(expression, '(')[0], VarValues(split(argContents, ','), variableValues)); return ExecuteFunction(split(expression, '(')[0], VarValues(split(argContents, ','), variableValues));
} }
else if (split(expression, '.')[0] == "SLB" && !inQuotes) else if (split(expression, '.')[0] == "ZS" && !inQuotes)
{ {
string argContents = ""; string argContents = "";
int y = indexInStr(expression, '(') + 1; int y = indexInStr(expression, '(') + 1;
@ -160,7 +160,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
y++; y++;
} }
return SLBFunction(split(expression, '(')[0], VarValues(split(argContents, ','), variableValues)); return ZSFunction(split(expression, '(')[0], VarValues(split(argContents, ','), variableValues));
} }
else else
return GetVariableValue(expression, variableValues); return GetVariableValue(expression, variableValues);
@ -199,7 +199,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
string returnVal = AnyAsString(ExecuteFunction(name, VarValues(split(argContents, ','), variableValues))); string returnVal = AnyAsString(ExecuteFunction(name, VarValues(split(argContents, ','), variableValues)));
newExpression += returnVal; newExpression += returnVal;
} }
else if (split(name, '.')[0] == "SLB" && !inQuotes) else if (split(name, '.')[0] == "ZS" && !inQuotes)
{ {
string argContents = ""; string argContents = "";
int y = indexInStr(expression, '(') + 1; int y = indexInStr(expression, '(') + 1;
@ -210,7 +210,7 @@ boost::any EvalExpression(const string& ex, unordered_map<string, boost::any>& v
y++; y++;
} }
//cout << split(expression, '(')[0] << " " << argContents << endl; //cout << split(expression, '(')[0] << " " << argContents << endl;
string returnVal = AnyAsString(SLBFunction(split(name, '(')[0], VarValues(split(argContents, ','), variableValues))); string returnVal = AnyAsString(ZSFunction(split(name, '(')[0], VarValues(split(argContents, ','), variableValues)));
newExpression += returnVal; newExpression += returnVal;
} }
else else
@ -373,7 +373,7 @@ boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unorder
if (words.at(lineNum).at(0)[0] == '/' && words.at(lineNum).at(0)[1] == '/') if (words.at(lineNum).at(0)[0] == '/' && words.at(lineNum).at(0)[1] == '/')
return nullType; return nullType;
// If print statement (deprecated, now use SLB.System.Print() function) // If print statement (deprecated, now use ZS.System.Print() function)
else if (words.at(lineNum).at(0) == "print") else if (words.at(lineNum).at(0) == "print")
{ {
cout << StringRaw(AnyAsString(EvalExpression(unWrapVec(vector<string>(words.at(lineNum).begin() + 1, words.at(lineNum).end())), variableValues))) << endl; cout << StringRaw(AnyAsString(EvalExpression(unWrapVec(vector<string>(words.at(lineNum).begin() + 1, words.at(lineNum).end())), variableValues))) << endl;
@ -384,7 +384,7 @@ boost::any ProcessLine(const vector<vector<string>>& words, int lineNum, unorder
else if (words.at(lineNum).at(0) == "return") else if (words.at(lineNum).at(0) == "return")
return EvalExpression(unWrapVec(vector<string>(words.at(lineNum).begin() + 1, words.at(lineNum).end())), variableValues); return EvalExpression(unWrapVec(vector<string>(words.at(lineNum).begin() + 1, words.at(lineNum).end())), variableValues);
// Check if it is SLB Builtin function // Check if it is ZS Builtin function
else if (words.at(lineNum).at(0)[0] == 'S' && words.at(lineNum).at(0)[1] == 'L' && words.at(lineNum).at(0)[2] == 'B' && words.at(lineNum).at(0)[3] == '.') else if (words.at(lineNum).at(0)[0] == 'S' && words.at(lineNum).at(0)[1] == 'L' && words.at(lineNum).at(0)[2] == 'B' && words.at(lineNum).at(0)[3] == '.')
return EvalExpression(unWrapVec(words.at(lineNum)), variableValues); return EvalExpression(unWrapVec(words.at(lineNum)), variableValues);
@ -576,7 +576,7 @@ boost::any ExecuteFunction(const string& functionName, const vector<boost::any>&
return nullType; return nullType;
} }
int parseSlang(string script) int parseZSharp(string script)
{ {
script = replace(script, " ", "\t"); script = replace(script, " ", "\t");
#if DEVELOPER_MESSAGES #if DEVELOPER_MESSAGES
@ -668,7 +668,7 @@ int parseSlang(string script)
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
// Gathers builtin functions and variables // Gathers builtin functions and variables
GetBuiltins(SLBContents); GetBuiltins(ZSContents);
functionValues = builtinFunctionValues; functionValues = builtinFunctionValues;
globalVariableValues = builtinVarVals; globalVariableValues = builtinVarVals;
@ -722,7 +722,7 @@ int main(int argc, char* argv[])
} }
else else
{ {
LogWarning("No script provided! Please drag and drop .SLG file over interpreter executable file, or provide it's path as a command-line argument."); LogWarning("No script provided! Please drag and drop .ZS file over interpreter executable file, or provide it's path as a command-line argument.");
cout << "Press Enter to Continue"; cout << "Press Enter to Continue";
cin.ignore(); cin.ignore();
exit(1); exit(1);
@ -733,7 +733,7 @@ int main(int argc, char* argv[])
#if DEVELOPER_MESSAGES #if DEVELOPER_MESSAGES
InterpreterLog("Parsing..."); InterpreterLog("Parsing...");
#endif #endif
parseSlang(scriptTextContents); parseZSharp(scriptTextContents);
return 0; return 0;
} }

View File

@ -2,7 +2,7 @@
using namespace std; using namespace std;
std::string SLBContents = R"( std::string ZSContents = R"(
// Default variables, can be overwritten // Default variables, can be overwritten
// if re-initialized or changed // if re-initialized or changed
float PI = 3.14159265358979323846264338 float PI = 3.14159265358979323846264338
@ -11,21 +11,21 @@ float EulersNumber = 2.71828183
// Trigonometric function Sin // Trigonometric function Sin
func Sin(input) func Sin(input)
{ {
float out = SLB.Math.Sin(input) float out = ZS.Math.Sin(input)
return out return out
} }
// Trigonometric function Cos // Trigonometric function Cos
func Cos(input) func Cos(input)
{ {
float out = SLB.Math.Cos(input) float out = ZS.Math.Cos(input)
return out return out
} }
// Trigonometric function Tan // Trigonometric function Tan
func Tan(input) func Tan(input)
{ {
float out = SLB.Math.Tan(input) float out = ZS.Math.Tan(input)
return out return out
} }
@ -46,21 +46,21 @@ func Tanh(input)
// Rounds input to nearest integer value // Rounds input to nearest integer value
func Round(input) func Round(input)
{ {
float out = SLB.Math.Round(input) float out = ZS.Math.Round(input)
return out return out
} }
// Linearly interpolates between a and b by t // Linearly interpolates between a and b by t
func Lerp(a, b, t) func Lerp(a, b, t)
{ {
float out = SLB.Math.Lerp(a, b, t) float out = ZS.Math.Lerp(a, b, t)
return out return out
} }
// Get absolute value of x // Get absolute value of x
func Abs(x) func Abs(x)
{ {
float out = SLB.Math.Abs(x) float out = ZS.Math.Abs(x)
return out return out
} }
@ -95,46 +95,46 @@ func Clamp(input, min, max)
// Sets color of pixel to RGB value // Sets color of pixel to RGB value
func SetPixel(x, y, r, g, b) func SetPixel(x, y, r, g, b)
{ {
string out = SLB.Graphics.SetPixel(x, y, r, g, b) string out = ZS.Graphics.SetPixel(x, y, r, g, b)
return out return out
} }
// Prints input value to console // Prints input value to console
func Print(in) func Print(in)
{ {
SLB.System.Print(in) ZS.System.Print(in)
} }
// Prints input value to console with appended newline '\n' // Prints input value to console with appended newline '\n'
func Printl(in) func Printl(in)
{ {
SLB.System.PrintLine(in) ZS.System.PrintLine(in)
} }
// Creates new sprite class // Creates new sprite class
func NSprite(path, x, y, r) func NSprite(path, x, y, r)
{ {
Sprite s = SLB.Graphics.Sprite(path, x, y, r) Sprite s = ZS.Graphics.Sprite(path, x, y, r)
return s return s
} }
// Draws sprite to window // Draws sprite to window
func Draw(spr) func Draw(spr)
{ {
SLB.Graphics.Draw(spr) ZS.Graphics.Draw(spr)
} }
// Creates new Vector2 class // Creates new Vector2 class
func NVec2(x, y) func NVec2(x, y)
{ {
Vec2 v = SLB.System.Vec2(x, y) Vec2 v = ZS.System.Vec2(x, y)
return v return v
} }
// Gets if key is down // Gets if key is down
func GetKey(keyName) func GetKey(keyName)
{ {
bool b = SLB.Input.GetKey(keyName) bool b = ZS.Input.GetKey(keyName)
return b return b
} }
)" )"

View File

@ -22,8 +22,9 @@
<VCProjectVersion>16.0</VCProjectVersion> <VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<ProjectGuid>{d5f150f8-1f83-41eb-a195-1b5c3ca9322a}</ProjectGuid> <ProjectGuid>{d5f150f8-1f83-41eb-a195-1b5c3ca9322a}</ProjectGuid>
<RootNamespace>Slang</RootNamespace> <RootNamespace>ZSharp</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>ZSharp</ProjectName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -166,14 +167,14 @@
<ClInclude Include="graphics.h" /> <ClInclude Include="graphics.h" />
<ClInclude Include="main.h" /> <ClInclude Include="main.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="SLB.h" /> <ClInclude Include="ZS.h" />
<ClInclude Include="strops.h" /> <ClInclude Include="strops.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="icon.ico" /> <Image Include="icon.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="Slang.rc" /> <ResourceCompile Include="ZSharp.rc" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -41,7 +41,7 @@
<ClInclude Include="main.h"> <ClInclude Include="main.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="SLB.h"> <ClInclude Include="ZS.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
@ -54,7 +54,7 @@
</Image> </Image>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="Slang.rc"> <ResourceCompile Include="ZSharp.rc">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>

View File

@ -73,7 +73,7 @@ int InterpreterLog(const string& logText)
bt = *localtime(&timer); bt = *localtime(&timer);
#endif #endif
cout << "\x1B[34m[" + to_string(Hour) + ":" + to_string(Min) + ":" + to_string(Sec) + "] \x1B[33mSlang: \x1B[32m" << logText << "\033[0m\t\t" << endl; cout << "\x1B[34m[" + to_string(Hour) + ":" + to_string(Min) + ":" + to_string(Sec) + "] \x1B[33mZSharp: \x1B[32m" << logText << "\033[0m\t\t" << endl;
return 1; return 1;
} }
@ -98,7 +98,7 @@ int LogCriticalError(const string& errorText)
bt = *localtime(&timer); bt = *localtime(&timer);
#endif #endif
cerr << "\x1B[34m[" + to_string(Hour) + ":" + to_string(Min) + ":" + to_string(Sec) + "] \x1B[33mSlang: \x1B[31mERROR: " << errorText << "\033[0m\t\t" << endl; cerr << "\x1B[34m[" + to_string(Hour) + ":" + to_string(Min) + ":" + to_string(Sec) + "] \x1B[33mZSharp: \x1B[31mERROR: " << errorText << "\033[0m\t\t" << endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
return 2; return 2;
} }
@ -255,62 +255,62 @@ int GetBuiltins(std::string s)
} }
// Executes // Executes
boost::any SLBFunction(const string& name, const vector<boost::any>& args) boost::any ZSFunction(const string& name, const vector<boost::any>& args)
{ {
if (name == "SLB.Math.Sin") if (name == "ZS.Math.Sin")
return sin(AnyAsFloat(args.at(0))); return sin(AnyAsFloat(args.at(0)));
else if (name == "SLB.Math.Cos") else if (name == "ZS.Math.Cos")
return cos(AnyAsFloat(args.at(0))); return cos(AnyAsFloat(args.at(0)));
else if (name == "SLB.Math.Tan") else if (name == "ZS.Math.Tan")
return tan(AnyAsFloat(args.at(0))); return tan(AnyAsFloat(args.at(0)));
else if (name == "SLB.Math.Round") else if (name == "ZS.Math.Round")
return AnyAsInt(args.at(0)); return AnyAsInt(args.at(0));
else if (name == "SLB.Math.Lerp") else if (name == "ZS.Math.Lerp")
return lerp(AnyAsFloat(args.at(0)), AnyAsFloat(args.at(1)), AnyAsFloat(args.at(2))); return lerp(AnyAsFloat(args.at(0)), AnyAsFloat(args.at(1)), AnyAsFloat(args.at(2)));
else if (name == "SLB.Math.Abs") else if (name == "ZS.Math.Abs")
return abs(AnyAsFloat(args.at(0))); return abs(AnyAsFloat(args.at(0)));
else if (name == "SLB.Graphics.Init") else if (name == "ZS.Graphics.Init")
{ {
#if DEVELOPER_MESSAGES == true #if DEVELOPER_MESSAGES == true
InterpreterLog("Init graphics"); InterpreterLog("Init graphics");
#endif #endif
initGraphics(StringRaw(AnyAsString(args.at(0))), AnyAsInt(args.at(1)), AnyAsInt(args.at(2))); initGraphics(StringRaw(AnyAsString(args.at(0))), AnyAsInt(args.at(1)), AnyAsInt(args.at(2)));
} }
else if (name == "SLB.Graphics.Sprite") else if (name == "ZS.Graphics.Sprite")
{ {
Sprite s(StringRaw(AnyAsString(args.at(0))), any_cast<Vec2>(args.at(1)), any_cast<Vec2>(args.at(2)), AnyAsFloat(args.at(3))); Sprite s(StringRaw(AnyAsString(args.at(0))), any_cast<Vec2>(args.at(1)), any_cast<Vec2>(args.at(2)), AnyAsFloat(args.at(3)));
return s; return s;
} }
else if (name == "SLB.Graphics.Draw") else if (name == "ZS.Graphics.Draw")
any_cast<Sprite>(args.at(0)).Draw(); any_cast<Sprite>(args.at(0)).Draw();
else if (name == "SLB.Graphics.Load") else if (name == "ZS.Graphics.Load")
any_cast<Sprite>(args.at(0)).Load(); any_cast<Sprite>(args.at(0)).Load();
else if (name == "SLB.Graphics.Text") else if (name == "ZS.Graphics.Text")
{ {
Text t(StringRaw(AnyAsString(args.at(0))), StringRaw(AnyAsString(args.at(1))), any_cast<Vec2>(args.at(2)), AnyAsFloat(args.at(3)), AnyAsFloat(args.at(4)), (Uint8)AnyAsFloat(args.at(5)), (Uint8)AnyAsFloat(args.at(6)), (Uint8)AnyAsFloat(args.at(7))); Text t(StringRaw(AnyAsString(args.at(0))), StringRaw(AnyAsString(args.at(1))), any_cast<Vec2>(args.at(2)), AnyAsFloat(args.at(3)), AnyAsFloat(args.at(4)), (Uint8)AnyAsFloat(args.at(5)), (Uint8)AnyAsFloat(args.at(6)), (Uint8)AnyAsFloat(args.at(7)));
return t; return t;
} }
else if (name == "SLB.Graphics.DrawText") else if (name == "ZS.Graphics.DrawText")
any_cast<Text>(args.at(0)).Draw(); any_cast<Text>(args.at(0)).Draw();
else if (name == "SLB.Graphics.LoadText") else if (name == "ZS.Graphics.LoadText")
any_cast<Text>(args.at(0)).Load(); any_cast<Text>(args.at(0)).Load();
else if (name == "SLB.Physics.AxisAlignedCollision") else if (name == "ZS.Physics.AxisAlignedCollision")
{ {
return AxisAlignedCollision(any_cast<Sprite>(args.at(0)), any_cast<Sprite>(args.at(1))); return AxisAlignedCollision(any_cast<Sprite>(args.at(0)), any_cast<Sprite>(args.at(1)));
} }
else if (name == "SLB.Input.GetKey") else if (name == "ZS.Input.GetKey")
return KEYS[StringRaw(any_cast<string>(args.at(0)))] == 1; return KEYS[StringRaw(any_cast<string>(args.at(0)))] == 1;
else if (name == "SLB.System.Print") else if (name == "ZS.System.Print")
cout << StringRaw(AnyAsString(args.at(0))); cout << StringRaw(AnyAsString(args.at(0)));
else if (name == "SLB.System.PrintLine") else if (name == "ZS.System.PrintLine")
cout << StringRaw(AnyAsString(args.at(0))) << endl; cout << StringRaw(AnyAsString(args.at(0))) << endl;
else if (name == "SLB.System.Vec2") else if (name == "ZS.System.Vec2")
{ {
Vec2 v(AnyAsFloat(args.at(0)), AnyAsFloat(args.at(1))); Vec2 v(AnyAsFloat(args.at(0)), AnyAsFloat(args.at(1)));
return v; return v;
} }
else else
LogWarning("SLB function \'" + name + "\' does not exist."); LogWarning("ZS function \'" + name + "\' does not exist.");
return nullType; return nullType;
} }

View File

@ -1,4 +1,4 @@
// SLB program to evaluate a given expression // ZS program to evaluate a given expression
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <string> #include <string>

View File

Before

Width:  |  Height:  |  Size: 800 KiB

After

Width:  |  Height:  |  Size: 800 KiB

View File

@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}} //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file. // Microsoft Visual C++ generated include file.
// Used by Slang.rc // Used by ZSharp.rc
// //
#define IDI_ICON1 101 #define IDI_ICON1 101