2KWLang (short for 2-Keyword Language) is an esolang by User:PythonshellDebugwindow.
There are only two keywords in this language, as the name implies, and they are
To import the file named fname (must be a string) for its side effects only:
To print x with a newline:
Without a newline:
print x | "";
Read file to STDOUT
To print out the contents of the file named fname (again, must be a string):
print import fname;
To get user input:
where n is a digit 0-9. To retrieve it once inputted:
where n is a digit 0-9.
These operators have C-like syntax and the same precedence. 2KWLang has the following mathematical operators: +, -, *, /, %, &&, ||, &, |, !, ~, and ^.
These operators also have C-like syntax. 2KWLang has the following comparison operators: ==, !=, >, <, >=, and <=.
Like in C, the ( ) parentheses/round brackets use surround notation, and they are only used for grouping
Again, C-like syntax for the
x ? y : z ternary operator. 0 and the empty string are considered falsy, all other values are considered truthy.
String, integer, and floating-point literals
Strings have double quotes around them:
but these quotes can be escaped:
"This string has escaped \"quotes\" in it!"
Integers and floating-points are like in C:
and they allow leading zeros.
2KWLang programs can import themselves, even conditionally using the ternary operator.
print "Hello, World!";
print "\0"; print "\0";
Quine (maybe cheating)
print import "nameOfThisFile";
where nameOfThisFile is the name of the file being executed.
Requires 3 files: main.2kwl, 1.2kwl, and 0.2kwl.
print "\0"; import (("\0" == "1") ? "1.2kwl" : "0.2kwl");
print "1"; import "1.2kwl";