Kitanai
Jump to navigation
Jump to search
Kitanai is an interpreted esoteric language.
The original interpreter is made with C++.
(By the way, Kitanai means "dirty" in Japanese (Obviously refering to the language's syntax))
Full language Syntax :
- ( : Begin Instruction Bloc
Usage : (Any code goes here)
- ) : Stop Instruction Bloc
- [ : Begin Memory Access
Usage : [Any code goes here]
- ] : Stop Memory Access
- ? : Condition
Usage : ?(condition code)(code executed if condition code returns anything except 0)(code executed if condition code returns 0).
- $ : AccessMemoryPosition
Usage : $"position" OR $366
Description : "position" is the name of the "variable" you want to access and "366" is the sub-case of your variable).
- : : CurrentStackPosition
Usage : :
Description : Return the current position of the stack as a string.
- ; : CurrentSubStackPosition
Usage : ;
Description : Return the current sub-position of the stack as a number.
- < : StackLeft
Usage : <
Description : Decrease the sub-position of the stack.
- > : StackRight
Usage : >
Description : Increase the sub-position of the stack.
- ^ : StackSize
Usage : ^
Description : Returns the current stack size.
- @ : CurrentMemoryValue
Usage : @
Description : Returns the current value pointed in the Memory.
- # : Flag
Usage : #
Description : Creates a new flag.
- + : FlagCount
Usage : +
Description : Returns the flag count as a number.
- & : Goto
Usage : &(x)
Description : Jump to the (x) flag (Where x is the number of the flag).
- * : GotoNoOrigin
Usage : *(x)
Description : Jump to the (x) flag (Where x is the number of the flag) without adding the origin to the pile.
- ~ : Origin
Usage : &~
Description : Jump to the DynamicFlag created just after the previous Goto.
- ! : ToggleExecution
Usage : !
Description : Pause code execution until encountering a new ToggleExecution.
- % : End
Usage : %
Description : Ends the program.
Standard Library
Here are the available functions :
- add (string) (string) :
Description : Returns the concatenation of the two strings given as parameters.
- add (number) (number) :
Description : Returns the sum of the two numbers given as parameters.
- sub (number) (number) :
Description : Returns the subtraction of the two numbers given as parameters.
- mul (number) (number) :
Description : Returns the multiplication of the two numbers given as parameters.
- div (number) (number) :
Description : Returns the division of the two numbers given as parameters.
- eq (string) (string) :
Description : Returns the Number(1) is the two strings are equal else it returns Number(0).
- eq (number) (number) :
Description : Returns the Number(1) is the two numbers are equal else it returns Number(0).
- neq (string) (string) :
Description : Returns the Number(0) is the two strings are equal else it returns Number(1).
- neq (number) (number) :
Description : Returns the Number(0) is the two numbers are equal else it returns Number(1).
- gt (string) (string) :
Description : Returns the Number(1) is the first string has a greater length than the second string else it returns Number(0).
- gt (number) (number) :
Description : Returns the Number(1) is the first number is greater than the second one else it returns Number(0).
- ge (string) (string) :
Description : Returns the Number(1) is the first string has a greater or equivalent length than the second string else it returns Number(0).
- ge (number) (number) :
Description : Returns the Number(1) is the first number is greater or equal than the second one else it returns Number(0).
- lt (string) (string) :
Description : Returns the Number(1) is the second string has a greater length than the first string else it returns Number(0).
- lt (number) (number) :
Returns the Number(1) is the second number is greater than the first one else it returns Number(0).
- le (string) (string) :
Description : Returns the Number(1) is the second string has a greater or equivalent length than the first string else it returns Number(0).
- le (number) (number) :
Returns the Number(1) is the second number is greater or equal than the first one else it returns Number(0).
- print (string) :
Description : Prints the (string).
- println (string) :
Description : Prints the (string) and appends a newline.
- printerr (string) :
Description : Prints the (string) in stderr.
- input (string) :
Description : Returns the string entered by the user and displays the (string) as a prompt.
- string (string) :
Description : Does nothing.
- string (number) :
Description : Converts an int to a string.
- int (string) :
Description : Converts a string to an int.
- int (number) :
Description : Does nothing.
- random () :
Description : Returns a random Number from 0 to 1.
- time ()
Description : Returns the current epoch time
- split (string target, string value, string delimiter)
Description : Splits the string "value" with the delimiter "delimiter" and place the result in the stack "target".
- func (string function_name, int arg_count, instruction code)
Description : Creates a new function named "function_name" with "arg_count" arguments that will execute "code" instruction
You can retrieve arguments in the "args" stack.
- substr (string) (number) (number) :
Description : Returns the substring of (string) between the first and the second number.
- bsfe (string) :
Description : Returns the (string) encoded with base64. (Base Sixty Four = bsf)
- bsfd (string) :
Description : Returns the (string) decoded with base64 (Base Sixty Four = bsf)
Examples
- Hello World
(All of the following versions works)
print "Hello, world!"
print("Hello, world!")
print"Hello, world!"
["Hello, world!"] print @
["Hello, world!"] print(@)
["Hello, world!"]print@
- Cat
print(input(""))
- Fibonacci
$0[int(input "Fib : ")]
$1[1]$2[1]
#
$3[$1@]
$1[$2@]
$2[add @ ($3@)]
$0[sub @ 1]
?(neq ($0@) 1) (&1)
print($1@)
- 99 bottles of beer
$"quant"[99]
#
?(gt @ 1) (
print((add(add(add (string @) " bottles of beer on the wall, ")(string @)) " bottles of beer."))
?(gt @ 2) (
$"suffix"[add (string(sub ($"quant"@) 1)) " bottles of beer on the wall."]
) (
$"suffix"["1 bottle of beer on the wall."]
)
) (
?(eq ($"quant"@) 1) (
print "1 bottle of beer on the wall, 1 bottle of beer."
$"suffix"["no more beer on the wall!"]
)
)
print (add "Take one down, pass it around, " ($"suffix"@))
print ""
$"quant"[sub @ 1]
?(neq @ 0) (&1)
%
- Compact Deadfish Interpreter :
$0[0]#$1[input">> "]?(add(eq($0@)256) (eq($0@)-1))([0])?(eq($1@)"i")($0[add@1])? (eq($1@)"d")($0[sub@1])?(eq($1@)"o") (print($0@))?(eq($1@)"s")($0[mul@@])&1
- Clean Deadfish Interpreter :
$"accumulator"[0]
#
$"userInput"[input">> "]
?(eq ($"accumulator" @) 256)
($"accumulator"[0])
?(eq ($"accumulator" @) -1)
($"accumulator"[0])
?(eq ($"userInput" @) "i")
($"accumulator"[add @ 1])
?(eq ($"userInput" @) "d")
($"accumulator"[sub @ 1])
?(eq ($"userInput" @) "o")
(print($"accumulator" @))
?(eq ($"userInput" @) "s")
($"accumulator"[mul @ @])
&1
- Compact More or Less Game
println(bsfd"QmllbnZlbnVlIHN1ciBsZSBqZXUgZHUgcGx1cyBvdSBtb2lucw==") $"s"[int(mul random 100)]$"t"[6]$"f"[0]#$"i"[int(input(add(add (bsfd"RW50cmV6IHVuIG5vbWJyZSAo")($"t"@))(bsfd"IGVzc2FpcykgOiA=")$"i"))] &2?(eq($"t"@)0)(&3)?(eq($"f"@)1)(&4)&1#?(eq($"s"@)($"i"@))($"f"[1]&~ )($"t"[sub@1]?(gt($"s"@)($"i"@))(println(bsfd"Qydlc3QgcGx1cyAh"))( println(bsfd"Qydlc3QgbW9pbnMgIQ=="))&~)#println(bsfd"TG9vc2Vy")%# println(add(add(bsfd"V2lubmVyIGVuIA==")(sub 6($"t"@)))(bsfd"IGVzc2Fpcw=="))%
- Clean More or less Game
print "Bienvenue sur le jeu du plus ou moins"
$"secretNumber" [int(mul random 100)]
$"try" [6]
$"numberFound" [0]
#
$"userInput" [int(input(add(add "Entrez un nombre (" ($"try"@)) " essais) : "$"userInput"))]
&2
?(eq ($"try"@) 0) (
&3
)
?(eq ($"numberFound"@) 1) (
&4
)
&1
#
?(eq ($"secretNumber"@) ($"userInput"@)) (
$"numberFound" [1]
&~
) (
$"try" [sub @ 1]
?(gt ($"secretNumber"@) ($"userInput"@)) (
print "C'est plus !"
) (
print "C'est moins !"
)
&~
)
#
print "Looser"
%
#
print(add(add "Winner en " (sub 6 ($"try"@))) " essais")
%
- Function definition
func "sum" 2 ( $"args" add($0@)($1@) )