Warning: This library is still in developement testing. Use at your own risk.
Swifty.js uses its own syntax and keywords.
Doing that will make JavaScript more fun (building custom keywords, specifying syntax etc.)
Here's an example code of Swifty.js:
[ swift version 0.3 ]
FUNCTION example = FUNC(
[...any],
({
constant params = any
return params
})
))
example("String") # "String"
A complete walkthrough of how to treat Swifty.js keywords and syntax correctly.
Swifty.js is a JavaScript PreProcesser that takes code, transforms it fully into JavaScript, and runs it.
Take this for example:
[ swift version 0.1 ]
FUNCTION myFunction = FUNC([...any], ({})))
##+
Check if version is valid and remove it
Take keywords and make the JavaScript-readable
Add semicolons
##-
You can get it by CDNjs:
<script src="https://cdn.jsdelivr.net/gh/Parking-Master/Swifty.js@latest/0.3/swifty.js" async>[ swift version 0.3 ]</script>
<script src="https://cdn.jsdelivr.net/gh/Parking-Master/Swifty.js@latest/0.3/swifty.min.js" async>[ swift version 0.3 ]</script>
- Or download the file here.
Let's walk through some CS (Common-Syntax) in Swifty.js.
Swifty.js code is NOT to be placed in .js
(JavaScript) files.
Swifty.js code is NOT to be placed the HTML <script>
tag.
Instead, it uses its own tag called the <swift>
tag:
<swift>
# Code here
</swift>
Before anything, you need to define the version:
[ swift version 0.3 ]
The version number should be between 1
(0.1
-> 0.9
). Continue...
From an example code, you may have noticed that Swifty.js functions are "UPPERCASE":
FUNCTION example = FUNC(...)
^^^^^^^^ ^^^^
It's so the code is not to be mixed with pre-defined keywords and variables, etc.
ALWAYS use "UPPERCASE" syntax for Swifty.js.
To define a function, just use FUNCTION
.
Then, the function body starts with FUNC()
.
FUNCTION example = FUNC(...)
Then, to define paramaters, you use an Array
:
FUNCTION example = FUNC(
[...any],
({
constant params = any # These will be the parameters
})
))
Note that Swifty.js never uses semicolons.
A variable is simple in Swifty.js, because it is just called a variable
:
variable myVar = 1
A local variable is also simple in Swifty.js, because it is just called a letter
:
letter myLet = 0
A constant variable is also simple in Swifty.js, because it is just called a constant
:
constant myConst = 2
Strings can be defined using the string
keyword:
string myStr = "Test string"
myStr # "Test string"
Swifty.js comments are quite familiar because they're related to other file-type comments.
They begin with a hashtag (#
), and the comment comes right after it:
# This is a single-line comment
Swifty.js multi-line comments are not familiar.
First, you start with two hashtags (##
).
The first one starts with a plus-sign (+
).
The last one ends with a minus-sign (-
).
##+
This is
a multi-line
comment
##-
The POP
keyword lets you make JavaScript (default) alert boxes.
POP.alert(message: String ? "")
POP.alert("Hello, world!")
POP.prompt("Enter your name:")
POP.confirm("Are you sure?")
Dialouge boxes let you make smooth pop-ups with user interaction.
DIALOUGE("Select an action:")
IMPORT(url: String ? "")
IMPORT("https://www.example.com/file.js")
If you'd like to see more AS (Advanced-Syntax), please see the Full Documentation.
MIT
Swifty.js 0.2
Swifty.js uses its own syntax and keywords.
Doing that will make JavaScript more fun (building custom keywords, specifying syntax etc.)
Here's an example code of Swifty.js:
[ swift version 0.2 ]
function example = func(...any) {
constant params = any
return params
}
example("String") # "String"
A complete walkthrough of how to treat Swifty.js keywords and syntax correctly.
You can get it by CDN:
<script src="https://cdn.jsdelivr.net/gh/Parking-Master/Swifty.js@latest/0.2/swifty.js" async>[ swift version 0.2 ]</script>
- Download the file here
Let's walk through some CS (Common-Syntax) in Swifty.js.
Do not place Swifty.js code in .js
(JavaScript) files.
Do not place Swifty.js code the HTML <script>
tag.
Instead, place it in the pre-defined <swift>
tag:
<swift>
# Code here
</swift>
To define a function, just use function
.
Then, the function body starts with func()
.
function example = func(...)
Then, to define paramaters, you place all of them inside the parenthesis:
function example = func(...any) {
constant params = any
# "params" are the parameters
}
Note that Swifty.js never uses semicolons.
A variable is simple in Swifty.js, because it is just called a variable
:
variable myVar = 1
A letter is also simple in Swifty.js, because it is just called a letter
:
letter myLet = 0
A constant is also simple in Swifty.js, because it is just called a constant
:
constant myConst = 2
A letter is also simple in Swifty.js, because it is just called a letter
:
string myStr = "Test string"
Swifty.js comments are quite familiar because they're related to other file-type comments.
They begin with a hashtag (#
), and the comment comes right after it:
# This is a single-line comment
Swifty.js multi-line comments are not familiar.
First, you start with two hashtags (##
).
The first one starts with a plus-sign (+
).
The last one ends with a minus-sign (-
).
##+
Multi
Line
Comment
##-
Swifty.js 0.1
Swifty.js uses its own syntax and keywords.
Here's an example code of Swifty.js:
[ swift version 0.1 ]
function example = func(...any) {
constant params = any
return params
}
example("String") # "String"
You can get it by CDN:
<script src="https://cdn.jsdelivr.net/gh/Parking-Master/Swifty.js@latest/0.1/swifty.js" async>[ swift version 0.1 ]</script>
- Download the file here
Let's walk through some CS (Common-Syntax) in Swifty.js.
Do not place Swifty.js code in .js
(JavaScript) files.
Do not place Swifty.js code the HTML <script>
tag.
Place it in the pre-defined <swift>
tag:
<swift>
</swift>
A function body starts with func()
.
function example = func(...)
Then, to define paramaters, you place all of them inside the parenthesis:
function example = func(...any) {
# ...
}
Swifty.js never uses semicolons.
A variable is simple in Swifty.js, because it is just called a variable
:
variable myVar = 1
A letter is also simple in Swifty.js, because it is just called a letter
:
letter myLet = 0
A constant is also simple in Swifty.js, because it is just called a constant
:
constant myConst = 2
Swifty.js comments are quite familiar because they're related to other file-type comments.
They begin with a hashtag (#
), and the comment comes right after it:
Swifty.js multi-line comments are not familiar.
First, you start with two hashtags (##
).
The first one starts with a plus-sign (+
).
The last one ends with a minus-sign (-
).