Repository navigation
Expand file tree
/
Copy pathcouplescript.bat
More file actions
105 lines (92 loc) · 2.24 KB
/
Copy pathcouplescript.bat
File metadata and controls
105 lines (92 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
@echo off
setlocal enabledelayedexpansion
REM CoupleScript Interpreter for Windows
if "%1"=="" (
echo CoupleScript Interactive REPL
echo Type CoupleScript commands or 'exit' to quit
echo Examples:
echo remember "Hello World"
echo marry name "Alice"
echo propose greet^(^): remember "Hello!"
echo.
:loop
set /p "line=cs> "
if "!line!"=="exit" goto :eof
call :interpret "!line!"
goto :loop
) else (
if exist "%1" (
echo 💕 Running CoupleScript program: %1
echo.
for /f "usebackq delims=" %%A in ("%1") do (
set "line=%%A"
call :interpret "!line!"
)
echo.
echo 💖 Program finished!
) else (
echo ❌ Error: File %1 not found
)
)
goto :eof
:interpret
set "line=%~1"
REM Skip comments and empty lines
if "!line:~0,1!"=="#" goto :eof
if "!line!"=="" goto :eof
REM Handle remember command (print)
echo !line! | findstr /i "^remember " >nul
if !errorlevel!==0 (
set "msg=!line:remember =!"
REM Remove surrounding quotes if present
if "!msg:~0,1!"=="^"" if "!msg:~-1!"=="^"" set "msg=!msg:~1,-1!"
echo !msg!
goto :eof
)
REM Handle marry command (variable assignment)
echo !line! | findstr /i "^marry " >nul
if !errorlevel!==0 (
echo 💒 !line!
goto :eof
)
REM Handle argue command (if statement)
echo !line! | findstr /i "^argue " >nul
if !errorlevel!==0 (
echo 💭 !line!
goto :eof
)
REM Handle makeup command (else)
echo !line! | findstr /i "^makeup" >nul
if !errorlevel!==0 (
echo 💕 !line!
goto :eof
)
REM Handle propose command (function definition)
echo !line! | findstr /i "^propose " >nul
if !errorlevel!==0 (
echo 💍 !line!
goto :eof
)
REM Handle accept command (function call)
echo !line! | findstr /i "^accept " >nul
if !errorlevel!==0 (
echo 💝 !line!
goto :eof
)
REM Handle anniversary command (loop)
echo !line! | findstr /i "^anniversary " >nul
if !errorlevel!==0 (
echo 🎉 !line!
goto :eof
)
REM Handle love/hate (booleans)
echo !line! | findstr /i "love\|hate" >nul
if !errorlevel!==0 (
echo ❤️ !line!
goto :eof
)
REM Default: show that we're processing the line
if not "!line!"=="" (
echo 🤔 Processing: !line!
)
goto :eof