My own programming language, currently under development
You need to have Python 3.6+
installed. If you haven't, go to Python and install the latest version.
Once you have Python setup, you need to clone this repository and open a terminal inside the folder. Then you must type:
C:\Users\...\Pansy > python shell.py
You should see:
Pansy>
You can exit anytime using the command:
Pansy> exit
Now you are ready to start! 😄
Let's imagine you want to run the code that is in the dir: examples/HelloWorld/code.pansy
You just need to use the command:
Pansy> run("examples/HelloWorld/code.pansy")
var x = <value>
@ This a one line comment
Currently there are 4 data types: Integer
, Float
, String
and List
.
var x = 1
Pansy> var x = 5.0
var x = "This is a string"
var x = [1,2,3]
Sum (+)
Subtraction (-)
Multiplication (*)
Division (/)
Int Division (//)
Remainder (%)
Equal (==)
Inequal (!=)
Greater than (>)
Less than (<)
Greater than or Equal to (>=)
Less than or Equal to (<=)
var x = 0
if x < 0:
print("You need more!")
elif x > 0:
print("You need less!")
else:
print("Correct!")
end
for i=0 to 10:
print(i)
end
for i=0 to 10 step 2:
print(i)
end
var x = 0
while x < 10:
print(i)
var i = i + 1
end
func double(n) {
var n = n * 2
return n
}
Pansy comes with some built-in functions (more on the way 😉):
print(arg)
- Printsarg
on the screeninput()
- Waits for the input of the useris_number(arg)
- Returns 1 (True) ifarg
is a number or 0 (False) if notis_string(arg)
- Returns 1 (True) ifarg
is a string or 0 (False) if notis_list(arg)
- Returns 1 (True) ifarg
is a list or 0 (False) if notis_function(arg)
- Returns 1 (True) ifarg
is a function or 0 (False) if notappend(arg1, arg2)
- Appendsarg2
to the listarg1
pop(arg1, arg2)
- Pops the element at the indexarg2
of the listarg1
extend(arg1, arg2)
- Joins to lists togetherget(arg1, arg2)
- Gets the element at the indexarg2
of the listarg1
run(arg)
- Runs a program from a file with the extension.pansy
len(arg)
- Returns the length of the listarg
to_str(arg)
- Transformsarg
to a string if possibleto_int(arg)
- Transformsarg
to a integer if possibleto_float(arg)
- Transformsarg
to a float if possible