Simple python module for KoiLang parsing.
From pip:
pip install KoiLang
From source code:
python setup.py build_ext --inplace
python setup.py install
KoiLang is a markup language while is easy to read for people. There is an simple example.
#background Street
#camera on(Orga)
#character Orga
Huh... I'm a pretty good shot, huh?
#camera on(Ride, Ched)
#character Ride
B- boss...
#character Orga
#action bleed
#camera on(object: blood, source: Orga)
#camera on(Ched, Orga, Ride)
#character Orga
How come you're stammering like that... Ride!
#playsound freesia
#character Orga
#action stand_up speed(slowly)
#character Ride
But... but!
#character Orga
I'm the Boss of Tekkadan, Orga Itsuka, this is nothing to me.
#character Ride
#action shed_tear
No... not for me...
#camera on(Orga)
#character Orga
Protecting my members is my job!
#character Ched
#action shed_tear
#character Ride
But...!
#character Orga
Shut up and let's go!
#camera on(Orga)
#action walk direction(front) speed(slowly)
Everyone's waiting, besides...
I finally understand now, Mika, we don't need any destinations, we just need to keep moving forward.
As long as we don't stop, the road will continue!
In KoiLang, the code contains 'command' section and 'text' section. The format of the command section is similar to a C prepared statement, using '#' as the prefix. And other lines that do not start with '#' are the text section.
#command "This is a command"
This is the text.
The format of a single command like:
#command_name [param 1] [param 2] ...
There are several parameters behind the command whose name should be a valid variable name.
An unsigned decimal integer like is also a legal command name, like
#114
.
Each command can have several parameters behind the command name. Valid argument type include integer, float, literal and string.
#arg_int 1 0b101 0x6CF
#arg_float 1. 2e-2 .114514
#arg_literal string __name__
#arg_string "A string"
Here literal argument is a valid python variety name containing letter, digit, underline and not starting with digit. Usually it is the same as a string.
The above parameter types are often referred to base parameters. Combination parameter which is composed of multiple basic parameters is another argument type. It is a key-to-value mode which is starting with a literal as key and followed by several basic parameters. The format is as follows:
#kwargs key(value)
And another format:
#keyargs_list key(item0, item1)
And the third:
#kwargs_dict key(x: 11, y: 45, z: 14)
All the parameters above can be put together:
#draw Line 2 pos0(x: 0, y: 0) pos1(x: 16, y: 16) \
thickness(2) color(255, 255, 255)
Kola module provides a fast way to translate KoiLang command into a python function call.
Above command #draw
will convert to function call below:
draw(
"Line", 2,
pos0={"x": 0, "y": 0},
pos1={"x": 16, "y": 16},
thickness=2,
color=[255, 255, 255]
)