Skip to content

Commit 4ed71c6

Browse files
Class-based OOP
1 parent 1ece8dc commit 4ed71c6

File tree

2 files changed

+79
-12
lines changed

2 files changed

+79
-12
lines changed

Source/FreakC.bat

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ if "%1" == "--clrbat" (
5252
if "!name:FCShell.bat=!" NEQ "!name!" set clearCheck=true
5353
if "!name:createFile.bat=!" NEQ "!name!" set clearCheck=true
5454
if "!name:libgen.bat=!" NEQ "!name!" set clearCheck=true
55+
if "!name:disDelayedStore.bat=!" NEQ "!name!" set clearCheck=true
5556
if "!clearCheck!" == "false" del /q %%i
5657
)
5758
exit /b
@@ -75,6 +76,8 @@ set wloopnum=0
7576
set wloopnum2=0
7677
set proctar=something
7778
set inlftar=something
79+
set classtar=something
80+
set methodtar=something
7881
set fchcomment=false
7982
set matchInd=0
8083
set forInd=0
@@ -147,6 +150,46 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
147150
set inlftar=none
148151
set deniedToken=true
149152
)
153+
if %%a == class[] (
154+
set classval=0
155+
set classadd=true
156+
set classtar=!printString:class[] =!
157+
set deniedToken=true
158+
)
159+
if %%a == endclass[] (
160+
set classadd=false
161+
set classtar=none
162+
set deniedToken=true
163+
)
164+
if %%a == method[] (
165+
set methodval=0
166+
set methodadd=true
167+
set methodtar=!printString:method[] =!
168+
set deniedToken=true
169+
)
170+
if %%a == endmethod[] (
171+
set methodadd=false
172+
set methodtar=none
173+
set deniedToken=true
174+
)
175+
if %%a == new[] (
176+
set cprocess=!printString:new[] =!
177+
set turn=0
178+
for %%i in (!cprocess!) do (
179+
if !turn! == 0 set target=%%i
180+
if !turn! == 1 set objname=%%i
181+
set /a turn+=1
182+
)
183+
for /r %%i in (*.method) do (
184+
set name=%%i
185+
set name=!name:%cd%\=!
186+
call :get_len len !target!
187+
for %%j in (!len!) do if "!name:~0,%%j!" == "!target!" (
188+
call disDelayedStore !name! !objname!!name:~%%j!
189+
)
190+
)
191+
for %%i in (!target!) do for %%j in (!objname!) do set printString=!printString:new[] %%i =call %%j.init.bat !
192+
)
150193
set icall=false
151194
if "!ch:~-4!" == "[//]" (
152195
set icall=true
@@ -157,7 +200,7 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
157200
set iprocess=!printString:icall[] =!
158201
)
159202
if "!icall!" == "true" (
160-
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
203+
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
161204
set deniedToken=true
162205
set turn=0
163206
for %%i in (!iprocess!) do (
@@ -336,7 +379,7 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
336379
if %%a == drive[] set printString=!printString:drive[] =!:
337380
if %%a == while[] (
338381
set prevLoop[!prevLoopInd!]=while
339-
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
382+
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
340383
set fccondition=!printString:while[] =!
341384
set fcpos[!wloopInd!]=!wloopnum!
342385
for %%i in (!wloopInd!) do (
@@ -350,7 +393,7 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
350393
)
351394
if %%a == for[] (
352395
set prevLoop[!prevLoopInd!]=for
353-
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
396+
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
354397
set turn=0
355398
set process=!printString:for[] =!
356399
for %%i in (!process!) do (
@@ -380,7 +423,7 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
380423
)
381424
if %%a == endwhile[] set whileCheck=true
382425
if "!whileCheck!" == "true" (
383-
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
426+
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
384427
set /a _wloopInd=!wloopInd!-1
385428
for %%i in (!_wloopInd!) do (
386429
if "!acceptFor!" == "true" (
@@ -417,7 +460,7 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
417460
if %%a == repeat[] (
418461
set prevLoop[!prevLoopInd!]=repeat
419462
set prevLoop=repeat
420-
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
463+
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
421464
set fcpos2[!wloopInd2!]=!wloopnum2!
422465
for %%i in (!wloopInd2!) do echo :RepeatLoop!fcpos2[%%i]!>>!outtar!
423466
set /a wloopnum2+=1
@@ -426,7 +469,7 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
426469
set deniedToken=true
427470
)
428471
if %%a == until[] (
429-
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
472+
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
430473
set /a _wloopInd2=!wloopInd2!-1
431474
set fccondition2=!printString:until[] =!
432475
for %%i in (!_wloopInd2!) do (
@@ -440,14 +483,14 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
440483
if %%a == begin[] set printString=!printString:begin[]=(!
441484
if %%a == done[] set printString=!printString:done[]=^)!
442485
if %%a == match[] (
443-
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
486+
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
444487
set matchConds[!matchInd!]=!printString:match[] =!
445488
echo set matchChecked!matchInd!=false>>!outtar!
446489
set /a matchInd+=1
447490
set deniedToken=true
448491
)
449492
if %%a == case[] (
450-
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
493+
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
451494
set /a _matchInd=!matchInd!-1
452495
for %%i in (!_matchInd!) do (
453496
(
@@ -458,13 +501,13 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
458501
set deniedToken=true
459502
)
460503
if %%a == default[] (
461-
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
504+
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
462505
set /a _matchInd=!matchInd!-1
463506
for %%i in (!_matchInd!) do echo if "^!matchChecked%%i^!" == "false" (>>!outtar!
464507
set deniedToken=true
465508
)
466509
if %%a == endcase[] (
467-
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
510+
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
468511
echo ^)>>!outtar!
469512
set deniedToken=true
470513
)
@@ -580,6 +623,17 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
580623
echo.!printString!>>!inlftar!.inline
581624
)
582625
)
626+
) else if "!methodadd!" == "true" (
627+
if !methodval! == 0 (
628+
set methodval=1
629+
echo.>!classtar!.!methodtar!.method
630+
) else (
631+
if "!fccomment!" == "true" (
632+
echo.::!printString!>>!classtar!.!methodtar!.method
633+
) else if not "!deniedToken!" == "true" (
634+
echo.!printString!>>!classtar!.!methodtar!.method
635+
)
636+
)
583637
) else (
584638
if "!fccomment!" == "true" (
585639
echo.::!printString!>>%output%.bat
@@ -590,10 +644,19 @@ for /f "tokens=* delims= " %%x in ('type %output%.fclang') do (
590644
)
591645
)
592646
if exist *.inline del /q *.inline
647+
if exist *.method del /q *.method
593648
setlocal disabledelayedexpansion
594649
if "%fcread%" == "true" type %output%.bat
595650
if not "%fccompile%" == "true" if not "%fcread%" == "true" call %output%.bat
596651
exit /b
597652
:fcversion
598-
echo FreakC DevKit Version 0.16.1 BETA
599-
exit /b
653+
echo FreakC DevKit Version 0.17.0 BETA
654+
exit /b
655+
656+
:get_len
657+
set len=0
658+
set str=%~2
659+
:loop
660+
if not "!str:~%len%!" == "" set /a len+=1 & goto loop
661+
(endlocal & set %~1=%len%)
662+
exit /b

Source/disDelayedStore.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
setlocal disableDelayedExpansion
2+
set name=%~2
3+
type %~1>%name:.method=.bat%
4+
exit /b

0 commit comments

Comments
 (0)