-
Notifications
You must be signed in to change notification settings - Fork 0
/
BrainFuck.bat
79 lines (61 loc) · 1.21 KB
/
BrainFuck.bat
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
@ECHO OFF
REM Brainfuck
SET PTR=0
REM ポインター
SET NOWSTR=
REM 出力文字列
SET NOWINPUT=NEXT_INPUT
REM 現在文字列
SET MEMSIZE=1024
REM メモリのサイズ
SET /A MEMSIZE_=MEMSIZE-1
REM メモリのサイズ-1
FOR /L %%T IN (0,1,%MEMSIZE_%) DO SET MEMORY%%T=0
REM メモリの初期化
SET PROGRAM=%*
SET COUNTER=0
:LOOP
SET TMP=%PROGRAM:~0,1%
SET PROGRAM=%PROGRAM:~1%
IF "%TMP%"=="+" (
SET /A PROG%COUNTER%=1
SET /A COUNTER=COUNTER+1
)
IF "%TMP%"=="-" (
SET /A PROG%COUNTER%=2
SET /A COUNTER=COUNTER+1
)
IF "%TMP%"==")" (
SET /A PROG%COUNTER%=3
SET /A COUNTER=COUNTER+1
)
IF "%TMP%"=="(" (
SET /A PROG%COUNTER%=4
SET /A COUNTER=COUNTER+1
)
IF "%TMP%"=="." (
SET /A PROG%COUNTER%=5
SET /A COUNTER=COUNTER+1
)
IF "%TMP%"=="," (
SET /A PROG%COUNTER%=6
SET /A COUNTER=COUNTER+1
)
IF "%TMP%"=="[" (
SET /A PROG%COUNTER%=7
SET /A COUNTER=COUNTER+1
)
IF "%TMP%"=="]" (
SET /A PROG%COUNTER%=8
SET /A COUNTER=COUNTER+1
)
IF NOT "%PROGRAM%"=="" GOTO LOOP
REM プログラムが空になるまで処理を行う
SET /A PROG%COUNTER%=8
SET DEPTH=0
REM 再帰の深さ
CALL DFS 0
@ECHO OFF
SET CODE=10
CALL PutChar.bat
REM 最後に改行を出力する