-
Notifications
You must be signed in to change notification settings - Fork 0
GigaScript‐X Documentation
File extension: .gsx
GigaScript-X has very cool syntax, similar to that of modern slang (mostly Gen-Z).
A variable can hold any value supported by GigaScript-X.
lit varName be value rn
varName
can be any name you want, but must follow the following requirements:
- Cannot start with a number
- Must start a letter or an underscore "_".
value
can be any value you want that is supported by GigaScript-X.
lit anotherVar rn
Mutable variables do not need to have a variable assigned when they are declared.
Important
All variable declarations must end with the rn
keyword.
bro varName be value rn
varName
can be any name you want, but must follow the following requirements:
- Cannot start with a number
- Must start a letter or an underscore "_".
value
can be any value you want that is supported by GigaScript-X.
Important
Constant variables must have a value when declared.
Caution
Constant variables cannot be reassigned!
varName be newValue
Note
Reassignments shouldn't end with the rn
keyword.
To access a variable, simply reference it using the variable name.
varName
varName
should be the name of your variable. You can use varName
anywhere in your code. For examples, see examples.
Functions are very useful when you want to repeat the same task multiple times in different parts of your code.
bruh funcName(params) {
*code*
}
funcName
could be any name following these naming rules:
- Cannot start with a number
- Must start a letter or an underscore "_".
params
can be any length of parameters you need passed into your function, or no parameters at all, following the same naming rules as above.
To return a value in a function, simply reference the value on the last line of the function.
funcName(params)
funcName
could be any name following these naming rules:
- Cannot start with a number
- Must start a letter or an underscore "_".
params
can be any length of parameters you need passed into your function, or no parameters at all, following the same naming rules as above.
return value;
value
is the value you want to return;
Caution
Make sure to include the rn
keyword at the end of the return statement! Otherwise it will throw an error!
Warning
Don't add code after a return
statement. When the code execution reaches a return
statement, it will stop execution of the function and return the value.
class ClassName(){
public publicProp be "this can be any value" rn
private privateProp be "this can be any value but can't be accessed outside of the class" rn
public publicMethod(params){
code (See [Functions](https://github.com/aName2050/GigaScript/wiki/GigaScript-X-Documentation#Functions) for more info on functions.)
}
private privateMethod(params){
code (See [Functions](https://github.com/aName2050/GigaScript/wiki/GigaScript-X-Documentation#Functions) for more info on functions.)
}
}
ClassName
can be any name, while still following these naming rules:
- Cannot start with a number
- Must start a letter or an underscore "_".
public
properties and methods can be accessed when a new class instance is created.private
properties and methods cannot be accessed when a new class instance is created.
lit className be new ClassName() rn
ClassName
is the name of your class.
new ClassName()
will create a new object containing all the class's public properties and methods.
- Create a new instance of the class and set it as the value of any variable.
lit aCoolClass be new ClassName() rn
- Access the public properties and methods of the class as if you were accessing the properties of an object.
aCoolClass.publicProp
aCoolClass.publicMethod(params)
condition
is where you would check if a condition is nocap
. See examples.
sus(condition) {
code
}
sus(condition) {
code
} imposter {
code
}
sus(condition) {
code
} imposter sus (other_condition) {
code
} imposter {
code
}
Tip
You don't need to include an imposter
statement in every conditional statement.
while
loops are useful when you need to iterate over something a certain amount of times, or while
a condition is nocap
.
while(condition){
code
}
condition
is any conditional statement that would return either nocap
or cap
.
Caution
It is not recommended to set condition
to always be nocap
, condition
should eventually become cap
to prevent your program from becoming unstable and crashing.
yall
loops are useful when you need to iterate over something a variable amount of times.
yall(initializer; condition; modifier) {
code
}
initializer
sets a variable.
condition
compares the initializer
to a condition and continues to code
if it returns nocap
.
modifier
modifies the initializer
after the for
loop finishes an iteration.
Importing code from other GigaScript-X files is useful when creating large projects.
yoink aVariable from "relative/path/to/file.gsx"
yoink aFunction from "relative/path/to/file.gsx"
aVariable
and aFunction
is the variable or function you want to import. "relative/path/to/file.gsx" is the path to the file, relative to the parent directory.
Caution
When writing out the file path to the file, only relative paths are supported. Do not include a "./" at the beginning as that will result in an error.
Note
You can only import one variable/function from each file at a time, to import multiple variables/functions, use a separate yoink
statement.
Exporting variables and functions is needed to use the yoink
statement.
lit aVariable be "a value" rn
bruh aFunction(params){
code
}
yeet aVariable rn
yeet aFunction rn
aVariable
and aFunction
is the variable or function you want to export. A yeet
statement can only export one value at a time.
Important
You cannot export a value that is not a variable or function.
These are tokens reserved for GigaScript-X that can't be used as the name of classes, functions, or variables.
Note
You can use any of the reserved tokens when used inside of a string.
lit
bro
bruh
class
nocap
cap
undefined
new
null
private
public
sus
imposter
while
yall
continue
skirt
yoink
yeet
from
messAround
findOut
nerd
waffle
timestamp
format
Caution
Using any of these keywords as a class, function, or variable identifier will result in an error!
big ( > )
lil ( < )
frfr ( == )
nah ( != )
!
btw ( && )
carenot ( || )
"
with ( + )
without ( - )
by ( * )
some ( / )
left ( % )
be ( = )
You can see examples for GigaScript-X in this section. You can run these examples by copying the code in a .gsx
file and then running the file
lit x be 32 rn
bro aCoolObject be { x, z is 64, complex is { foo is "bar" } };
x be x by 2
waffle(x)
waffle(aCoolObject.complex)
waffle(x)
should output 64
.
waffle(aCoolObject.complex)
should output { foo: "bar" }
.
-
Declare a mutable variable called
x
with the value of32
. -
Declare a constant variable called
aCoolObject
with the value of { x, z: 64, complex: { foo: "bar" } }`. -
Reassign the variable
x
to the result ofx
multiplied by 2, which should result in64
. -
Print the value of
x
to the console. Prints64
. -
Print the value of
aCoolObject.complex
to the console. Prints{ foo: "bar" }
.- The
complex
property ofaCoolObject
is accessed and passed into thewaffle
function.
- The
bruh add(x, y){
bro result be x with y rn
result
}
waffle(add(1, 2))
waffle(add(1, 2))
should output 3
.
-
Declare a function called
add
with parametersx
andy
. - Inside the function...
-
Declare a constant variable called
result
with the value ofx
andy
added together. -
Return the value of
result
.
-
Declare a constant variable called
-
Waffle the result of adding
1
and2
to the console. Prints3
.
class Person {
public fname be "John" rn
public lname be "Doe" rn
public getName() {
bro fullName be fname with " " with lname rn
fullName
}
}
bro human be new Person() rn
waffle(human.getName())
waffle(human.getName())
should output "John Doe"
.
-
Declare a class called
Person
. - Inside the class...
-
Declare a public property called
fname
with the value of"John"
. -
Declare a public property called
lname
with the value of"Doe"
. -
Declare a public method called
getName
with no parameters. - Inside the method...
-
Declare a constant variable with the name of
fullName
with the result of combining the strings"John"
," "
, and"Doe"
. -
Return the value of
fullName
.
-
Declare a constant variable with the name of
-
Declare a public property called
-
Declare a constant variable called
human
.-
Create a new instance of the class
Person
. -
Assign the returned object value to the variable
human
.
-
Create a new instance of the class
-
Print the result of calling
human.getName()
. Prints"John Doe"
.- The
getName
method in the variablehuman
is called. - The method returns the full name by combining the first name (
fname
) and the last name (lname
).
- The
lit passed be nocap rn
lit isTest be cap rn
lit Class be "computer science" rn
sus(Class frfr "computer science) {
waffle("in computer science!")
sus(passed frfr isTest != nocap) {
waffle("passed the homework!")
} imposter sus (passed frfr isTest) {
waffle("passed the test!")
} imposter {
waffle("failed")
}
} imposter {
waffle("This class isn't graded yet.")
}
-
Declare a mutable variable called
passed
with the value ofnocap
. -
Declare a mutable variable called
isTest
with the value ofcap
. -
Declare a mutable variable called
class
with the value of"computer science"
. -
Check if
class
is equal to"computer science"
.- If true...
-
Print
"in computer science!"
to the console. -
Check if
passed
isnocap
and the opposite ofisTest
isnocap
- If nocap...
-
Waffle
"passed the homework!"
to the console.
-
Waffle
- If cap
-
Check if both
passed
andisTest
isnocap
instead.- If nocap
-
Waffle
"passed the test!"
to the console.
-
Waffle
- If nocap
-
Check if both
- If all other conditions return
cap
...-
Waffle
"failed"
to the console.
-
Waffle
- If nocap...
-
Print
- If cap...
-
Waffle
"This class isn't graded yet."
to the console.
-
Waffle
- If true...
bro max be 10 rn
while(max big 0) {
waffle(max)
max be max without 1
}
This should output:
10
9
8
7
6
5
4
3
2
1
to the console.
-
Declare a constant variable called
max
with the value of10
. -
Create a
while
loop with the conditionmax big 0
. You would read this as "whilemax
is greater than0
, do..." - Inside the
while
loop...-
Waffle the value of
max
to the console. -
Reassign the value of
max
to the result of the value ofmax
minus1
.
-
Waffle the value of
yall(lit i be 0 rn i lil 5 rn i be i with 1) {
waffle(i)
}
This should output:
1
2
3
4
5
to the console.
-
Create a
yall
loop with the initializerlit i be 0
, the conditioni lil 5
, and the modifier ofi be i with 1
.- The initializer is usually a mutable variable set to a specific value.
-
Declare a mutable variable called
i
with the value of0
.
-
Declare a mutable variable called
- The condition usually checks if the initializer meets a certain condition.
-
Check if
i
is less than5
- If nocap...
- Continue running the loop
- If cap...
- End the loop
- If nocap...
-
Check if
- The modifier usually modifies the value of the initializer.
- After the loop finishes an iteration...
-
Reassign the value of
i
to the result of adding1
to the value ofi
.
-
Reassign the value of
- After the loop finishes an iteration...
- The initializer is usually a mutable variable set to a specific value.
- Inside the
for
loop-
Waffle the value of
i
to the console.
-
Waffle the value of
main.gsx
yoink x from "anotherFile.gsx"
waffle(x)
anotherFile.gsx
bro x be 10 rn
yeet x rn
waffle(x)
should output 10
.
main.gsx
-
Yoink the variable
x
fromanotherFile.gsx
. -
Waffle the value of
x
to the console. Prints10
.
anotherFile.gsx
-
Declare a constant variable called
x
with the value10
. -
Yeet the variable
x
.
© Bardia Shafaee (aName2050) 2024
See our license for more details.