| @@ -5,23 +5,22 @@ pushd %~dp0 | |||||
| set exeName=slime.exe | set exeName=slime.exe | ||||
| set binDir=bin | set binDir=bin | ||||
| mkdir quickbuild 2>nul | |||||
| pushd quickbuild | |||||
| mkdir build 2>nul | |||||
| pushd build | |||||
| taskkill /F /IM %exeName% > NUL 2> NUL | taskkill /F /IM %exeName% > NUL 2> NUL | ||||
| echo ---------- Compiling ---------- | echo ---------- Compiling ---------- | ||||
| call timecmd cl ../src/main.c /Fe%exeName% /W3 /Ox /O2 /Oi /TC /nologo /EHsc /link | |||||
| call timecmd cl ../src/main.c /Fe%exeName% /D_DEBUG /W3 /TC /Zi /nologo /EHsc /link | |||||
| if %errorlevel% == 0 ( | if %errorlevel% == 0 ( | ||||
| echo. | echo. | ||||
| if not exist ..\%binDir% mkdir ..\%binDir% | |||||
| move %exeName% ..\%binDir%\ > NUL | |||||
| echo Done | |||||
| ) else ( | ) else ( | ||||
| echo. | echo. | ||||
| echo Fucki'n 'ell | |||||
| echo Fuckin' ell | |||||
| ) | ) | ||||
| popd | popd | ||||
| rd quickbuild /S /Q | |||||
| rem rd build /S /Q | |||||
| popd | popd | ||||
| @@ -1,4 +1,4 @@ | |||||
| @echo off | @echo off | ||||
| pushd %~dp0\vs | |||||
| start slime.sln | |||||
| pushd %~dp0 | |||||
| start "" "cdbg64.exe" build\slime.exe | |||||
| popd | popd | ||||
| @@ -156,6 +156,7 @@ typedef enum { | |||||
| Built_In_Rest, | Built_In_Rest, | ||||
| Built_In_Subtraction, | Built_In_Subtraction, | ||||
| Built_In_Type, | Built_In_Type, | ||||
| Built_In_While, | |||||
| } Built_In_Name; | } Built_In_Name; | ||||
| /** | /** | ||||
| @@ -196,6 +197,7 @@ char* Built_In_Name_to_string(Built_In_Name name) { | |||||
| case Built_In_Rest: return "rest"; | case Built_In_Rest: return "rest"; | ||||
| case Built_In_Subtraction: return "-"; | case Built_In_Subtraction: return "-"; | ||||
| case Built_In_Type: return "type"; | case Built_In_Type: return "type"; | ||||
| case Built_In_While: return "while"; | |||||
| } | } | ||||
| return "Built in string missing in Built_In_Name_to_string"; | return "Built in string missing in Built_In_Name_to_string"; | ||||
| @@ -311,6 +313,7 @@ Ast_Node* create_ast_node_built_in_function(char* name) { | |||||
| else if (string_equal(name, "read")) type = Built_In_Read; | else if (string_equal(name, "read")) type = Built_In_Read; | ||||
| else if (string_equal(name, "rest")) type = Built_In_Rest; | else if (string_equal(name, "rest")) type = Built_In_Rest; | ||||
| else if (string_equal(name, "type")) type = Built_In_Type; | else if (string_equal(name, "type")) type = Built_In_Type; | ||||
| else if (string_equal(name, "while")) type = Built_In_While; | |||||
| else return nullptr; | else return nullptr; | ||||
| Ast_Node* node = new(Ast_Node); | Ast_Node* node = new(Ast_Node); | ||||
| @@ -632,6 +632,23 @@ Ast_Node* eval_expr(Ast_Node* node, Environment* env) { | |||||
| return create_ast_node_nil(); | return create_ast_node_nil(); | ||||
| return create_ast_node_t(); | return create_ast_node_t(); | ||||
| } | } | ||||
| case Built_In_While: { | |||||
| try { | |||||
| arguments_length = list_length(arguments); | |||||
| } | |||||
| if (arguments_length < 2) { | |||||
| report_error(Error_Type_Wrong_Number_Of_Arguments); | |||||
| } | |||||
| Ast_Node* condition = arguments->value.pair->first; | |||||
| Ast_Node* then_part = arguments->value.pair->rest; | |||||
| Ast_Node* result = create_ast_node_nil(); | |||||
| while (eval_expr(condition, env)->type != Ast_Node_Type_Nil) { | |||||
| result = eval_expr(then_part->value.pair->first, env); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| case Built_In_If: { | case Built_In_If: { | ||||
| try { | try { | ||||
| arguments_length = list_length(arguments); | arguments_length = list_length(arguments); | ||||
| @@ -1,7 +1,13 @@ | |||||
| #define console_normal "\x1B[0m" | |||||
| #define console_red "\x1B[31m" | |||||
| #define console_green "\x1B[32m" | |||||
| #define console_cyan "\x1B[36m" | |||||
| /* #define console_normal "\x1B[0m" */ | |||||
| /* #define console_red "\x1B[31m" */ | |||||
| /* #define console_green "\x1B[32m" */ | |||||
| /* #define console_cyan "\x1B[36m" */ | |||||
| #define console_normal "" | |||||
| #define console_red "" | |||||
| #define console_green "" | |||||
| #define console_cyan "" | |||||
| typedef enum { | typedef enum { | ||||
| Log_Level_None, | Log_Level_None, | ||||
| @@ -1,4 +1,4 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||||
| <ItemGroup Label="ProjectConfigurations"> | <ItemGroup Label="ProjectConfigurations"> | ||||
| <ProjectConfiguration Include="Debug|Win32"> | <ProjectConfiguration Include="Debug|Win32"> | ||||
| @@ -30,7 +30,7 @@ | |||||
| <VCProjectVersion>15.0</VCProjectVersion> | <VCProjectVersion>15.0</VCProjectVersion> | ||||
| <ProjectGuid>{1A47A3ED-871F-4CB4-875B-8CAA385B1771}</ProjectGuid> | <ProjectGuid>{1A47A3ED-871F-4CB4-875B-8CAA385B1771}</ProjectGuid> | ||||
| <RootNamespace>slime</RootNamespace> | <RootNamespace>slime</RootNamespace> | ||||
| <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> | |||||
| <WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion> | |||||
| <ProjectName>slime</ProjectName> | <ProjectName>slime</ProjectName> | ||||
| </PropertyGroup> | </PropertyGroup> | ||||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||||