Repository: FreakC-Foundation/FreakC
Branch: master
Commit: c92fc604b5b6
Files: 32
Total size: 127.0 KB
Directory structure:
gitextract_natnmdy8/
├── .github/
│ ├── CODE_OF_CONDUCT.md
│ ├── CONTRIBUTING.md
│ ├── FUNDING.yml
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ └── feature_request.md
│ └── PULL_REQUEST_TEMPLATE.md
├── Examples/
│ ├── 99BottlesOfBeer.fclang
│ ├── Calculator.fclang
│ ├── Fibonacci.fclang
│ ├── FizzBuzz.fclang
│ ├── HelloWorld.fclang
│ ├── IsDivisable.fclang
│ ├── LoveTester.fclang
│ ├── OOP.fclang
│ ├── OddOrEven.fclang
│ ├── RPG.fclang
│ ├── RainbowText.fclang
│ ├── SortArray.fclang
│ ├── StoreData.fclang
│ ├── TheTruthMachine.fclang
│ └── Tictactoe.fclang
├── IDE.md
├── LICENSE.md
├── README.md
├── Source/
│ ├── FCShell.bat
│ ├── FreakC.bat
│ ├── createFile.bat
│ └── libgen.bat
├── TUTORIAL.md
└── Utilities/
└── Scripts/
├── FreakC/
│ └── freakc.tmLanguage
├── FreakC.sublime-build
└── battoexe.bat
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at nguyenphuminh09876543@gmail.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
================================================
FILE: .github/CONTRIBUTING.md
================================================
Contributing to FreakC!
======================
Thanks for your interests in FreakC, if you want to contribute to the project, please consider looking at the following notes!
## Language
We would prefer English as the main language for contributing, but you can use Vietnamese!
## Writing a Good Pull Request
- Make sure to write a rich description showing changes that you made, the upgrades on the project, what it would do, etc.
- Name your pull request nicely.
- Don't use any NSFW or weird contents in a pull request.
That's all, thanks for your time with FreakC!
================================================
FILE: .github/FUNDING.yml
================================================
# These are supported funding model platforms
BEP-20: 0x1848Ba922d6eD66D4910176998fF4fa77AEb82D5
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
**Please describe the changes this PR makes and why it should be merged:**
**Classification**
Choose one:
- [ ] This PR add changes to the codebase.
- [ ] This PR add changes to the documentations.
================================================
FILE: Examples/99BottlesOfBeer.fclang
================================================
change_title[] 99 Bottles Of Beer
var[] count=99
while[] %count% GTR 0
if[] %count% LEQ 1 (
var[] word=bottle
) el[] (
var[] word=bottles
)
print[] %count% %word% of beer on the wall
print[] %count% %word% of beer,
print[] Take one down, pass it around,
eq[] count--
if[] %count% LEQ 1 (
var[] word=bottle
) el[] (
var[] word=bottles
)
if[] %count% GTR 0 (
print[] %count% %word% of beer on the wall.
) el[] (
print[] No more %word% of beer on the wall.
)
endwhile[]
stop[] >nul
================================================
FILE: Examples/Calculator.fclang
================================================
change_title[] Calculator Made With FreakC
change_color[] 8f
change_mode[] con cols=60 lines=20
label[] menu
clrscr[]
print[] ========================================================
print[] FreakC Calculator
print[]
print[] "+" Plus
print[]
print[] "-" Minus
print[]
print[] "*" Multiply
print[]
print[] "/" Divide
print[]
print[]
print[] Enter your Math problem:
inp[] prob=
:: If you want to get the number fixed, you can replace the line below with PoopInt[fnc] ans=%prob%
scan_strs[] %%i in (' ps[] %prob% ') do var[] ans=%%i
print[] Answer: %ans%
stop[]
goto[] menu
================================================
FILE: Examples/Fibonacci.fclang
================================================
function[] func
var[] n1=0
var[] n2=1
var[] n3=0
var[] i=0
eq[] end=%~2 - 1
while[] %i% LSS %end%
eq[] n3=%n1%+%n2%
var[] n1=%n2%
var[] n2=%n3%
eq[] i++
endwhile[]
var[] %~1=%n3%
endfunc[]
func[..] "res" "5"
print[] %res%
stop[]
================================================
FILE: Examples/FizzBuzz.fclang
================================================
change_title[] FizzBuzz
eq[] count=1
while[] %count% LSS 101
eq[] fizzbuzz=%count% %% 15
eq[] fizz=%count% %% 3
eq[] buzz=%count% %% 5
if[] %fizzbuzz% == 0 (
print[] FizzBuzz
) elif[] %fizz% == 0 (
print[] Fizz
) elif[] %buzz% == 0 (
print[] Buzz
) el[] (
print[] %count%
)
eq[] count++
endwhile[]
stop[] >nul
================================================
FILE: Examples/HelloWorld.fclang
================================================
print[] Hello, World^!
stop[] >nul
================================================
FILE: Examples/IsDivisable.fclang
================================================
change_title[] Is Divisable Checker
change_color[] 0a
label[] menu
clrscr[]
print[] Dividend:
inp[] Dividend=
print[]
print[] Divisor:
inp[] Divisor=
eq[] Remainder=%Dividend% %% %Divisor%
print[]
print[]
print[]
if[] %Remainder% == 0 (
print[] It is divisable!
) el[] (
print[] It is not divisable!
)
stop[] >nul
goto[] menu
================================================
FILE: Examples/LoveTester.fclang
================================================
change_title[] Love Tester
change_color[] 0a
label[] game
clrscr[]
print[] Person 1:
inp[] person1=
print[] Person 2:
inp[] person2=
goto[] test
label[] test
eq[] test=%random% %% 100 + 0
print[] %test% percents of love
stop[]
goto[] game
================================================
FILE: Examples/OOP.fclang
================================================
function[] Dog
var[] %~1.age=%~2
var[] %~1.weight=%~3
print[] print[] %%~1>%~1.says.bat
endfunc[]
Dog[..] "Mary" "3" "4kg"
print[] Age: %Mary.age%
print[] Weight: %Mary.weight%
Mary.says[..] "Woof woof"
================================================
FILE: Examples/OddOrEven.fclang
================================================
change_title[] Odd or Even checker
clrscr[]
inp[] inp=
eq[] ans=%inp% %% 2
if[] %ans% == 0 (
print[] Is even
) el[] (
print[] Is odd
)
stop[]
inf_loop[]
================================================
FILE: Examples/RPG.fclang
================================================
change_title[] RPG DEMO
change_color[] 2f
change_mode[] con cols=70 lines=20
eq[] ehp=100
eq[] hp=100
label[] Battle
clrscr[]
if[] %ehp% LEQ 0 goto[] win
if[] %hp% LEQ 0 goto[] lose
print[]
print[]
print[]
print[] Goblin: %ehp% HP
print[] You: %hp% HP
print[]
print[]
print[]
print[]
print[] Moves:
print[]
print[] 1. Punch 2. Flee
print[]
key[] 12
if_el[] 2 goto[] Flee
if_el[] 1 goto[] Punch
label[] Punch
eq[] ehp-=20
eq[] hp-=10
goto[] Battle
label[] Flee
clrscr[]
print[] You fleed from battle!
stop[] >nul
quit[]
label[] win
print[] You win!
stop[] >nul
quit[]
label[] lose
print[] By somehow you lose, but okay...
stop[] >nul
quit[]
================================================
FILE: Examples/RainbowText.fclang
================================================
change_title[] Rainbow Text
label[] rainbowtext
change_color[] 0a
print[] Hello, World^!
change_color[] 0b
print[] Hello, World^!
change_color[] 0c
print[] Hello, World^!
change_color[] 0d
print[] Hello, World^!
change_color[] 0e
print[] Hello, World^!
change_color[] 0f
print[] Hello, World^!
goto[] rainbowtext
================================================
FILE: Examples/SortArray.fclang
================================================
inp[] n=The amount of element:
loop[] %%i in (1,1,%n%) do inp[] arr[%%i]=Element %%i:
enb_delay[]
loop[] %%i in (1,1,%n%) do (
eq[] ind=%%i+1
loop[] %%j in (^!ind^!,1,%n%) do (
if[] ^!arr[%%i]^! GTR ^!arr[%%j]^! (
var[] temp=^!arr[%%i]^!
var[] arr[%%i]=^!arr[%%j]^!
var[] arr[%%j]=^!temp^!
)
)
)
print[] Sorted:
loop[] %%i IN (1,1,%n%) DO print[] Element %%i: ^!arr[%%i]^!
================================================
FILE: Examples/StoreData.fclang
================================================
print[] Example>>data.txt
================================================
FILE: Examples/TheTruthMachine.fclang
================================================
change_title[] The truth machine
inp[] inp=
if[] %inp% == 0 (
print[] 0
) el[] if[] %inp% == 1 (
label[] loop
print[] %inp%
goto[] loop
)
inf_loop[]
================================================
FILE: Examples/Tictactoe.fclang
================================================
change_title[] TicTacToe
change_color[] e4
change_mode[] con cols=70 lines=20
label[] tictactoe
clrscr[]
var[] a1=1
var[] a2=2
var[] a3=3
var[] a4=4
var[] a5=5
var[] a6=6
var[] a7=7
var[] a8=8
var[] a9=9
var[] s1=A
var[] s2=A
var[] s3=A
var[] s4=A
var[] s5=A
var[] s6=A
var[] s7=A
var[] s8=A
var[] s9=A
var[] attack=0
var[] cycle=0
var[] moves=0
label[] Start
clrscr[]
print[] *******
print[] *%a1% %a2% %a3%*
print[] *%a4% %a5% %a6%*
print[] *%a7% %a8% %a9%*
print[] *******
print[] Enter a number:
key[] 123456789
if_el[] 9 goto[] d9
if_el[] 8 goto[] d8
if_el[] 7 goto[] d7
if_el[] 6 goto[] d6
if_el[] 5 goto[] d5
if_el[] 4 goto[] d4
if_el[] 3 goto[] d3
if_el[] 2 goto[] d2
if_el[] 1 goto[] d1
goto[] Start
label[] d1
if[] %s1% EQU N goto[] Start
var[] a1=X
var[] s1=N
eq[] moves=%moves%+1
goto[] check
label[] d2
if[] %s2% EQU N goto[] Start
var[] a2=X
var[] s2=N
eq[] moves=%moves%+1
goto[] check
label[] d3
if[] %s3% EQU N goto[] Start
var[] a3=X
var[] s3=N
eq[] moves=%moves%+1
goto[] check
label[] d4
if[] %s4% EQU N goto[] Start
var[] a4=X
var[] s4=N
eq[] moves=%moves%+1
goto[] check
label[] d5
if[] %s5% EQU N goto[] Start
var[] a5=X
var[] s5=N
eq[] moves=%moves%+1
goto[] check
label[] d6
if[] %s6% EQU N goto[] Start
var[] a6=X
var[] s6=N
eq[] moves=%moves%+1
goto[] check
label[] d7
if[] %s7% EQU N goto[] Start
var[] a7=X
var[] s7=N
eq[] moves=%moves%+1
goto[] check
label[] d8
if[] %s8% EQU N goto[] Start
var[] a8=X
var[] s8=N
eq[] moves=%moves%+1
goto[] check
label[] d9
if[] %s9% EQU N goto[] Start
var[] a9=X
var[] s9=N
eq[] moves=%moves%+1
goto[] check
label[] check
if[] %a1%+%a2%+%a3% EQU X+X+X goto[] win
if[] %a4%+%a5%+%a6% EQU X+X+X goto[] win
if[] %a7%+%a8%+%a9% EQU X+X+X goto[] win
if[] %a1%+%a4%+%a7% EQU X+X+X goto[] win
if[] %a2%+%a5%+%a8% EQU X+X+X goto[] win
if[] %a3%+%a6%+%a9% EQU X+X+X goto[] win
if[] %a1%+%a5%+%a9% EQU X+X+X goto[] win
if[] %a3%+%a5%+%a7% EQU X+X+X goto[] win
if[] %moves% EQU 9 goto[] draw
goto[] middle
label[] middle
if[] %s5% EQU N goto[] mon
var[] a5=O
var[] s5=N
eq[] moves=%moves%+1
goto[] moncheck
label[] mon
if[] %moves% GEQ 1 goto[] Offence
if[] %moves% EQU 9 goto[] draw
label[] Offence
if[] %a1%+%a2%+%a3% EQU O+O+3 goto[] a3set
if[] %a1%+%a2%+%a3% EQU 1+O+O goto[] a1set
if[] %a1%+%a2%+%a3% EQU O+2+O goto[] a2set
if[] %a4%+%a5%+%a6% EQU O+O+6 goto[] a6set
if[] %a4%+%a5%+%a6% EQU O+5+O goto[] a5set
if[] %a4%+%a5%+%a6% EQU 4+O+O goto[] a4set
if[] %a7%+%a8%+%a9% EQU O+O+9 goto[] a9set
if[] %a7%+%a8%+%a9% EQU 7+O+O goto[] a7set
if[] %a7%+%a8%+%a9% EQU O+8+O goto[] a8set
if[] %a1%+%a4%+%a7% EQU 1+O+O goto[] a1set
if[] %a1%+%a4%+%a7% EQU O+4+O goto[] a4set
if[] %a1%+%a4%+%a7% EQU O+O+7 goto[] a7set
if[] %a2%+%a5%+%a8% EQU 2+O+O goto[] a2set
if[] %a2%+%a5%+%a8% EQU O+5+O goto[] a5set
if[] %a2%+%a5%+%a8% EQU O+O+8 goto[] a8set
if[] %a3%+%a6%+%a9% EQU O+O+9 goto[] a9set
if[] %a3%+%a6%+%a9% EQU 3+O+O goto[] a3set
if[] %a3%+%a6%+%a9% EQU O+6+O goto[] a6set
if[] %a1%+%a5%+%a9% EQU O+5+O goto[] a5set
if[] %a1%+%a5%+%a9% EQU O+O+9 goto[] a9set
if[] %a1%+%a5%+%a9% EQU 1+O+O goto[] a1set
if[] %a3%+%a5%+%a7% EQU O+O+7 goto[] a7set
if[] %a3%+%a5%+%a7% EQU O+5+O goto[] a5set
if[] %a3%+%a5%+%a7% EQU 3+O+O goto[] a3set
goto[] Defence
label[] Defence
if[] %a1%+%a2%+%a3% EQU X+X+3 goto[] a3set
if[] %a1%+%a2%+%a3% EQU 1+X+X goto[] a1set
if[] %a1%+%a2%+%a3% EQU X+2+X goto[] a2set
if[] %a4%+%a5%+%a6% EQU X+X+6 goto[] a6set
if[] %a4%+%a5%+%a6% EQU X+5+X goto[] a5set
if[] %a4%+%a5%+%a6% EQU 4+X+X goto[] a4set
if[] %a7%+%a8%+%a9% EQU X+X+9 goto[] a9set
if[] %a7%+%a8%+%a9% EQU 7+X+X goto[] a7set
if[] %a7%+%a8%+%a9% EQU X+8+X goto[] a8set
if[] %a1%+%a4%+%a7% EQU 1+X+X goto[] a1set
if[] %a1%+%a4%+%a7% EQU X+4+X goto[] a4set
if[] %a1%+%a4%+%a7% EQU X+X+7 goto[] a7set
if[] %a2%+%a5%+%a8% EQU 2+X+X goto[] a2set
if[] %a2%+%a5%+%a8% EQU X+5+X goto[] a5set
if[] %a2%+%a5%+%a8% EQU X+X+8 goto[] a8set
if[] %a3%+%a6%+%a9% EQU X+X+9 goto[] a9set
if[] %a3%+%a6%+%a9% EQU 3+X+X goto[] a3set
if[] %a3%+%a6%+%a9% EQU X+6+X goto[] a6set
if[] %a1%+%a5%+%a9% EQU X+5+X goto[] a5set
if[] %a1%+%a5%+%a9% EQU X+X+9 goto[] a9set
if[] %a1%+%a5%+%a9% EQU 1+X+X goto[] a1set
if[] %a3%+%a5%+%a7% EQU X+X+7 goto[] a7set
if[] %a3%+%a5%+%a7% EQU X+5+X goto[] a5set
if[] %a3%+%a5%+%a7% EQU 3+X+X goto[] a3set
goto[] Random
label[] Random
eq[] attack=%Random% * 9 / 32768 +1
eq[] cycle=%cycle%+1
if[] %cycle% LEQ 1 goto[] Random
if[] %attack% EQU 1 goto[] a1set
if[] %attack% EQU 2 goto[] a2set
if[] %attack% EQU 3 goto[] a3set
if[] %attack% EQU 4 goto[] a4set
if[] %attack% EQU 5 goto[] a5set
if[] %attack% EQU 6 goto[] a6set
if[] %attack% EQU 7 goto[] a7set
if[] %attack% EQU 8 goto[] a8set
if[] %attack% EQU 9 goto[] a9set
goto[] Random
label[] a1set
if[] %s1% EQU N goto[] Random
var[] a1=O
var[] s1=N
eq[] moves=%moves%+1
goto[] moncheck
label[] a2set
if[] %s2% EQU N goto[] Random
var[] a2=O
var[] s2=N
eq[] moves=%moves%+1
goto[] moncheck
label[] a3set
if[] %s3% EQU N goto[] Random
var[] a3=O
var[] s3=N
eq[] moves=%moves%+1
goto[] moncheck
label[] a4set
if[] %s4% EQU N goto[] Random
var[] a4=O
var[] s4=N
eq[] moves=%moves%+1
goto[] moncheck
label[] a5set
if[] %s5% EQU N goto[] Random
var[] a5=O
var[] s5=N
eq[] moves=%moves%+1
goto[] moncheck
label[] a6set
if[] %s6% EQU N goto[] Random
var[] a6=O
var[] s6=N
eq[] moves=%moves%+1
goto[] moncheck
label[] a7set
if[] %s7% EQU N goto[] Random
var[] a7=O
var[] s7=N
eq[] moves=%moves%+1
goto[] moncheck
label[] a8set
if[] %s8% EQU N goto[] Random
var[] a8=O
var[] s8=N
eq[] moves=%moves%+1
goto[] moncheck
label[] a9set
if[] %s9% EQU N goto[] Random
var[] a9=O
var[] s9=N
eq[] moves=%moves%+1
goto[] moncheck
label[] moncheck
if[] %a1%+%a2%+%a3% EQU O+O+O goto[] lose
if[] %a4%+%a5%+%a6% EQU O+O+O goto[] lose
if[] %a7%+%a8%+%a9% EQU O+O+O goto[] lose
if[] %a1%+%a4%+%a7% EQU O+O+O goto[] lose
if[] %a2%+%a5%+%a8% EQU O+O+O goto[] lose
if[] %a3%+%a6%+%a9% EQU O+O+O goto[] lose
if[] %a1%+%a5%+%a9% EQU O+O+O goto[] lose
if[] %a3%+%a5%+%a7% EQU O+O+O goto[] lose
if[] %moves% EQU 9 goto[] draw
goto[] Start
label[] win
clrscr[]
print[] You win!
stop[] >nul
goto[] tictactoe
label[] lose
clrscr[]
print[] You lose!
stop[] >nul
goto[] tictactoe
label[] draw
clrscr[]
print[] Draw!
stop[] >nul
goto[] tictactoe
================================================
FILE: IDE.md
================================================
An experimental programming language
## Sublime text 3
In "[FreakC/Utilities/Scripts](Utilities/Scripts)" there is a file called "[FreakC.sublime-build](Utilities/Scripts/FreakC.sublime-build)" which is the Sublime Text's build system for FreakC. To use it, please paste it in the "%APPDATA%\Sublime Text v\Packages\User" or wherever your Packages folder is. Then, make sure that you have set the environment variable for FreakC. After that, you will be able to compile FreakC codes in Sublime Text.
For syntax highlighting, copy the "FreakC" folder in the same folder, then paste it in "%APPDATA%\Sublime Text v\Packages\".
## Note
Support for VSCode had been discontinued since we recreated the whole language. However, supports for Sublime Text is still being developed, so Sublime is probably the go-to editor for FreakC.
================================================
FILE: LICENSE.md
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: README.md
================================================
An experimental programming language
## Note
I have taken a little break from FreakC and Batch coding as a whole, I might do a rewrite for FreakC in the future when I'm free.
Other than that, I'm working on JeChain, check it out if you are interested!
## What is FreakC ?
`print[] Hello, World.`
FreakC is a nice, little, multi-paradigm programming language, which looks like Batch, compiles to Batch and is written in Batch as well. It is mainly built to be an experimental project with the idea of creating a programming language in such a limited language like Batch, but then it turns out that FreakC has added a little bit of features to Batch that might come in handy for some Batch developers. Batch's commands should work with FreakC most of the time, however, there are some quirks you should consider checking out which I have mentioned in the next part of this document.
And yes, this is not a C dialect, it's more like `C` in `ArnoldC`.
### Language preview
Hello World:
print[] Hello, World!
Function definition:
function[] SayHello
print[] Hello
endfunc[]
:: Calling "SayHello" function, printing out "Hello"
SayHello[..]
:: This will also work, because Batch's commands work in FreakC:
call SayHello
Class-based object-oriented programming:
:: Create a class called "Dog"
class[] Dog
:: Init method
method[] init
var[] $this.age=%~2
var[] $this.weight=%~3
endmethod[]
method[] BeingCute
print[] *Being cute*
endmethod[]
endclass[]
FreakC's commands end with `[]` or a special operator to indicate that it's FreakC code, so it doesn't cause confusion with Batch codes in your code.
[More samples](https://github.com/FreakC-Foundation/FreakC/tree/master/Examples)
[Join the small community on Discord!!!](https://discord.gg/eNwqK4APsD)
### Switching from Batch to FreakC
While FreakC is compatible with Batch, but it's not 100% compatible, you just need to replace all `!` with `^!`, `^^!` with `^^^^^!` (the second one is only required in enabled delayed expansion). If you use codes that depends on blank lines, then just change them to the `!` character to create a blank line entirely, or just use Batch's `^`.
### FreakC's added features compared to Batch
* While loops, repeat-until loops, and FreakC's own for loops with break/continue supports.
* Switch cases.
* Class-based OOP.
* A bunch of utility functions for you to use.
* Inline functions.
* Macros.
* Some minimal operators.
* Floating-point numbers.
* Some additional commands.
There are still more! [Get started now!](https://github.com/FreakC-Foundation/FreakC/blob/master/TUTORIAL.md)
### Stuffs you would expect from a scripting language
* Multi-paradigm (procedural, object-oriented, data-oriented...).
* General purpose.
* Dynamically typed.
* Short, simple, packed with utility functions to help coding easier.
* Easy to set up and use since it's written in Batch, you can just download the compiler and start coding.
* Extremely light compiler which weighs less than 40kb!
### Should you use FreakC?
* As a Batch developer: Sure, but be aware that this project is still in BETA, and hasn't reached 1.0.
* As a open-source developer: You can 100% use my code for your project, but please follow the conditions from Apache-2.0 License, and at least credit me in the README.
* As a beginner to programming: No, just no, Batch and FreakC are things created by dark magic.
* AS a real deal programmer: No, Batch and FreakC are slow and weird, their community is small, and there are not much good frameworks out there.
### Todos
* Concurrent model.
* More utility functions.
* Nicer inheritance and polymorphism for OOP.
## What comes with the devkit ?
* A compiler.
* A command line shell.
* A command line interface.
* Some utilities.
* Some examples.
## Language resources
* [Tutorials](https://github.com/FreakC-Foundation/FreakC/blob/master/TUTORIAL.md)
* [Samples](https://github.com/FreakC-Foundation/FreakC/tree/master/Examples)
* [IDEs](IDE.md)
## Frameworks and libraries
### Official FreakC's frameworks
* discord.fclang - A discord api wrapper built on top of Discord.net, can be used for bot dev.
### Cool Batch frameworks/libraries
* Number.cmd - A library for evaluating floating point number.
* Discord.bat - A discord api wrapper built on top of Discord.net, can be used for bot dev.
### Batch game frameworks
There are many existing game engines for Batch/FreakC:
* Berry
* Corpse
* Shade
* Seta
## Contribute
We would love to have you as a contributor! Please consider checking out [contribution guidelines](https://github.com/FreakC-Foundation/FreakC/blob/master/.github/CONTRIBUTING.md) first!
## Support the project!
If you like FreakC, it would be great if you leave a star here ❤️. I'd love if you follow me as well 😘.
To push the project's development faster, I'd love if you buy me a coffee by sending me some cryptos into my BEP-20 wallet: `0x1848Ba922d6eD66D4910176998fF4fa77AEb82D5`
### Sponsors
* Top sponsor: @anapple96
## Resources
* Facebook
* Discord
* Offical Website
## Languages based on FreakC
I've created this tiny language for Vietnamese using the FreakC's codebase:
* VNC
## Contributors
* Owner/Developer: @nguyenphuminh.
* VSCode contributor: @anapple96.
## Repo's contributors
## Copyrights and License
Copyright © 2020-2021 Nguyen Phu Minh published under the Apache 2.0 License
================================================
FILE: Source/FCShell.bat
================================================
@echo off
echo.>tar.fclang
echo. FreakC's interactive shell
echo. ==========================
echo. Version 0.1.0
echo.
echo.
:loop
set /p inp=
if "%inp%" == "start[]" (
start freakc tar.fclang
) else if "%inp%" == "endcli[]" (
del /q tar.fclang
if exist tar.bat del /q tar.bat
exit /b
) else if "%inp%" == "wipe[]" (
echo.>tar.fclang
) else if "%inp%" == "clr[]" (
cls
) else (
echo %inp%>>tar.fclang
)
goto loop
================================================
FILE: Source/FreakC.bat
================================================
@echo off
setlocal enabledelayedexpansion
::------------------------------------------------------------------------------
:: Init macros
::------------------------------------------------------------------------------
:: New line
set NLM=^
set NL=^^^%NLM%%NLM%^%NLM%%NLM%
set LF=^^%NL%
::------------------------------------------------------------------------------
:: Command line interface
::------------------------------------------------------------------------------
set helpCheck=false
if "%1" == "" (
set helpCheck=true
set pauseAcp=true
)
if "%1" == "--help" set helpCheck=true
if "%helpCheck%" == "true" (
echo. Usage: freakc {option/name} {option}
echo.
echo. Options:
echo.
echo. --help :Have to be the first parameter, shows all options
echo. --shell :Have to be the first parameter, open shell.
echo. --version :Have to be the first parameter, shows the current version of the DevKit.
echo. --compile :Have to be the second parameter, compile the file only.
echo. --candr :Have to be the second parameter, compile and shows compiled code.
echo. --create :Have to be the second parameter, create a new FreakC project.
echo. --clrlib :Have to be the first parameter, delete all standard libraries in the folder.
echo. --clrbat :Have to be the first parameter, delete all Batch files in the folder.
echo. --keep :Have to be the first parameter, keep all the .inline files and .method files.
echo.
echo. [Leave the second {option} blank if you want to both compile and run the file]
if "%pauseAcp%" == "true" pause >nul
exit /b
)
if "%1" == "--version" goto fcversion
if "%2" == "--compile" set fccompile=true
if "%2" == "--candr" set fcread=true
if "%2" == "--create" set fccreate=true
if "%2" == "--keep" (
set keepmethod=true
set keepinline=true
set fccompile=true
)
if "%1" == "--shell" (
FCShell
exit /b
)
if "%1" == "--clrlib" (
for /r %%i in (*.bat) do (
set name=%%i
if "!name:fclib=!" NEQ "!name!" del /q %%i
)
exit /b
)
if "%1" == "--clrbat" (
for /r %%i in (*.bat) do (
set name=%%i
set clearCheck=false
if "!name:FreakC.bat=!" NEQ "!name!" set clearCheck=true
if "!name:FCShell.bat=!" NEQ "!name!" set clearCheck=true
if "!name:createFile.bat=!" NEQ "!name!" set clearCheck=true
if "!name:libgen.bat=!" NEQ "!name!" set clearCheck=true
if "!clearCheck!" == "false" del /q %%i
)
exit /b
)
if "%fccreate%" == "true" (
md %output%
cd %output%
if "%3" == "--empty" (
if "%4" == "--de-enabled" echo enb_delay[]>%output%.fclang
echo.>>%output%.fclang
) else (
if "%3" == "--de-enabled" echo enb_delay[]>%output%.fclang
echo print[] Hello World, Hello FreakC^^!>>%output%.fclang
)
exit /b
)
::------------------------------------------------------------------------------
:: Compiling
::------------------------------------------------------------------------------
:: Get the input file
set fccompilename=%1
set output=%fccompilename:.fclang=%
:: Config
set fccomment=false
set proctar=something
set inlftar=something
set classtar=something
set methodtar=something
set fchcomment=false
set /a wloopnum=0, wloopnum2=0, matchInd=0, forInd=0, wloopInd=0, wloopInd2=0, prevLoopInd=0
:: Pre-stored codes
echo @echo off>%output%.bat
if "%2" == "--de-enabled" echo setlocal enabledelayedexpansion>>%output%.bat
if "%3" == "--de-enabled" echo setlocal enabledelayedexpansion>>%output%.bat
echo :FreakCCompiled>>%output%.bat
:: Reading through each lines
for /f "tokens=* delims= " %%x in (%output%.fclang) do (
set deniedToken=false
set printString=%%x
for %%a in (%%x) do (
set ch=%%a
if "!ch:~-4!" == "[..]" (
set ch=!ch:[..]=!
for %%i in (!ch!) do set printString=!printString:%%a=call %%i!
)
if "!ch:~-4!" == "[::]" (
set ch=!ch:[::]=!
for %%i in (!ch!) do set printString=!printString:%%a=call :%%i!
)
if "%%a" == "c[]" (
set fccomment=true
set printString=!printString:c[]=!
)
if "%%a" == "e[]" (
set fccomment=false
set printString=!printString:e[]=!
)
if "%%a" == "h[]" set deniedToken=true
if "%%a" == "ch[]" set fchcomment=true
if "%%a" == "ce[]" (
set fchcomment=false
set deniedToken=true
)
if %%a == include[] (
set targetFile=!printString:include[] =!
if exist !targetFile!.fclang (
call createFile.bat "!targetFile!"
type !targetFile!.bat>>%output%.bat
)
set deniedToken=true
)
if %%a == compile[] (
set targetFile=!printString:compile[] =!
if exist !targetFile!.fclang call createFile.bat "!targetFile!"
set deniedToken=true
)
if %%a == get_utils[] (
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
(
echo.set NLM=^^
echo.
echo.
echo.set NL=^^^^^^%%NLM%%%%NLM%%^^%%NLM%%%%NLM%%
echo.set LF=^^^^%%NL%%
)>>!outtar!
set deniedToken=true
)
if %%a == end[] set printString=!printString:end[]=exit /b 0!
if %%a == gen_lib_func[] (
call libgen !printString:gen_lib_func[] =!
set deniedToken=true
)
if %%a == function[] (
set procval=0
set procadd=true
set proctar=!printString:function[] =!
set deniedToken=true
)
if %%a == endfunc[] (
set procadd=false
set proctar=none
set deniedToken=true
)
if %%a == inlinef[] (
set inlfval=0
set inlfadd=true
set inlftar=!printString:inlinef[] =!
set deniedToken=true
)
if %%a == endinlf[] (
set inlfadd=false
set inlftar=none
set deniedToken=true
)
if %%a == class[] (
set classval=0
set classadd=true
set classtar=!printString:class[] =!
set deniedToken=true
)
if %%a == endclass[] (
set classadd=false
set classtar=none
set deniedToken=true
)
if %%a == method[] (
set methodval=0
set methodadd=true
set methodtar=!printString:method[] =!
set deniedToken=true
)
if %%a == endmethod[] (
set methodadd=false
set methodtar=none
set deniedToken=true
)
if %%a == new[] (
set cprocess=!printString:new[] =!
set turn=0
for %%i in (!cprocess!) do (
if !turn! == 0 set target=%%i
if !turn! == 1 set objname=%%i
set /a turn+=1
)
for /r %%i in (*.method) do (
set name=%%i
set name=!name:%cd%\=!
set _name=!name:.method=.bat!
call :get_len len !target!
for %%j in (!len!) do if "!name:~0,%%j!" == "!target!" (
for /f "delims=" %%n in ('find /c /v "" !name!') do set "slen=%%n"
set "slen=!slen:*: =!"
echo.>!objname!!_name:~%%j!
<"!name!" (
for /L %%c in (1 1 !slen!) do (
set /p line=
if "!line!" NEQ "" for %%v in (!objname!) do (
if "!line:$this=!" NEQ "!line!" (
echo !line:$this=%%v!>>!objname!!_name:~%%j!
) else echo.!line!>>!objname!!_name:~%%j!
)
set line=
)
)
)
)
if exist !objname!.init.bat (
for %%i in (!target!) do for %%j in (!objname!) do set printString=!printString:new[] %%i =call %%j.init.bat !
) else set deniedToken=true
)
if %%a == extends[] (
set target=!printString:extends[] =!
for /r %%i in (*.method) do (
set name=%%i
set name=!name:%cd%\=!
call :get_len len !target!
for %%j in (!len!) do if "!name:~0,%%j!" == "!target!" (
for /f "delims=" %%n in ('find /c /v "" !name!') do set "slen=%%n"
set "slen=!slen:*: =!"
<"!name!" (
for /L %%c in (1 1 !slen!) do (
set /p line=
if "!line!" NEQ "" for %%v in (!classtar!) do echo.!line!>>!classtar!!name:~%%j!
set line=
)
)
)
)
set deniedToken=true
)
set icall=false
if "!ch:~-4!" == "[//]" (
set icall=true
set iprocess=!printString:[//]=!
)
if %%a == icall[] (
set icall=true
set iprocess=!printString:icall[] =!
)
if "!icall!" == "true" (
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
set deniedToken=true
set turn=0
for %%i in (!iprocess!) do (
if !turn! LEQ 0 (
set inltar=%%i
) else set inlargs[!turn!]=%%i
set /a turn+=1
)
set /a turn-=1
for /f "delims=" %%n in ('find /c /v "" !inltar!.inline') do set "len=%%n"
set "len=!len:*: =!"
<"!inltar!.inline" (
for /L %%c in (1 1 !len!) do (
set /p line=
if !turn! == 0 (
echo.!line!>>!outtar!
) else (
for /l %%z in (1 1 !turn!) do for %%v in (!inlargs[%%z]!) do if %%c GEQ 2 set line=!line:%%z[]=%%v!
echo.!line!>>!outtar!
)
)
)
)
if "!ch:~-2!" == "[]" (
call :get_len chlen !ch!
set /a chlen-=2
for %%i in (!chlen!) do set chl=!ch:~0,%%i!
for %%i in (!ch!) do (
if "!ch:~0,7!" == "string_" (
call libgen string !chl:~7!
for %%j in (!chl:~7!) do set printString=!printString:%%i=call fclib_string_%%j.bat!
)
if "!ch:~0,5!" == "math_" (
call libgen math !chl:~5!
for %%j in (!chl:~5!) do set printString=!printString:%%i=call fclib_math_%%j.bat!
)
if "!ch:~0,4!" == "arr_" (
call libgen array !chl:~4!
for %%j in (!chl:~4!) do set printString=!printString:%%i=call fclib_array_%%j.bat!
)
)
)
if %%a == max[] (
call libgen list max
set printString=!printString:max[]=call fclib_list_max.bat!
)
if %%a == min[] (
call libgen list min
set printString=!printString:min[]=call fclib_list_min.bat!
)
if %%a == sum[] (
call libgen list sum
set printString=!printString:sum[]=call fclib_list_sum.bat!
)
if %%a == deny[] (
echo.>%output%.bat
set deniedToken=true
)
if %%a == drive[] set printString=!printString:drive[] =!:
if %%a == while[] (
set prevLoop[!prevLoopInd!]=while
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
set fccondition=!printString:while[] =!
set fcpos[!wloopInd!]=!wloopnum!
for %%i in (!wloopInd!) do (
(
echo :WhileLoop!fcpos[%%i]!
echo if not !fccondition! goto EndLoop!fcpos[%%i]!
)>>!outtar!
)
set /a wloopnum+=1
set /a wloopInd+=1
set /a prevLoopInd+=1
set deniedToken=true
)
if %%a == for[] (
set prevLoop[!prevLoopInd!]=for
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
set process=!printString:for[] =!
for /f "tokens=1-4 delims= " %%i in ("!process!") do (
set varname[!forInd!]=%%i
set start[!forInd!]=%%j
set step[!forInd!]=%%k
set end[!forInd!]=%%l
)
set fcpos[!wloopInd!]=!wloopnum!
for %%i in (!wloopInd!) do (
for %%s in (!forInd!) do (
(
echo set !varname[%%s]!=!start[%%s]!
echo :WhileLoop!fcpos[%%i]!
echo if ^^!!varname[%%s]!^^! GEQ !end[%%s]! goto EndLoop!fcpos[%%i]!
)>>!outtar!
)
)
set /a wloopnum+=1, wloopInd+=1, forInd+=1, prevLoopInd+=1
set deniedToken=true
)
set whileCheck=false
set acceptFor=false
if %%a == endfor[] (
set whileCheck=true
set acceptFor=true
)
if %%a == endwhile[] set whileCheck=true
if "!whileCheck!" == "true" (
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
set /a _wloopInd=!wloopInd!-1
for %%i in (!_wloopInd!) do (
if "!acceptFor!" == "true" (
set /a forInd-=1
for %%s in (!forInd!) do echo set /a !varname[%%s]!+=!step[%%s]!>>!outtar!
)
echo goto WhileLoop!fcpos[%%i]!>>!outtar!
echo :EndLoop!fcpos[%%i]!>>!outtar!
)
set /a wloopInd-=1
set deniedToken=true
)
if %%a == breakl[] (
set /a _wloopInd=!wloopInd!-1
set /a _wloopInd2=!wloopInd2!-1
set /a prevLoopInd-=1
for %%i in (!prevLoopInd!) do (
if "!prevLoop[%%i]!" == "for" for %%y in (!_wloopInd!) do for %%s in (!fcpos[%%y]!) do set printString=!printString:breakl[]=goto EndLoop%%s!
if "!prevLoop[%%i]!" == "while" for %%y in (!_wloopInd!) do for %%s in (!fcpos[%%y]!) do set printString=!printString:breakl[]=goto EndLoop%%s!
if "!prevLoop[%%i]!" == "repeat" for %%y in (!_wloopInd2!) do for %%s in (!fcpos2[%%y]!) do set printString=!printString:breakl[]=goto UntilLoop%%s!
)
)
if %%a == continue[] (
set /a _forInd=!forInd!-1
set /a _wloopInd=!wloopInd!-1
set /a _wloopInd2=!wloopInd2!-1
set /a prevLoopInd-=1
for %%i in (!prevLoopInd!) do (
if "!prevLoop[%%i]!" == "for" for %%y in (!_wloopInd!) do for %%s in (!fcpos[%%y]!) do for %%k in (!_forInd!) do for %%q in (!varname[%%k]!) do for %%z in (!step[%%k]!) do set printString=!printString:continue[]=set /a %%q+=%%z ^& goto WhileLoop%%s!
if "!prevLoop[%%i]!" == "while" for %%y in (!_wloopInd!) do for %%s in (!fcpos[%%y]!) do set printString=!printString:continue[]=goto WhileLoop%%s!
if "!prevLoop[%%i]!" == "repeat" for %%y in (!_wloopInd2!) do for %%s in (!fcpos2[%%y]!) do set printString=!printString:continue[]=goto RepeatLoop%%s!
)
)
if %%a == repeat[] (
set prevLoop[!prevLoopInd!]=repeat
set prevLoop=repeat
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
set fcpos2[!wloopInd2!]=!wloopnum2!
for %%i in (!wloopInd2!) do echo :RepeatLoop!fcpos2[%%i]!>>!outtar!
set /a wloopnum2+=1
set /a prevLoopInd+=1
set /a wloopInd2+=1
set deniedToken=true
)
if %%a == until[] (
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
set /a _wloopInd2=!wloopInd2!-1
set fccondition2=!printString:until[] =!
for %%i in (!_wloopInd2!) do (
(
echo if !fccondition2! goto UntilLoop!fcpos2[%%i]!
echo goto RepeatLoop!fcpos2[%%i]!
echo :UntilLoop!fcpos2[%%i]!
)>>!outtar!
)
set /a wloopInd2-=1
set deniedToken=true
)
if %%a == begin[] set printString=!printString:begin[]=(!
if %%a == done[] set printString=!printString:done[]=^)!
if %%a == match[] (
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
set matchConds[!matchInd!]=!printString:match[] =!
echo set matchChecked!matchInd!=false>>!outtar!
set /a matchInd+=1
set deniedToken=true
)
if %%a == case[] (
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
set /a _matchInd=!matchInd!-1
for %%i in (!_matchInd!) do (
(
echo if !matchConds[%%i]! == !printString:case[] =! (
echo set matchChecked%%i=true
)>>!outtar!
)
set deniedToken=true
)
if %%a == default[] (
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
set /a _matchInd=!matchInd!-1
for %%i in (!_matchInd!) do echo if "^!matchChecked%%i^!" == "false" (>>!outtar!
set deniedToken=true
)
if %%a == endcase[] (
if "!procadd!" == "true" (set outtar=!proctar!.bat) else if "!inlfadd!" == "true" (set outtar=!inlftar!.inline) else (set outtar=%output%.bat)
echo ^)>>!outtar!
set deniedToken=true
)
if %%a == endmatch[] (
set deniedToken=true
set /a matchInd-=1
)
if %%a == key[] set printString=!printString:key[] =CHOICE /C:! /N
if %%a == uprint[] set printString=!printString:uprint[]=echo!
if %%a == print[] set printString=!printString:print[] =echo.!
if %%a == fprint[] set printString=!printString:fprint[] =echo:!
if %%a == create_dir[] set printString=!printString:create_dir[]=md!
if %%a == change_dir[] set printString=!printString:change_dir[]=cd!
if %%a == del[] set printString=!printString:del[]=del!
if %%a == remove_dir[] set printString=!printString:remove_dir[]=rmdir!
if %%a == read_file[] set printString=!printString:read_file[]=type!
if %%a == int[] (
set printString=!printString:int[]=set /a!
set printString=!printString:++=+=1!
set printString=!printString:--=-=1!
)
if %%a == eq[] (
set printString=!printString:eq[]=set /a!
set printString=!printString:++=+=1!
set printString=!printString:--=-=1!
)
if %%a == define[] (
set !printString:define[]=!
set deniedToken=true
)
if %%a == logoff[] set printString=!printString:logoff[]=SHUTDOWN /l!
if %%a == hibernate_shutdown[] set printString=!printString:hibernate_shutdown[]=SHUTDOWN /h!
if %%a == float[] (
call libgen float float
set printString=!printString:float[]=call fclib_float.bat!
)
if %%a == var[] set printString=!printString:var[]=set!
if %%a == cnd[] (
call libgen util cnd
set printString=!printString:cnd[]=call fclib_util_cnd.bat!
)
if %%a == inp[] set printString=!printString:inp[]=set /p!
if %%a == goto[] set printString=!printString:goto[]=goto!
if %%a == call[] set printString=!printString:call[]=call!
if %%a == lcall[] set printString=!printString:lcall[] =call :!
if %%a == change_color[] set printString=!printString:change_color[]=color!
if %%a == change_mode[] set printString=!printString:change_mode[]=mode!
if %%a == change_title[] set printString=!printString:change_title[]=title!
if %%a == rename[] set printString=!printString:rename[]=ren!
if %%a == mov[] set printString=!printString:mov[]=move!
if %%a == copy[] set printString=!printString:copy[]=copy!
if %%a == open[] set printString=!printString:open[]=start!
if %%a == quit[] set printString=!printString:quit[]=exit!
if %%a == inf_loop[] set printString=!printString:inf_loop[]=goto FreakCCompiled!
if %%a == imd_shutdown[] set printString=!printString:imd_shutdown[]=shutdown -s -t 0!
if %%a == imd_restart[] set printString=!printString:imd_restart[]=shutdown -r -t 0!
if %%a == clrscr[] set printString=!printString:clrscr[]=cls!
if %%a == restart_after[] set printString=!printString:restart_after[]=shutdown -r -t!
if %%a == shutdown_after[] set printString=!printString:shutdown_after[]=shutdown -s -t!
if %%a == imd_shutdowns[] set printString=!printString:imd_shutdowns[]=SHUTDOWN /p!
if %%a == stop[] set printString=!printString:stop[]=pause!
if %%a == local[] set printString=!printString:local[]=SETLOCAL!
if %%a == endloc[] set printString=!printString:endloc[]=ENDLOCAL!
if %%a == see_date[] set printString=!printString:see_date[]=date /t!
if %%a == see_time[] set printString=!printString:see_time[]=time /t!
if %%a == change_date[] set printString=!printString:change_date[]=date!
if %%a == change_time[] set printString=!printString:change_time[]=time!
if %%a == ls[] set printString=!printString:ls[]=dir!
if %%a == if[] set printString=!printString:if[]=if!
if %%a == if_el[] set printString=!printString:if_el[]=if errorlevel!
if %%a == if_not_el[] set printString=!printString:if_not_el[]=if not errorlevel!
if %%a == if_not[] set printString=!printString:if_not[]=if not!
if %%a == if_defined[] set printString=!printString:if_defined[]=if defined!
if %%a == if_exist[] set printString=!printString:if_exist[]=if exist!
if %%a == if_not_exist[] set printString=!printString:if_not_exist[]=if not exist!
if %%a == if_not_defined[] set printString=!printString:if_not_defined[]=if not defined!
if %%a == el[] set printString=!printString:el[]=else!
if %%a == elif[] set printString=!printString:elif[]=else if!
if %%a == label[] set printString=!printString:label[] =:!
if %%a == wait[] set printString=!printString:wait[]=timeout /nobreak /t!
if %%a == loop[] set printString=!printString:loop[]=for /l!
if %%a == scan_files[] set printString=!printString:scan_files[]=for /r!
if %%a == scan_strs[] set printString=!printString:scan_strs[]=for /f!
if %%a == scan_str[] set printString=!printString:scan_str[]=for!
if %%a == scan_dir[] set printString=!printString:scan_dir[]=for /d!
if %%a == ping[] set printString=!printString:ping[]=ping!
if %%a == sysinf[] set printString=!printString:sysinf[]=systeminfo!
if %%a == ipinf[] set printString=!printString:ipinf[]=ipconfig /all!
if %%a == hello_world[] set printString=!printString:hello_world[]=echo Hello, World!
if %%a == unicode[] set printString=!printString:unicode[]=chcp 65001!
if %%a == curl[] set printString=!printString:curl[]=curl!
if %%a == fndstr[] set printString=!printString:ndfstr[]=findstr!
if %%a == fnd[] set printString=!printString:fnd[]=find!
if %%a == ps[] set printString=!printString:ps[]=powershell!
if %%a == enb_delay[] set printString=!printString:enb_delay[]=setlocal enabledelayedexpansion!
if %%a == dis_delay[] set printString=!printString:dis_delay[]=setlocal disabledelayedexpansion!
)
:: Writing into output file
if not "!fchcomment!" == "true" (
if "!procadd!" == "true" (
if !procval! == 0 (
set procval=1
echo.>!proctar!.bat
) else (
if "!fccomment!" == "true" (
echo.::!printString!>>!proctar!.bat
) else if not "!deniedToken!" == "true" (
echo.!printString!>>!proctar!.bat
)
)
) else if "!inlfadd!" == "true" (
if !inlfval! == 0 (
set inlfval=1
echo.>!inlftar!.inline
) else (
if "!fccomment!" == "true" (
echo.::!printString!>>!inlftar!.inline
) else if not "!deniedToken!" == "true" (
echo.!printString!>>!inlftar!.inline
)
)
) else if "!methodadd!" == "true" (
if !methodval! == 0 (
set methodval=1
if !methodtar! NEQ init echo.>!classtar!.!methodtar!.method
) else (
if "!fccomment!" == "true" (
echo.::!printString!>>!classtar!.!methodtar!.method
) else if not "!deniedToken!" == "true" (
echo.!printString!>>!classtar!.!methodtar!.method
)
)
) else (
if "!fccomment!" == "true" (
echo.::!printString!>>%output%.bat
) else if not "!deniedToken!" == "true" (
echo.!printString!>>%output%.bat
)
)
)
)
:: Delete the inline and method files if needed.
if "%keepinline%" NEQ "true" if exist *.inline del /q *.inline
if "%keepmethod%" NEQ "true" if exist *.method del /q *.method
:: Disable delayed expansion so that the code can work fine on the console.
setlocal disabledelayedexpansion
if "%fcread%" == "true" type %output%.bat
if not "%fccompile%" == "true" if not "%fcread%" == "true" call %output%.bat
exit /b
:fcversion
echo FreakC DevKit Version 0.19.6 BETA
exit /b
:: A function to calculate string's length
:get_len
set len=0
set str=%~2
:loop
if not "!str:~%len%!" == "" set /a len+=1 & goto loop
set %~1=%len%
exit /b
================================================
FILE: Source/createFile.bat
================================================
freakc %~1 --keep
================================================
FILE: Source/libgen.bat
================================================
call :%~1_%~2
exit /b 0
:float_float
echo for /f %%%%i in ('powershell %%~2'^) DO set %%~1=%%%%i>fclib_float.bat
exit /b 0
:array_qsort
(
echo set /a l=%%~2, h=%%~3, a=^^!h^^!-^^!l^^!+1, top=-1
echo for /l %%%%i in (0 1^) do (set stack[%%%%i]=0
echo if %%%%i GEQ ^^!a^^! goto end^)
echo :end
echo set /a top+=1
echo set stack[^^!top^^!]=^^!l^^!
echo set /a top+=1
echo set stack[^^!top^^!]=^^!h^^!
echo :WhileLoop0
echo if not ^^!top^^! GEQ 0 goto EndLoop0
echo for %%%%j in (^^!top^^!^) do set /a h=^^!stack[%%%%j]^^!, top-=1
echo for %%%%j in (^^!top^^!^) do set /a l=^^!stack[%%%%j]^^!, top-=1
echo for %%%%j in (^^!h^^!^) do set pivot=^^!%%~1[%%%%j]^^!
echo set /a i=^^!l^^!-1, _high=^^!h^^!-1
echo for /l %%%%i in (^^!l^^! 1 ^^!_high^^!^) do (
echo if ^^!%%~1[%%%%i]^^! LEQ ^^!pivot^^! (
echo set /a i+=1
echo for %%%%j in (^^!i^^!^) do (
echo set temp=^^!%%~1[%%%%j]^^!
echo set %%~1[%%%%j]=^^!%%~1[%%%%i]^^!
echo set %%~1[%%%%i]=^^!temp^^!^)^)^)
echo set /a _i=^^!i^^!+1
echo for %%%%m in (^^!_i^^!^) do (
echo set temp=^^!%%~1[%%%%m]^^!
echo for %%%%j in (^^!h^^!^) do set %%~1[%%%%m]=^^!%%~1[%%%%j]^^!
echo set %%~1[^^!h^^!]=^^!temp^^!^)
echo set /a p=^^!i^^!+1
echo set /a _res1=^^!p^^!-1, _res2=^^!p^^!+1
echo if ^^!_res1^^! GTR ^^!l^^! (
echo set /a top+=1
echo set stack[^^!top^^!]=^^!l^^!
echo set /a top+=1
echo set stack[^^!top^^!]=^^!_res1^^!^)
echo if ^^!_res2^^! LSS ^^!h^^! (
echo set /a top+=1
echo set stack[^^!top^^!]=^^!_res2^^!
echo set /a top+=1
echo set stack[^^!top^^!]=^^!h^^!^)
echo goto WhileLoop0
echo :EndLoop0
echo exit /b 0
)>fclib_array_qsort.bat
exit /b
:array_max
(
echo set /a len=%%~3-1
echo setlocal enabledelayedexpansion
echo set max=^^!%%~2[0]^^!
echo for %%%%i in (0,1,%%len%%^) do if ^^!%%~2[%%%%i]^^! GTR %%max%% set max=^^!%%~2[%%%%i]^^!
echo (endlocal ^& set %%~1=%%max%%^)
)>fclib_array_max.bat
exit /b 0
:array_min
(
echo set /a len=%%~3-1
echo setlocal enabledelayedexpansion
echo set min=^^!%%~2[0]^^!
echo for %%%%i in (0,1,%%len%%^) do if ^^!%%~2[%%%%i]^^! LSS %%min%% set min=^^!%%~2[%%%%i]^^!
echo (endlocal ^& set %%~1=%%min%%^)
)>fclib_array_min.bat
exit /b 0
:array_sum
(
echo set /a len=%%~3-1
echo set sum=0
echo setlocal enabledelayedexpansion
echo for %%%%i in (0,1,%%len%%^) do set /a sum+=^^!%%~2[%%%%i]^^!
echo (endlocal ^& set %%~1=%%sum%%^)
)>fclib_array_sum.bat
exit /b 0
:array_join
(
echo set /a len=%%~3-1
echo setlocal enabledelayedexpansion
echo for %%%%i in (0,1,%%len%%^) do set res=^^!res^^!^^!%%~2[%%%%i]^^!
echo (endlocal ^& set %%~1=%%res%%^)
)>fclib_array_join.bat
exit /b 0
:array_length
(
echo set res_len=0
echo :loop
echo if not defined %%~2[%%res_len%%] (
echo set %%~1=%%res_len%%
echo exit /b
echo ^)
echo set /a res_len+=1
echo goto :loop
)>fclib_array_length.bat
exit /b 0
:array_includes
(
echo set res_len=0
echo setlocal enabledelayedexpansion
echo :loop
echo if "^!%%~3[%%res_len%%]^!" == "%%~2" (
echo endlocal ^& set %%~1=true
echo exit /b
echo ^) else if %%res_len%% GEQ %%~4 (
echo endlocal ^& set %%~1=false
echo exit /b
echo ^)
echo set /a res_len+=1
echo goto :loop
)>fclib_array_includes.bat
exit /b
:array_indexOf
(
exit /b 0
echo set res_len=0
echo setlocal enabledelayedexpansion
echo :loop
echo if "^!%%~3[%%res_len%%]^!" == "%%~2" (
echo endlocal ^& set %%~1=%%res_len%%
echo exit /b
echo ^) else if %%res_len%% GEQ %%~4 (
echo endlocal ^& set %%~1=-1
echo exit /b
echo ^)
echo set /a res_len+=1
echo goto :loop
)>fclib_array_indexOf.bat
exit /b 0
:array_lastIndexOf
(
echo set /a res_len=%%~4-1
echo setlocal enabledelayedexpansion
echo :loop
echo if "^!%%~3[%%res_len%%]^!" == "%%~2" (
echo endlocal ^& set %%~1=%%res_len%%
echo exit /b
echo ^) else if %%res_len%% LEQ 0 (
echo endlocal ^& set %%~1=-1
echo exit /b
echo ^)
echo set /a res_len-=1
echo goto :loop
)>fclib_array_lastIndexOf.bat
exit /b 0
:array_push
echo set %%~1[%%~3]=%%~2>fclib_array_push.bat
exit /b
:array_pop
(
echo set /a len=%%~2-1
echo set %%~1[%%len%%]^=
)>fclib_array_pop.bat
exit /b
:array_shift
(
echo set len=%%~2
echo for /l %%%%i in (0 1 ^^!len^^!^) do (
echo set /a ind=%%%%i+1
echo for %%%%j in (^^!ind^^!^) do set %%~1[%%%%i]=^^!%%~1[%%%%j]^^!
echo ^)
echo exit /b
)>fclib_array_shift.bat
exit /b
:array_unshift
(
echo set len=%%~2
echo for /l %%%%i in (1 1 ^^!len^^!^) do (
echo set /a ind=%%%%i-1
echo for %%%%j in (^^!ind^^!^) do set _arr[%%%%i]=^^!%%~1[%%%%j]^^!
echo ^)
echo for /l %%%%i in (1 1 ^^!len^^!^) do set %%~1[%%%%i]=^^!_arr[%%%%i]^^!
echo set %%~1[0]=%%~2
echo exit /b
)>fclib_array_unshift.bat
exit /b
:array_reverse
(
echo set /a len=%%~2-1, _len=0
echo for /l %%%%i in (^^!len^^! -1 0^) do (
echo for %%%%j in (^^!_len^^!^) do set _arr[%%%%j]=^^!%%~1[%%%%i]^^!
echo set /a _len+=1
echo ^)
echo for /l %%%%i in (0 1 ^^!len^^!^) do set %%~1[%%%%i]=^^!_arr[%%%%i]^^!
echo exit /b
)>fclib_array_reverse.bat
exit /b
:array_clear
(
echo set ind=0
echo :loop
echo if %%ind%% GEQ %%~2 exit /b
echo set %%~1[%%ind%%]=
echo set /a ind+=1
echo goto loop
)>fclib_array_clear.bat
exit /b
:array_fill
(
echo set ind=%%~3
echo :loop
echo set %%~1[%%ind%%]=%%~2
echo if %%ind%% GEQ %%~4 exit /b
echo set /a ind+=1
echo goto loop
)>fclib_array_fill.bat
exit /b
:array_splice
(
echo call :length len %%~1
echo for /l %%%%i in (%%~2 1 ^^!len^^!^) do (
echo set /a ind=%%%%i+%%~3
echo for %%%%j in (^^!ind^^!^) do set %%~1[%%%%i]=^^!%%~1[%%%%j]^^!
echo ^)
echo exit /b
echo :length
echo set res_len=0
echo :loop
echo if not defined %%~2[%%res_len%%] (
echo set %%~1=%%res_len%%
echo exit /b
echo ^)
echo set /a res_len+=1
echo goto :loop
)>fclib_array_splice.bat
exit /b
:math_abs
(
echo set tar=%%~2
echo set %%~1=%%tar:-=%%
)>fclib_math_abs.bat
exit /b 0
:math_even
(
echo set /a res=%%~2 %%%% 2
echo if %%res%% == 0 (
echo set %%~1=true
echo ^) else (
echo set %%~1=false
echo ^)
)>fclib_math_even.bat
exit /b 0
:math_odd
(
echo set /a res=%%~2 %%%% 2
echo if %%res%% == 0 (
echo set %%~1=false
echo ^) else (
echo set %%~1=true
echo ^)
)>fclib_math_odd.bat
exit /b 0
:math_pow
(
echo set res=%%~2
echo set /a t=%%~3 - 1
echo for /l %%%%i in (1,1,%%t%%^) do (
echo set /a res*=%%res%%
echo ^)
echo set %%~1=%%res%%
)>fclib_math_pow.bat
exit /b 0
:math_factorial
(
echo set mul=1
echo for /l %%%%i in (1,1,%%~2^) do set /a mul*=%%%%i
echo set %%~1=%%mul%%
)>fclib_math_factorial.bat
exit /b 0
:string_lower
(
echo set lower=%%~2
echo set lower=%%lower:A=a%%
echo set lower=%%lower:B=b%%
echo set lower=%%lower:C=c%%
echo set lower=%%lower:D=d%%
echo set lower=%%lower:E=e%%
echo set lower=%%lower:F=f%%
echo set lower=%%lower:G=g%%
echo set lower=%%lower:H=h%%
echo set lower=%%lower:I=i%%
echo set lower=%%lower:J=j%%
echo set lower=%%lower:K=k%%
echo set lower=%%lower:L=l%%
echo set lower=%%lower:M=m%%
echo set lower=%%lower:N=n%%
echo set lower=%%lower:O=o%%
echo set lower=%%lower:P=p%%
echo set lower=%%lower:Q=q%%
echo set lower=%%lower:R=r%%
echo set lower=%%lower:S=s%%
echo set lower=%%lower:T=t%%
echo set lower=%%lower:U=u%%
echo set lower=%%lower:V=v%%
echo set lower=%%lower:W=w%%
echo set lower=%%lower:X=x%%
echo set lower=%%lower:Y=y%%
echo set lower=%%lower:Z=z%%
echo set %%~1=%%lower%%
)>fclib_string_lower.bat
exit /b 0
:string_upper
(
echo set upper=%%~2
echo set upper=%%upper:a=A%%
echo set upper=%%upper:b=B%%
echo set upper=%%upper:c=C%%
echo set upper=%%upper:d=D%%
echo set upper=%%upper:e=E%%
echo set upper=%%upper:f=F%%
echo set upper=%%upper:g=G%%
echo set upper=%%upper:h=H%%
echo set upper=%%upper:i=I%%
echo set upper=%%upper:j=J%%
echo set upper=%%upper:k=K%%
echo set upper=%%upper:l=L%%
echo set upper=%%upper:m=M%%
echo set upper=%%upper:n=N%%
echo set upper=%%upper:o=O%%
echo set upper=%%upper:p=P%%
echo set upper=%%upper:q=Q%%
echo set upper=%%upper:r=R%%
echo set upper=%%upper:s=S%%
echo set upper=%%upper:t=T%%
echo set upper=%%upper:u=U%%
echo set upper=%%upper:v=V%%
echo set upper=%%upper:w=W%%
echo set upper=%%upper:x=X%%
echo set upper=%%upper:y=Y%%
echo set upper=%%upper:z=Z%%
echo set %%~1=%%upper%%
)>fclib_string_upper.bat
exit /b 0
:string_slice
(
echo set /a len=%%~4-%%~3
echo set str=%%~2
echo setlocal enabledelayedexpansion
echo set str=^^!str:~%%~3,%%len%%^^!
echo endlocal ^& set %%~1=%%str%%
)>fclib_string_slice.bat
exit /b 0
:string_length
(
echo setlocal enabledelayedexpansion
echo set len=0
echo set str=%%~2
echo :loop
echo if not "^!str:^~%%len%%^!" == "" set /a len+=1 ^& goto loop
echo (endlocal ^& set %%~1=%%len%%^)
)>fclib_string_length.bat
exit /b 0
:string_reverse
(
echo setlocal enabledelayedexpansion
echo set len=0
echo set str=%%~2
echo set newstr=
echo :loop
echo if not "^!str:^~%%len%%^!" == "" set /a len+=1 ^& goto loop
echo set /a strlen=%%len%%-1
echo for /l %%%%i in (%%strlen%%,-1,0^) do set newstr=^^!newstr^^!^^!str:^~%%%%i,1^^!
echo (endlocal ^& set %%~1=%%newstr%%^)
)>fclib_string_reverse.bat
exit /b 0
:string_chr
(
echo if "%%~2" == "" exit /b
echo if %%~2 LSS 32 exit /b
echo if %%~2 GTR 126 exit /b
echo set alphabet= ^^!"#$%%%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^^^^_`abcdefghijklmnopqrstuvwxyz{|}~"
echo setlocal enabledelayedexpansion
echo set /a var=%%~2-32
echo set char=^^!alphabet:~%%var%%,1^^!
echo endlocal ^& set %%~1=^^%%char%%
)>fclib_string_chr.bat
exit /b 0
:string_ord
(
echo setlocal enabledelayedexpansion
echo set target=%%~2
echo set alphabet= ^^^^^^^^^^!"#$%%%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^^^^_`abcdefghijklmnopqrstuvwxyz{|}~"
echo for /l %%%%i in (0,1,94^) do if "^!alphabet:~%%%%i,1^!" == "^!target:~0,1^!" set /a res=%%%%i+32
echo endlocal ^& set %%~1=%%res%%
)>fclib_string_ord.bat
exit /b 0
:string_startswith
(
echo set str=%%~2
echo call :length "len" "%%~3"
echo setlocal enabledelayedexpansion
echo if "^!str:~%%~4,%%len%%^!" == "%%~3" (
echo (endlocal ^& set %%~1=true^)
echo ^) else (
echo (endlocal ^& set %%~1=false^)
echo ^)
echo exit /b
echo :length
echo setlocal enabledelayedexpansion
echo set len=0
echo set str=%%~2
echo :loop
echo if not "^!str:~%%len%%^!" == "" set /a len+=1 ^& goto loop
echo (endlocal ^& set %%~1=%%len%%^)
echo exit /b
)>fclib_string_startswith.bat
exit /b
:string_endswith
(
echo set str=%%~2
echo call :length "len" "%%~3"
echo setlocal enabledelayedexpansion
echo set str=^^!str:~0,19^^!
echo if "^!str:~-%%len%%^!" == "%%~3" (
echo (endlocal ^& set %%~1=true^)
echo ^) else (
echo (endlocal ^& set %%~1=false^)
echo ^)
echo exit /b
echo :length
echo setlocal enabledelayedexpansion
echo set len=0
echo set str=%%~2
echo :loop
echo if not "^!str:~%%len%%^!" == "" set /a len+=1 ^& goto loop
echo (endlocal ^& set %%~1=%%len%%^)
exit /b
)>fclib_string_endswith.bat
exit /b
:string_indexOf
(
echo set res_len=0
echo set str=%%~3
echo call :length sublen "%%~2"
echo call :length strlen "%%~3"
echo setlocal enabledelayedexpansion
echo :loop1
echo set /a res_len1=%%res_len%% - %%sublen%%
echo if "^!str:~%%res_len%%,%%sublen%%^!" == "%%~2" (
echo endlocal ^& set %%~1=%%res_len%%
echo exit /b
echo ^) else if %%res_len1%% GEQ %%strlen%% (
echo endlocal ^& set %%~1=-1
echo exit /b
echo ^)
echo set /a res_len+=1
echo goto :loop1
echo :length
echo setlocal enabledelayedexpansion
echo set len=0
echo set str=%%~2
echo :loop
echo if not "^!str:~%%len%%^!" == "" set /a len+=1 ^& goto loop
echo (endlocal ^& set %%~1=%%len%%^)
echo exit /b
)>fclib_string_indexOf.bat
:string_lastIndexOf
(
echo set str=%%~3
echo call :length sublen "%%~2"
echo call :length strlen "%%~3"
echo set /a res_len=%%strlen%% - %%sublen%%
echo setlocal enabledelayedexpansion
echo :loop1
echo if "^!str:~%%res_len%%,%%sublen%%^!" == "%%~2" (
echo endlocal ^& set %%~1=%%res_len%%
echo exit /b
echo ^) else if %%res_len%% LSS 0 (
echo endlocal ^& set %%~1=-1
echo exit /b
echo ^)
echo set /a res_len+=1
echo goto :loop1
echo :length
echo setlocal enabledelayedexpansion
echo set len=0
echo set str=%%~2
echo :loop
echo if not "^!str:~%%len%%^!" == "" set /a len+=1 ^& goto loop
echo (endlocal ^& set %%~1=%%len%%^)
echo exit /b
)>fclib_string_lastIndexOf.bat
exit /b
:string_trim
(
echo setlocal enabledelayedexpansion
echo set str=%%~2
echo :loop
echo set check=false
echo if "^!str:~0,1^!" == " " set check=true
echo if "^!str:~0,1^!" == " " set check=true
echo if "^!check^!" == "true" (
echo set str=^^!str:~1^^!
echo goto loop
echo ^)
echo :loop2
echo set check=false
echo if "^!str:~-1^!" == " " set check=true
echo if "^!str:~-1^!" == " " set check=true
echo if "^!check^!" == "true" (
echo set str=^^!str:~0,-1^^!
echo goto loop2
echo ^)
echo (endlocal ^& set %%~1=%%str%%^)
echo exit /b
)>fclib_string_trim.bat
exit /b
:list_max
(
echo set max=1
echo for %%%%i in ^(%%~2^) do (
echo set max=%%%%i
echo goto fcmaxend
echo ^)
echo :fcmaxend
echo for %%%%i in (%%~2^) do if %%%%i GTR %%max%% set max=%%%%i
echo set %%~1=%%max%%
)>fclib_list_max.bat
exit /b 0
:list_min
(
echo set min=1
echo for %%%%i in ^(%%~2^) do (
echo set min=%%%%i
echo goto fcminend
echo ^)
echo :fcminend
echo for %%%%i in (%%~2^) do if %%%%i LSS %%min%% set min=%%%%i
echo set %%~1=%%min%%
)>fclib_list_min.bat
exit /b 0
:list_sum
(
echo set sum=0
echo for %%%%i in ^(%%~2^) do set /a sum+=%%%%i
echo set %%~1=%%sum%%
)>fclib_list_sum.bat
exit /b 0
:util_cnd
echo if %%~2 (set %%~1=%%~3^) else set %%~1=%%~4>fclib_util_cnd.bat
exit /b 0
================================================
FILE: TUTORIAL.md
================================================
An experimental programming language
# First note
FreakC is a superset language which is transpiled to Batch, so pretty much all of FreakC's logic is Batch's, so it would be good if you check out the [Batch/CMD's official docs](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/windows-commands) or [a simple Batch tutorial](https://www.tutorialspoint.com/batch_script/batch_script_syntax.htm)
# Installation
There are many ways to install FreakC, you can:
1. Clone FreakC from Github using:
git clone https://github.com/FreakC-Foundation/FreakC.git
2. Install here.
# Cli's usage
In the "FreakC" folder, open cmd and type this command to compile and run the code:
freakc file_name
Example:
freakc "Examples/HelloWorld.fclang"
If you want to compile the code only, type:
freakc file_name --compile
If you want to compile the code and show the compiled code, type:
freakc file_name --candr
To show the current version of the devkit, type:
freakc --version
To create a new FreakC project quickly, you can type:
freakc project_name --create
Notice that it will generate a file with a Hello World example in it, if you just want to create an empty file, type:
freakc project_name --create --empty
You can enable delayed expansion in the output with:
freakc file_name (create/compile/candr or nothing) --de-enabled
this would be better than `enb_delay[]` in some cases.
To keep all the .inline files and .method files, type:
freakc --keep
To delete all stdlib files generated, type:
freakc --clrlib
To delete all Batch files, type:
freakc --clrbat
To show all options and usage, type:
freakc --help
To show all options and usage with pause, type:
freakc
### Interactive shell
To open interactive shell, type:
freakc --shell
::Or fcshell
You can type in whatever you want, it will be stored in "tar.fclang". You can type in any of these commands to execute tasks:
* `start[]` - Runs all the codes written
* `endcli[]` - Delete tar.fclang and exit
* `wipe[]` - Resets codes
* `clr[]` - Clear console
# Print text
To print out a string or text, you can do it like this:
print[] string
The command is compiled to `echo.`, if you just want to use the traditional `echo`:
uprint[] string
It's worth noticing that `print[]` might not work well with delayed expansion, but `uprint[]` does, so try using `uprint[]` if your program starts going weird. Also, since `uprint[]` is `echo`, it should work way faster than `print[]`. But `print[]` can print out an empty line easier, so it might worth combining them in your code.
There's also `fprint[]`, which is the fastest one, but however this one doesn't work with delayed expansion variables at all.
## Store data
You can actually store data to a file by using:
print[] data>>file
:: Overwrite:
print[] data>file
:: Multi-line
(
print[] data1
print[] data2
)>file_name
# Special characters
Unlike any characters, "!" requires "^", for example:
::This would causes no errors
print[] @#/
::This would cause error ("!" will not be shown)
print[] !
::Correct codes:
print[] ^!
# Unicode characters
To start using Unicode character, type:
unicode[] >nul
So now you can use Unicode characters:
unicode[] >nul
print[] ă ê ©
:: Would print out "ă ê ©"
# Prints out command's text
If you type:
print[] print[]
It won't print out "print[]", but it will print out "echo", because FreakC will compiles any statement/command without caring if it's a used data or not. So to actually print out "print[]", you will need to add "^" in any place of the command. Example:
print[] print[^]
:: This will print out "print[]"
# Variables
## Variables
### String
To declare a variable, you can use:
var[] variable_name=string_value
Or:
var[] "variable_name=string_value"
Multi-line strings:
local[] enabledelayedexpansion
var[] multi_line_string=Line 1^
!
Line 2^
!
Line 3
With normal Batch, you don't need the `!`, you just need a blank line. But with FreakC, the compiler skips through the new lines, so what it's doing is that it force the compiler to include that line (since that line still contain a character), and because `!` is skipped, it's an equivalent to an empty line.
But that way is just outdated, you can do that in a prettier way with a built-in `LF` macro:
var[] multi_line_string=Line 1!LF!
Line 2!LF!
Line 3!LF!
Though you can also use something kind of an equivalent to `\n` in other languages:
var[] multi_line_string=Line 1!NL!Line 2!NL!Line 3
`!NL!` is a built-in macro.
You can also implement something like this:
enb_delay[]
var[] n=sad^
!
!
print[] Hello^!n^!
print[] World
But the `!NL!` macro is fine enough.
But note that if you're using variables, make sure to enable delayed expansion or else it won't work!
There's also a command to enable Batch-style new line macros:
get_util[]
### Evaluate
To do math equations, do:
eq[] equation
to store in a variable(which you should use and it's highly recommended):
eq[] variable_name=equation
note that you can do multiple equations at once:
eq[] variable_name1=equation1, variable_name2=equation2
also, if you want to use variables that are assigned in that exact same line, you must not use "%":
eq[] age=1, intel=age+1
:: Variable "intel" will have the value of 2.
A prettier alternative is `int[]`:
int[] variable_name=equation
Note that eq[] will always round up number, to do equation or to declare a variable as a float, do:
:: Import float
import[] float
float[] "variable_name" "equation"
### Console input
To declare a variable from user's input, try:
inp[] variable_name=
Note: If you do this, it will prints out "Enter name:" right next to the input
inp[] variable_name=Enter name:
To read data from a file:
inp[] variable_name= delims=" %%i in () do (
:: Print out the element at position
print[] %%i
)
Example:
var[] list=1 2 3 4 5
scan_strs[] "tokens=3 delims= " %%i in (%list%) do (
:: Print out the element at position 3, which is 4
print[] %%i
)
Given that, you can have another way to iterate over a list: just create a loop from 0 to the length of the list, and use indexing like this.
List is extremely better in performance than array, and use much less memory since it doesn't create new variables, but it's not as convenient to just get a value from a specific index, and it's pretty hard to change values too. Make sure to use what serves you best.
#### Tuples
var[] tuple=`Simon`Sawicki`
for /F "tokens=1,2 delims=`" %%a in ("!tuple!") do (
echo Name : %%a
echo Surname: %%b
)
Technically a tuple is a list but use a different delimitter, and can not be iteratable and should be immutable as well.
### Maths
You can do Math equations with FreakC like this:
eq[] result=1+1+2+4
If you do this, variable "result" will be "Hel + lo"
var[] result=Hel + lo
Math operators
* `() - grouping`
* `! ~ - - unary operators`
* `* / % - arithmetic operators`
* `+ - - arithmetic operators`
* `<< >> - logical shift`
* `& - bitwise and`
* `^ - bitwise exclusive or`
* `| - bitwise or`
* `= *= /= %= += -= - assignment`
* `&= ^= |= <<= >>= , - expression separator`
* `++ -- - plus/minus 1`
### Merge strings
To merge strings, do this:
var[] str1=Hello
var[] str2=World
var[] str=%str1% %str2%
So the value of %str% is "Hello World"
Don't merge string like this:
var[] str1=Hello
var[] str2=World
var[] str=%str1% + %str2%
This time, the value will be "Hello + World"
### Use variables in different commands
You can use variables in FreakC commands as %variable_name%
For example, to print out a variable, you can do it like this:
var[] result=Hello World^!
print[] %result%
But, to print out an element of an array, you use:
var[] a[0]=Hello
print[] %a[0]%
To print out every element of an array, you can write something like this:
local[] ENABLEDELAYEDEXPANSION
var[] a[0]=100
var[] a[1]=35
var[] a[2]=20
loop[] %%n in (0,1,2) do (
print[] ^!a[%%n]^!
)
### Local and global variables
You can declare a global variable by just using all the ways mentioned recently.
To declare a variable locally, you will need to use:
local[]
eq[] ans=100
endloc[]
local[] and endloc[] helps create a local environment.
In Batch, to use variable in for loops, or enables command prosessor's extensions, you would need:
setlocal ENABLEDELAYEDEXPANSION
setlocal ENABLEEXTENSIONS
You can also do that with local[]
local[] ENABLEDELAYEDEXPANSION
local[] ENABLEEXTENSIONS
You can shorten `local[] ENABLEDELAYEDEXPANSION` with:
enb_delay[]
Same with disable delayed expansion:
dis_delay[]
### Delayed expansion
You have seen some `^!` above, that's an essential feature gained from delayed expansion.
If you want to prints out the element at position "i" (i is variable) of an array, you'd maybe try to do this:
print[] %arr[%i%]%
But it doesn't work, because you'd need to use:
local[] ENABLEDELAYEDEXPANSION
print[] ^!arr[%i%]^!
Also, if you change a value/declare a variable in a block of code locally in a normal way, it'd often not work outside the scope, so you should use delayed expansion pretty much all the time. Example:
Suppose this code:
if[] "%getOption%" EQU "yes" (
inp[] option=Enter option:
print[] Option read: %option%
)
Previous code will NOT work becase %option% value is replaced just one time when the IF command is parsed (before it is executed). You need to "delay" variable value expansion until SET /P command had modified variable value:
local[] EnableDelayedExpansion
if "%getOption%" EQU "yes" (
inp[] option=Enter option:
print[] Option read: ^!option^!
)
This problem is taken from [this source](https://stackoverflow.com/questions/22278456/enable-and-disable-delayed-expansion-what-does-it-do)
Notice that you're using `local[]`, which makes all the values defined locally, so remember to always add `endloc[]` (mostly when creating a function) to ensure everything works fine, like a `return` statement for example.
function[] getHello
local[] enabledelayedexpansion
:: Returning a value
endloc[] & var[] %~1=Hello
endfunc[]
An example of sorting an array:
inp[] n=The amount of element:
loop[] %%i IN (1,1,%n%) DO inp[] arr[%%i]=Element %%i:
local[] enabledelayedexpansion
loop[] %%i IN (1,1,%n%) DO (
eq[] ind=%%i+1
loop[] %%j IN (^!ind^!,1,%n%) DO (
if[] ^!arr[%%i]^! GTR ^!arr[%%j]^! (
var[] temp=^!arr[%%i]^!
var[] arr[%%i]=^!arr[%%j]^!
var[] arr[%%j]=^!temp^!
)
)
)
print[] Sorted:
loop[] %%i IN (1,1,%n%) DO print[] Element %%i: ^!arr[%%i]^!
### Special variables
* %random% - A variable with the value as random numbers from 1 to 99999
* %time% - A variable with the value as the current timer
* %date% - A variable with the value as the current date
* %cd% - A variable with the value as the current directory
* %errorlevel% - A variable with the value as the current Batch errorlevel value
* %cmdextversion% - A variable with the value as the current Command Processor Extensions version number
* %cmdcmdline% - A variable with the value as the original command line that invoked the Command Processor
* %path% - A variable with the value of PATH environment variable
* %highestnumanodenumber% - A variable with the value as the highest NUMA node number on this machine
There are a lot of special variables left, but you might not find uses for them
### Some features with variables
* %variable_name:~0,-2% - would extract all but the last 2 characters of the variable
* %variable_name:~-5% - would extract the last 5 characters of the variable
* %variable_name:~5% - would remove the first 5 characters of the variable
* %variable_name:str1=str2% - would replace str1 with str2
* %PATH:~10,5% - would expand the PATH environment variable, and then use only the 5 characters that begin at the 11th (offset 10) character of the expanded result. If the length is not specified, then it defaults to the remainder of the variable value. If either number (offset or length) is negative, then the number used is the length of the environment variable value added to the offset or length specified
### Batch-style macro
:: A macro which prints out "Hello"
var[] hello= print[] Hello
%hello%
You can join commands together like this:
var[] hello= print[] Hello ^& print[] Hell yeah^!
You can also pass arguments in by doing:
var[] macro_with_argument=for %%i in (argv) do echo %%i
%macro_with_argument:argv=1 2 3% :: Will print out 1, 2, 3 on each new lines.
What it did is simply just repace the macro with the command (of course), and `argv` in the string has been replaced by `1 2 3` which are now the arguments.
You can also create a mutli-line macro like how I did with multi-line string from above:
var[] macro_with_multi_commands=for %%i in (argv) do echo %%i!NL!echo Macro power %%i
This also work:
var[] macro_with_multi_commands=for %%i in (argv) do (!LF!
echo %%i!NL!echo Macro power %%i!LF!
)
### FreakC's macro
The Batch-style macro is the one being replaced in runtime. While it helps the program to run faster compared to calling functions, it's still kinda slow, so here comes the FreakC's true macro which is replaced during compile time:
:: A macro which prints out "Hello"
define[] hello= print[] Hello
!hello!
Remember that macros which acts like commands "kinda" require a " " in the back, but a normal macro doesn't:
define[] key=124123
print[] The key is !key!
FreakC's macro still works just like normal Batch variables, so you can also do stuffs like replace strings, generate substrings,...
define[] key=124123
print[] The key is !key:~1,2!
:: The result will be "The key is 24"
Basically, it should work like normal Batch's variables. But currently, multi-line macro doesn't work :(
### Alternative to macro
If you want an alternative, try reading at the [#Function] section. There will be docs about inlined functions, which are as fast as macros, but as nice as normal functions.
So why macro if inlined function is better? Well, simple, just don't use macro for any function-like stuffs, but macros can be good for stuffs like shorter naming, or really small tasks that usually just come as a form a single command :v
### Notes
Also, spaces in FreakC is extremely important, so if you declare a variable like this:
eq[] abc = 100
It will declare the "abc " variable, so if you prints it out like this, it will not work
print[] %abc%
You will have to code like this:
print[] %abc %
Then, it will prints out " 100"
Other thing that you should notice is that
var[] text
would return any variable begins with "text"
# Comments
## The best way
!= This is a comment =!
Because an undefined macro returns nothing, all the stuffs inside is gone in the compiler nicely. And because there are no variables named `= varname =`, we can use it safely. It's also the fastest one, since it's removed in compile time lol.
## Batch's way
Single-line Batch comment:
:: Comment
This might break in Batch's parenthesized block, but it's the fastest one.
Another way:
rem comment
This is the slowest one.
Another way:
%= =%
Its performance is decent, and work all the time.
## Old dumb way
Multi-line comment that's transpiled to Batch comments:
c[] line1
line2
e[]
To write a comment that won't show up in the compiled codes, use:
h[] comment
Multi-line version:
ch[] comment1
comment2
ce[]
# Labels and Goto statement
Labels helps you to jump to a state or pass parameters to execute tasks (somewhat procedural programming).
To create a label/procedure, you use:
label[] label_name
To jump to a label, you use:
goto[] label_name
To call a label/procedure, you use:
call[] :label_name
Or:
lcall[] label_name
call[] can also targets file, while lcall[] can only targets label. For example, you can execute files like this:
call[] file_name
### Differences between goto[] and call[]
goto[] jumps to a label and will not execute the previous code while call[] use code from the label but still execute the previous code.
Also, goto[] also supports parameters, which helps you a lot of time.
For examples, this code will print the sum of two parameters:
goto[] :plus 1 2
label[] plus
eq[] ans=%~1 + %~2
print[] %ans%
Note: You can pass arguments in FreakC are %~1, %~2,...
### Notes
To restart the program, you can type:
goto[] FreakCCompiled
It is because the compiled code of FreakC is in a main label/procedure "FreakCCompiled"
This code would still work eventhough it contains special character
label[] dsasd$ 123213 323
goto[] dsasd$ 123213 323
## Shorter call statement
You can replace
call[] function_name "arg1" "arg2"
with
function_name[..] "arg1" "arg2"
There's also one for calling labels:
label_name[::] "arg1" "arg2"
# Function
## Function definition using `label[]`
:: main code goes here
:: Calling the function
lcall[] function_name
:: function_name[::]
end[]
label[] function_name
:: function's code goes here
end[]
## Define function by creating a new Batch file
You can create a new file and call it manually, or you can use:
function[] function_name
:: Code goes here
endfunc[]
Example:
function[] SayHello
print[] Hello
:: Using the arguments
print[] %~1
:: Safely exit the function
:: end[]
endfunc[]
:: Prints "Hello"
call[] SayHello
:: SayHello[..]
The upper code creates a file called "SayHello.bat" and just calls it.
This also works:
(
print[] print[] Hello
print[] :: Using the arguments
print[] print[] %~1
print[] :: Safely exit the function
print[] :: end[]
)>SayHello.bat
:: Prints "Hello"
call[] SayHello
:: SayHello[..]
So what's the difference? `function[]` is processed in compile time, but storing into the file manually is executed during runtime, so it's much faster and more convenient to just use `function[]`.
For some cases, you should add:
end[]
to properly exit the function. But technically, the function should works fine most of the time with out `end[]`.
## Differences between labels and files
By using `function[]`, you are actually creating a new Batch file, but by using `label[]`, it's just calling a label, so it grants more speed. But by using `label[]`, the function will be defined locally in that specific file, while `function[]` generates a whole new file, so it can be accessed by other files with the given path.
For example, you have a `Main.fclang` file:
function[] SayHello
print[] Hello
endfunc[]
and a folder named 'stuffs' at the same scope, with `stuffs.fclang` in it:
:: You can call "SayHello" like this:
call[] ../SayHello.bat
Both ways are fine, `label[]`'s speed is bad when the main file's too large, `function[]`'s speed is bad when the user's drive has a lot of latency. If you want your code to be more structured, you should probably go with labels, but FreakC's mainly used for scripting, not something too big so both, again, are fine.
Note that with both labels and `function[]`(files), you should use `local[]` and `endloc[]` to define the variables locally, So you can do something like this:
function[] hello
local[]
var[] sth=hello
:: End local environment and return a value
endloc[] & var[] %~1=%sth%
endfunc[]
## Return statement
Functions in FreakC are accessed through the call statement, so it's not an expression, so you can "return" a value by assigning value to selected variable.
Example:
function[] sum
eq[] %~1=%~2+%~3
endfunc[]
:: Variable "sum" will be granted the value "3"
call[] sum "result" "1" "2"
:: sum[..] "result" "1" "2"
:: Prints out 3
print[] %result%
## Recursion
You can implement recursion by simply calling the function inside of it. For example, this is a program which will prints a string for "n" times:
function[] printLoop
print[] %~1
eq[] n=%~2-1
call printLoop "%~1" "%n%"
endfunc[]
Note that using `call` will give you a recursion limit of about 339. To fix this problem you can use `cmd /c`, or just implement a goto command to exit the function, store the current state in a variable and call it again, that should give you infinite recursion limit.
## Performance issues
Both using labels and `function[]` are fairly slow, if you want to improve performance, just use a normal Batch macro since it's much faster.
## Inline function
To boost the speed up, I **highly suggest** using inlined functions. It's as fast as macros, and works just like normal functions :D
inlinef[] somefunc
:: Arg1
print[] 1[]
:: Arg2
print[] 2[]
endfunc[]
somefunc[//] arg1 arg2
:: icall[] somefunc arg1 arg2
However, there's currently a severe limitation: inline funtions can't be used with delayed expansion variables, it can only work with normal values and normal variables. I'll work hard to fix this problem soon!
# Object Oriented Programming
## Objects
Note that there are no such things as "objects" in FreakC/Batch, but you can use the FreakC variable to gain the same effect as seen in other languages:
var[] dog.name=Mary
var[] dog.age=3
function[] dog.move
print[] *Moving*
endfunc[]
Or you may have it like this (technically you can do it however you want because of how FreakC's variables work):
var[] dog["name"]=Mary
var[] dog["age"]=3
function[] dog["move"]
print[] *Moving*
endfunc[]
You can access the elements normally:
enb_delay[]
print[] %dog.age%
:: An example with getting an element from input
inp[] input=
print[] ^!dog.%input%^!
:: If the input is "name" then the output will be "Mary"
## Classes
You can implement a "class" like this:
:: Create a class called "Dog"
class[] Dog
:: Init method
method[] init
::Set properties, implementing "this" as the first argurment passed (%~1)
var[] %~1.age=%~2
var[] %~1.weight=%~3
endmethod[]
method[] BeingCute
print[] *Being cute*
endmethod[]
endclass[]
:: Create an object
new[] Dog "Mary" "3" "4kg"
:: Prints out "age" property of "Mary", which is "3"
print[] Age: %Mary.age%
:: Call "Mary.BeingCute", which prints out "*Being cute*"
call[] Mary.BeingCute
## Old crappy function-based oop
You can implement a "class" like this:
:: Create a procedure called "Dog"
function[] Dog
::Set properties, implementing "this" as the first argurment passed (%~1)
var[] $this.age=%~2
var[] $this.weight=%~3
:: Storing the codes inside a Batch file, which creates something like a method
(
print[] print[] *Being cute*
)>%~1.BeingCute.bat
endfunc[]
:: Create an object
Dog[..] "Mary" "3" "4kg"
:: Prints out "age" property of "Mary", which is "3"
print[] Age: %Mary.age%
:: Call "Mary.BeingCute", which prints out "*Being cute*"
call[] Mary.BeingCute
## Class-based or function-based OOP?
Just use classes, don't use functions, function is the old way. Classes are much more readable, and they are in fact faster, since the methods are generated in compile time, while in the function's way, it is generated in runtime, and creating/writing to files in runtime is **incredibly slow**.
## Inhertitance and polymorphism
### The new way:
extends[] parent_class
### What will it do?
It will inherit all the methods from the parent class. Since there are no actual properties in FreakC's classes, it will simply copy the init function from the parent class and paste it in the one in the child class (if the child class has an init function lol). So technically you can say classes in FreakC are just things that create collections of methods.
### The old way:
The old function way: You can create an init function and call it inside the "classes"(functions) you're creating.
## Encapsulation
With encapsulation, you can implement getter/setter functions to implement protected, everytime the data got accessed it must go through a getter/setter function. With private, you do the same thing as protected, however, rather than putting it inside the init function, only add it in one specific "class"(function).
Keep it in mind that there have been many attempts implementing OOP in Batch, the upper one is just my way to do it in FreakC.
# If statements
To use if statement, check this out:
if[] condition command_to_execute
Example:
var[] abc=100
if[] %abc% == 100 (
print[] abc is equal to 100
)
:: With strings
var[] str=Hello
if[] "%str%" == "Hello" (
print[] Hello there
)
It's actually a good practice to have the values in the comparison quoted.
You can actually use a Batch command in if[]. Example:
var[] abc=20
if[] %abc% == 20 (
echo abc is equal to 100
)
## All the comparison operators:
* "==" - Equal
* "EQU" - Equal/numeric equal
* "NEQ" - Not equal
* "LSS" - Less than
* "LEQ" - Less than or equal
* "GTE" - Greater than
* "GEQ" - Greater than or equal
## Conditional expression
There are no actual "conditional expression" in FreakC, but here's something close to a "ternary operator":
cnd[] var_name "condition" "value1" "value2"
Example:
cnd[] result "1 EQU 2" "1 is equal to 2" "1 is not equal to 2"
print[] %result% :: Will print out "1 is not equal to 2"
## Other kinds or if statements:
### Execute if a file exists
if_exist[] file_name (
command_to_execute
)
### Execute if a variable is defined
if_defined[] variable_name (
command_to_execute
)
### Execute if a condition is false
if_not[] condtition (
command_to_execute
)
### Else
if[] condition (
command1
) elif[] condition2 (
command2
) el[] (
command3
)
## Notes
To use if not for if_defined[] or if_exist[], you can do this:
if_not_exist[] file (
command_to_execute
)
if_not_defined[] file (
command_to_execute
)
## Pressing keys with respond
To receive keys pressed, add:
key[] key
For examples, if you want the users to press one in "wsad", type:
key[] wsad
To perform any actions, you will need to use a special if statement:
if_el[] position_of_key_in_key[]
Note: actually, `if_el` gets the errorlevel variable's value.
Example:
key[] wsad
if_el[] 4 (
print[] You pressed "D"
)
if_el[] 3 (
print[] You pressed "A"
)
if_el[] 2 (
print[] You pressed "S"
)
if_el[] 1 (
print[] You pressed "W"
)
### If not errorlevel
You can use:
if_not_el[]
to use if not.
# Switch case
If you're familiar with C, then this is FreakC's way on how to use a switch case:
enb_delay[]
match[] value
case[] value1
:: Code
endcase[]
case[] value2
:: Code
endcase[]
default[]
:: Code executed when no case is match, and this block is optional
endcase[]
endmatch[]
But currently there's limitations with this command, as it currently can't check multiple cases :/, will update the feature soon!!
# Loops
## For loops (in Batch)
### Loops from "start" to "end" by "step"
loop[] %%parameters in (start,step,end) do (
)
### Loops through files rooted in a folder
scan_dir[] drive/directory %%parameters in (file) do (
)
### Loops through files, strings, or even the returned result of a command
scan_strs[] "tokens=position-position delims=delimiter" %%parameters in (something) do (
)
If `something` is double-quoted, then it is a string.
If `something` is single-quoted, then it is a command to be executed, and the parameter will be the returned content of the command.
If `something` is not quoted, then it will loops through every lines in a file.
`tokens` are the tokens you want to take, set it to a number if you want to get the token at that position set it to `*` if you want to get all tokens, set it to `number1-number2` if you want to get the tokens start from position number1 to position number2, and to access those tokens, use paratemeters in alphabetical order.
### Loops through a set of parameters
scan_str[] %%parameters in (set) do (
)
### Loops through a folder
scan_files[] %%parameters in (folder) do (
)
## While loops
While loops can be created using:
while[] condition
::code
endwhile[]
Of course, the loops will run when the condition is still true, stop when false.
### Repeat-until loop
repeat[]
::code
until[] condition
### Differences between While and Repeat Until
While loop is executed only when given condition is true. While repeat-until executes the codes first before caring about the condition, and it loops until the condition is true.
### Nesting while loops
This will work just fine:
while[] condition
while[] condition
endwhile[]
endwhile[]
(Same with repeat-until)
## Batch's way to create whiles loops.
FreakC's while loops are compiled down to goto statements and labels, so you can also create a while loop using normal Batch:
eq[] i=start_number
label[] loop
command
if[] %i% == end_number goto[] nextcode
eq[] i++
goto[] loop
label[] nextcode
command
But this would be too bulky, just stick with FreakC's whilee loop.
For example, this program will print all the number from 0 to 10 then print out "Done!":
eq[] i=0
label[] loop
print[] %i%
if[] %i% == 10 goto[] nextcode
eq[] i++
goto[] loop
label[] nextcode
print[] Done^!
## FreakC's for loop
enb_delay[]
for[] var_name start step end
:: some code
endfor[]
Why? Because FreakC's while loops are compiled down to labels and goto statements, which means that Batch's for will not work well with FreakC's while, unless you create a function containing that while loop, and then call it inside the Batch-style's for loop, then it would work, but that's tedious. However, FreakC's for loop is compiled down to the same format as while loops, so you can nest while and for loops together easily. Also, by using FreakC's for loop, you can gain some features which I will cover in the next section.
But there's some drawbacks, the biggest one is probably performance loss because FreakC's for is compiled down to goto statments and labels, which are way slower than Batch-styl for loops. But if you prefer convenience to performance then `for[]` is good for you, same with macros and functions lol.
## Break, continue statement
To break out a FreakC's for loop or while loop, simply use `breakl[]`:
enb_delay[]
for[] i 0 1 5
if[] ^!i^! == 3 breakl[]
endfor[]
:: This will print out 1, 2
To skip one iteration, use `continue[]`:
enb_delay[]
for[] i 0 1 5
if[] ^!i^! == 3 continue[]
endfor[]
:: This will print out 1, 2, 4
`continue[]` and `breakl[]` can work well with while loops and repeat-until loops.
# Inlining commands
Note that all commands can be inlined normally, except all FreakC-exclusive commands that uses its own kind of block statement.
These includes:
* `function[]` - `endfunc[]`
* `while[]` - `endwhile[]`
* `repeat[]` - `until[]`
* `match[]` - `endmatch[]`
* `case[]` - `endcase[]`
This will not work
function[] something endfunc[]
or this:
if[] 1 == 1 while[] 1 > 0
print[] OMG
endwhile[]
it should have been:
if[] 1 == 1 (
while 1 > 0
print[] OMG
endwhile[]
)
# Asynchronous process
In Batch, you can run a Batch file asynchronously using:
start /B "" file.bat
the equivalent in FreakC would be:
open[] /B "" file.bat
Example with functions:
enb_delay[]
:: asynchronous code
open[] /b "" count[..] "Dog"
:: synchronous code
count[..] "Sheep"
:: Count function to print a string 10 times
function[] count
@echo off
loop[] %%i in (1 1 10) do (
print[] %%i %~1
wait[] 2 >nul
)
endfunc[]
You would be able to see that it doesn't wait for 2 seconds to print out Dog and *then* Sheep, Dog and Sheep are printed at almost the same time. This is because the code is run asynchronously, it is non blocking. This helps a lot in improving performance because you can technically change "in-order" tasks into tasks that run together. Think of it as a bathtub, rather than making one people take a bath and then proceeds to the next one, you can just put all people into the bathtub, which should reduce a lot of time, and should scale well if given more people (who in real case, are users). Or if you are developing a videogame, the code can reacts to user's input while the game is still rendering normally.
# Parentheses
## An alternative
Because FreakC uses more "human-friendly" syntax, but Batch uses parentheses for creating blocks of codes, so I've decided to add a crappy "human version" of this:
if[] 1 == 1 begin[]
while 1 > 0
print[] OMG
endwhile[]
done[]
`begin[]` and `done[]` are direct equivalents of `(` and `)`, so they both work the same, but if you prefer codes to be more "human-readable", then this would be pretty good.
# Escaping characters
## Escaping special characters
To escape characters like `&|><` and most other characters, you can use the caret character:
:: Prints out "&"
print[] ^&
:: Prints out "|"
print[] ^|
### Escaping the caret character itself
print[] ^^
## Escaping % and !
With `%`, you can just double it up to escape it. Example:
:: Will print out "%LOL%"
print[] %%LOL%%
If you use `!` not for variables, then one caret character will do the job:
:: Will print out "Hello!"
print[] Hello^!
With `!` for variables, you can add 5 caret characters:
:: Will print out "!Hello!"
var[] hello=hello freakc
print[] ^^^^^!hello^^^^^!
## Escaping quotation marks
If you pass in arguments for functions (or for loops) like this:
func_name[..] "Arg1" "Arg2" "Arg3 " "
then there would be errors.
Instead, you must double the quotes:
func_name[..] "Arg1" "Arg2" "Arg3 "" "
Then just replace 2 quotes with one.
# Modules and include
Create a module:
deny[]
:: code goes here
Include the compiled content of the module:
include[] file_with_no_fclang_extension
`include[]` gives you the same effect you would get from `#include` from C/C++, but there're some differences. #include takes the code of the other file and put it in the main file and then the main file is compiled, while include[] compiles the other file first and then take that compiled codes and put it in the compiled main file.
You can also compile a file without including it:
compile[] file_with_no_fclang_extension
This might come in handy if you have files as functions. (Batch style)
# Pre-built libraries
## Float
float[] "variable_name" "some_value"
## List
:: Find sum of list of numbers, seperated by a space character.
sum[] "variable_name" "list"
:: Find maximum of list, seperated by a space character.
max[] "variable_name" "list"
:: Find minimum of list, seperated by a space character.
min[] "variable_name" "list"
:: Example:
max[] "max_num" "2 3 1 8 5"
:: This will prints out "8"
print[] %max_num%
## Array
:: Find sum of every elements in an array
arr_sum[] "variable_name" "array" "length"
:: Find largest element in an array
arr_max[] "variable_name" "array" "length"
:: Find smallest element in an array
arr_min[] "variable_name" "array" "length"
:: Return true if array include a value, false if not
arr_includes[] "variable_name" "value" "array" "length"
:: Find first index of an element, return -1 if find none
arr_indexOf[] "variable_name" "value" "array" "length"
:: Find last index of an element, return -1 if find none
arr_lastIndexOf[] "variable_name" "value" "array" "length"
:: Return a value which concatenated all elements in an array
arr_join[] "variable_name" "array" "length"
:: Find length of an array (will crash if an element is empty)
arr_length[] "variable_name" "array"
:: Reverse array
arr_reverse[] "array" "length"
:: Append a value into an array
arr_push[] "array" "value" "length"
:: But this is not really a good way to append a value into an array, you can just do this and it's way better:
var[] array[length+1]=value
:: By doing this, you gain better performance, and you can have better control at the array's length:
:: Example:
int[] arr_len++
var[] arr[%len%]=5
:: Prepend a value into an array (requires delayed expansion being enabled)
arr_unshift[] "array" "value" "length"
:: Remove the last value from an array
arr_pop[] "array" "length"
:: Same with arr_push[], this function is not really good, this is a better way:
var[] array[length]=
:: Example:
var[] arr[%arr_len%]=
int[] arr_len--
:: Remove the first value from an array (requires delayed expansion being enabled)
arr_shift[] "array" "length"
:: Remove an "amount" value from a specified "index" from "array"
arr_splice[] "array" "index" "amount"
:: Fill the array from index1 to index2 with a value
arr_fill[] "array" "value" "index1" "index2"
:: Come to think of it, you can create a whole new array filled with some value using arr_fill with out declaration
:: Sort an array using the quick sort algorithm
arr_qsort[] "array" "low" "high"
:: Clear an array (will crash if an element is empty)
arr_clear[] "array" "length"
:: Example:
var[] arr[0]=1
var[] arr[1]=0
var[] arr[2]=10
arr_max[] "max_num" "arr" "3"
:: This will print out "10"
print[] %max_num%
### Note
All the functions above only works with list with all integers. String or floats will cause errors.
## Math
:: Absolute
abs[] "variable_name" "number"
:: Check if a number is odd
odd[] "variable_name" "number"
:: Check if a number is even
even[] "variable_name" "number
:: Power
pow[] "variable_name" "number" "power_num"
:: Factorial
factorial[] "variable_name" "number"
## String
:: Length of string
string_length[] "variable_name" "string"
:: To uppercase
string_upper[] "variable_name" "string"
:: To lowercase
string_lower[] "variable_name" "string"
:: Reverse
string_reverse[] "variable_name" "string"
:: First first index of a substring in a string
string_indexOf[] "variable_name" "substring" "string"
:: First last index of a substring in a string
string_lastIndexOf[] "variable_name" "substring" "string"
:: Trim all excess spaces from both side of a string
string_trim[] "variable_name" "string"
:: Return true if string starts with a substring, false if it doesn't
string_startswith[] "variable_name" "string" "substring" "position"
:: Return true if string ends with a substring, false if it doesn't
string_endswith[] "variable_name" "string" "substring" "position"
:: Return an ASCII value equivalent to the character, if passed a string, it will return the value of the first character only, so if you pass in """" it will give you the ASCII value of the double quote character
string_ord[] "variable_name" "value"
:: Return a character equivalent to its ascii value
string_chr[] "variable_name" "value"
:: Note that you would probably need a caret character for escaping some special characters like "<>&^" like this:
string_chr[] "variable_name" "value"
print[] ^%variable_name% :: This is safe and highly recommended
## Import keyword and generating methods
From v0.6.1, `import[]` has been obsolete since commands can generate their own independent method files. But you can still use it if you want, it will generate a bunch of files even when you don't need them though:
:: Will generate all method files for math
import[] math
But I guess if you want to call files normally, you can use import for that:
import[] math
fclib_math_pow[..] "some_var" "some_value"
But you can use `gen_lib_func[]` which is much cleaner, and only generates the needed method:
gen_lib_func[]
fclib_math_pow[..] "some_var" "some_value"
But for real, why would you need to do that, just type in `pow[] "some_var" "some_value"`. It's shorter and it's basically the same thing.
# Command-line argument
You can use %1, %2, %3,... for command-line args
For example, you have a FreakC file called "main" like this (which will be compiled later):
print[] First argument: %1
print[] Second argument: %2
print[] Third argument: %3
If you pass in the file with these arguments:
./main Hello World and FreakC
Then the output would be:
First argument: Hello
Second argument: World
Third argument: and
# Statement
It's important to say that pretty much everything is a statement, not an expression. Every commands are executed, and no values are returned at all.
# Error handling
First of all, you'll need to know that the FreakC compiler will not catches errors at all, but you can still receive errors from CMD or the Batch interpreter.
## Error handling
You can catch errors by using the following codes:
command && (
echo The codes ran successfully
) || (
echo Failed :(
)
By using the "and" and "or" operator, we can implement error handling like above. Basically, it runs the "command", if there's no problem, it will execute the first block, or else it will execute the other block.
# Nul in FreakC
It's just like nul in Batch, so if you want to make your console not print out any process, you can do it like this:
Command >nul
To hide errors, you can do this:
Command >nul 2>nul
# Find strings in a file
fnd[]:
fnd[] [/V] [/C] [/N] [/I] [/OFF[LINE]] "string" [[drive:][path]filename[ ...]]
/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
/OFF[LINE] Do not skip files with offline attribute set.
"string" Specifies the text string to find.
[drive:][path]filename Specifies a file or files to search.
If a path is not specified, FIND searches the text typed at the prompt or piped from another command.
If a path is not specified, FIND searches the text typed at the prompt or piped from another command.
fndstr[]:
fndstr[] [/B] [/E] [/L] [/R] [/S] [/I] [/X] [/V] [/N] [/M] [/O] [/P] [/F:file]
[/C:string] [/G:file] [/D:dir list] [/A:color attributes] [/OFF[LINE]]
strings [[drive:][path]filename[ ...]]
/B Matches pattern if at the beginning of a line.
/E Matches pattern if at the end of a line.
/L Uses search strings literally.
/R Uses search strings as regular expressions.
/S Searches for matching files in the current directory and all subdirectories.
/I Specifies that the search is not to be case-sensitive.
/X Prints lines that match exactly.
/V Prints only lines that do not contain a match.
/N Prints the line number before each line that matches.
/M Prints only the filename if a file contains a match.
/O Prints character offset before each matching line.
/P Skip files with non-printable characters.
/OFF[LINE] Do not skip files with offline attribute set.
/A:attr Specifies color attribute with two hex digits. See "color /?"
/F:file Reads file list from the specified file(/ stands for console).
/C:string Uses specified string as a literal search string.
/G:file Gets search strings from the specified file(/ stands for console).
/D:dir Search a semicolon delimited list of directories
strings Text to be searched for.
[drive:][path]filename Specifies a file or files to search.
Use spaces to separate multiple search strings unless the argument is prefixed with /C.
For example, 'FINDSTR "hello there" x.y' searches for "hello" or "there" in file x.y.
'FINDSTR /C:"hello there" x.y' searches for "hello there" in file x.y.
Regular expression quick reference:
. Wildcard: any character
* Repeat: zero or more occurrences of previous character or class
^ Line position: beginning of line
$ Line position: end of line
[class] Character class: any one character in set
[^class] Inverse class: any one character not in set
[x-y] Range: any characters within the specified range
\x Escape: literal use of metacharacter x
\ Word position: end of word
(Copied from the documentation of Batch)
# Other useful commands
### Exit the program
quit[]
### Shutdown system
imd_shutdown[]
::Add /t time and /c "comment" to set the time to shutdown and leave a comment before shutdown
:: Log off
logoff[]
:: Hibernate shutdown
hibernate_shutdown[]
:: Shutdown system after a specific time (in ms)
shutdown_after[] time
:: Immediate shutdown
imd_shutdowns[]
### Restart system
imd_restart[]
::Add /t time and /c "comment" to set the time to shutdown and leave a comment before restart
:: Restart system after a specific time (in ms)
restart_after[] time
### Create a folder
create_dir[] folder_name
### Access a folder
change_dir[] folder_name
### Access a drive
drive[] drive_name
### Read a file
read_file[] file_name
### Clear the screen
clrscr[]
### Pause
stop[]
### Delete a file
del[]
### Delete a folder
remove_dir[] folder_name
### Change color, a pair of hex code is a color code
change_color[] hex_code
* 0 = Black
* 1 = Blue
* 2 = Green
* 3 = Aqua
* 4 = Red
* 5 = Purple
* 6 = Yellow
* 7 = White
* 8 = Gray
* 9 = Light Blue
* A = Light Green
* B = Light Aqua
* C = Light Red
* D = Light Purple
* E = Light Yellow
* F = Bright White
### Change the title of the program
change_title[] title_name
### Change console's size
change_mode[] size_number
change_mode[] con cols=columns_or_width lines=lines_or_height
:: Shorter one
change_mode[] columns_or_width,lines_or_height
### Rename a file
rename[] file_name
### Move a file to the new path
mov[] file_name new_path
### Copy a file to the new path
copy[] file_name new_path
### Open a file or a website url (would open cmd if nothing is opened)
open[] file
### Timeout for a specific time
wait[] time_as_second
### Restart the program or loop the program endlessly
inf_loop[]
### Shows date
see_date[]
### Shows time
see_time[]
### Shows all files in the current directory
ls[]
### Prompt for date to change date
change_date[]
Note: Administrator is required to run the command
### Prompt for time to change time
change_time[]
Note: Administrator is required to run the command
### Open powershell
ps[]
# Clear codes
You can clear all compiled code using:
deny[]
# Multiple colors
Since everything works fine in Batch works in FreakC, you can check this [link](https://gist.githubusercontent.com/mlocati/fdabcaeb8071d5c75a2d51712db24011/raw/b710612d6320df7e146508094e84b92b34c77d48/win10colors.cmd) out.
# Convert FreakC to .EXE files
In "[FreakC/Utilities/Scripts](Utilities/Scripts)" there is a file called "[battoexe.bat](Utilities/Scripts/battoexe.bat)" which helps you to convert .bat files to .exe files.
So to convert FreakC to .EXE files, you need to compile FreakC codes to Batch, and then convert the Batch file generated by simply dragging that Batch file onto battoexe.bat.
You can actually find plenty of other tools online that helps you to converts Batch files to EXE files.
# Notes
FreakC is case-sensitive only with commands with [], other stuffs aren't.
Most of the commands are just modified Batch commands, so you can actually apply Batch logic in it.
Funny fact, you can print "Hello, World" using:
hello_world[]
================================================
FILE: Utilities/Scripts/FreakC/freakc.tmLanguage
================================================
fileTypes
fclang
name
FreakC
patterns
match
::.*$|h\[\].*$|\!\=.*\=\!
name
comment.line
match
(?<=(function\[\] ))([A-Za-z_])\w+|(?<=(label\[\] ))([A-Za-z_])\w+|(?<=(class\[\] ))([A-Za-z_])\w+|(?<=(method\[\] ))([A-Za-z_])\w+
name
entity.name.function
match
([A-Za-z])\w+(?=\[\.\.\])|([A-Za-z])\w+(?=\[\:\:\])|(?<=(call\[\] ))([A-Za-z_])\w+|(?<=(^))([a-zA-Z_])+(?=(\.([A-Za-z_]+)\[\.\.\]))|(?<=(icall\[\] ))([A-Za-z_])\w+|(?<=(new\[\] ))([A-Za-z_])\w+|(?<=(goto\[\] ))([A-Za-z_])\w+
name
support.function
match
(%~1)+(?=(.[A-Za-z_])+)|\$this
name
variable.language
match
%%%%~([0-9])+|%%%~([0-9])+|%%~([0-9])+|%~([0-9])+
name
variable.parameter.function
match
=|\+|-|\*|/|\+\+|--
name
keyword.operator
match
([A-Za-z])\w+(?=\[\])
name
support.constant
match
".*"
name
string.quoted.double
scopeName
source.fclang
uuid
6f5f460e-5ab0-4ce2-8cb7-0cafea6c46c9
================================================
FILE: Utilities/Scripts/FreakC.sublime-build
================================================
{
"cmd": ["FreakC","$file"]
}
================================================
FILE: Utilities/Scripts/battoexe.bat
================================================
@echo off
title Convert BAT to EXE
mode 75,3 & color 0A
echo(
set "target.exe=%__cd__%%~n1.exe"
set "batch_file=%~f1"
set "bat_name=%~nx1"
set "bat_dir=%~dp1"
Set "sed=%temp%\2exe.sed"
copy /y "%~f0" "%sed%" >nul
(
(echo()
(echo(AppLaunched=cmd /c "%bat_name%")
(echo(TargetName=%target.exe%)
(echo(FILE0="%bat_name%")
(echo([SourceFiles])
(echo(SourceFiles0=%bat_dir%)
(echo([SourceFiles0])
(echo(%%FILE0%%=)
)>>"%sed%"
iexpress /n /q /m %sed%
del /q /f "%sed%"
exit /b 0
[Version]
Class=IEXPRESS
SEDVersion=3
[Options]
PackagePurpose=InstallApp
ShowInstallProgramWindow=0
HideExtractAnimation=1
UseLongFileName=1
InsideCompressed=0
CAB_FixedSize=0
CAB_ResvCodeSigning=0
RebootMode=N
InstallPrompt=%InstallPrompt%
DisplayLicense=%DisplayLicense%
FinishMessage=%FinishMessage%
TargetName=%TargetName%
FriendlyName=%FriendlyName%
AppLaunched=%AppLaunched%
PostInstallCmd=%PostInstallCmd%
AdminQuietInstCmd=%AdminQuietInstCmd%
UserQuietInstCmd=%UserQuietInstCmd%
SourceFiles=SourceFiles
[Strings]
InstallPrompt=
DisplayLicense=
FinishMessage=
FriendlyName=-
PostInstallCmd=
AdminQuietInstCmd=