欢声笑语
欢声笑语 or LLOLCODE is an esolang invented by User:None1 and User:PrySigneToFry and inspired by RiLOLCODE which is inspired by FLOLCODE which is inspired by LOLCODE, but...in Classical Chinese(This is also inspired by wenyan).
Keywords
WIP
Priority is like that in C++. Full-width brackets () are used to increase priority.
These are the main keywords. All 欢声笑语 keywords can be written in zh-cn or zh-tw.
Code | Comment |
---|---|
始于 [version] |
In all 欢声笑语 programs, 始于 introduces the program and specifies the version (although it isn't used yet). |
注: Comment |
Introduces a single line comment. |
注曰:“Comment” |
Introduces a multi line comment. |
用 [library] |
Includes a library. |
书 [string] |
Prints 言 to the standard output stream. If "于一行" is added outside the string, no newline will be printed. |
读 [var] |
Reads a string from the standard input stream into the variable. |
取 [var] |
Reads a thing that same as the type of var from the standard input stream into the variable. |
有物名 [var] |
Declares a variable without a value. Its type will be 虚. |
有物名[var]者, [value]也 |
Declares a variable and assigns a value to it. |
有物名[var]者, 其类为[type] |
Declares a variable of the specified type and assigns the initial value of that type to it. |
有物名[obj]者, [other obj]之同类也 |
Declares a variable and copies the contents of the other variable into the newly created variable. This is only valid if the other variable is a 类. |
[var]者,[value]也 |
Assigns a value to a variable. |
[expression]为[expression] |
Compares two expressions (a variable, a value or another comparison). Returns 真 if both expressions have the same value. |
[expression]不为[expression] |
Compares two expressions (a variable, a value or another comparison). Returns 假 if both expressions have the same value. |
[expression]大于[expression] |
Compares two expressions (a variable, a value or another comparison). Returns 真 if exp1>exp2. |
[expression]小于[expression] |
Compares two expressions (a variable, a value or another comparison). Returns 真 if exp1<exp2. |
[expression]不小于[expression] |
Compares two expressions (a variable, a value or another comparison). Returns 真 if exp1≥exp2. |
[expression]不大于[expression] |
Compares two expressions (a variable, a value or another comparison). Returns 真 if exp1≤exp2. |
[expression]与[expression]中大者 |
Returns the bigger of the two given expressions. |
[expression]与[expression]中小者 |
Returns the smaller of the two given expressions. |
[expression]加[expression] |
Calculates [expression1] + [expression2] |
[expression]减[expression] |
Calculates [expression1] - [expression2] |
[expression]乘[expression] |
Calculates [expression1] * [expression2] |
[expression]除[expression]之商 |
Calculates [expression1] / [expression2] |
[expression]除[expression] |
Calculates [expression1] ÷ [expression2] |
[expression]除[expression]之余 |
Calculates [expression1] modulo [expression2] |
续[argument1]以[argument2] (以[argument3] (以[argument4] ...)) |
Concatenates the given 言s. |
改[expression]为[type] |
Explicitly casts the expression to the given type. If the expression is a variable it is not changed. To also change a variable use [var]者,(改[var]为[type])也. |
换[variable]作[type] |
Explicitly casts a variable to the given type. The value of the variable is changed to the new type. This is equivalent to [var]者,(改[var]为[type])也. |
释[var] |
Interprets a 言 variable as an identifier. |
若[expression]为真者: ...SOMECODE ( 若非而[expression2]为真者: ...SOMECODE ... ) 若非: ...SOMECODE 云云 |
An if statement. If the expression can be evaluated to 真 (equivalent of 实) the 若 branch is executed, otherwise the 若非 branch is executed. |
何乃[expression] 若其乃[value]则 [code] 若其乃[value]则 [code] 若均非之则 [code] 云云 |
The SWITCH-statement compares the expression to the values of the 若其乃-statements. The values must be distinct and literal, i.e. they mustn't contain any variables or expressions which have to be evaluated at runtime. The 若其乃 block can be followed by any number of statements and can be terminated with 止步于此. If an 若其乃-block is not terminated with 止步于此 the next 若其乃 will be executed too, regardless of the comparison value. The default case (若均非之) is executed when no value matches the expression. |
复为之x次: code 云云 |
Do the code for x times. |
恒为是。若[expr]为真乃止: code 云云 |
Do the code until expr returns 真. |
恒为是。若[expr]为非乃止: code ENDLOOP. |
Do the code until expr returns 假. 断 can break the loops. |
止 |
止 terminates the program.
|
Types
虚
The 虚 type is an empty type that undefined. It is the most basic type when defining variables. It can be converted to a boolean value and return 假, or an integer value and return zero.
布尔
A 布尔 is a logical variable that has both 真 and 假 properties (either 真 or 假). 0, 0.0000000000, 0j, empty strings, NUL characters(its ASCII is zero), empty lists, empty tuples, empty dictionaries, empty objects (meaning objects that only have __init__ methods, and the only way is an empty function), and blank variables will all return 假. All other values return 真. The initialized value is 假.
Numeric Variable
整数
In this programming language, there is no upper and lower bound for integer types. This is the default integer type. The short integer type is from -32768 to 32767. The medium integer type is from -2147483648 to 2147483647, just like the int type in C++. The long integer type is from -9223372036854775808 to 9223372036854775807. There are also longer integer types, which are equivalent to __int128 types in C++. The initialized value is 0.
You can also define a numeric variable like this:
有物名圆周率者, 三又一分四厘一毫五丝九微二纤六沙五尘三埃五渺八漠九模糊八逡巡也
Use LOLCODE to represent it is
I HAS A M_PI ITZ A NUMBAR M_PI R 3.1415926535898
For more detail, see at here.
小数
Like integer types, decimal types have no upper and lower bounds. The upper and lower bounds of a single-precision decimal type are equal to the upper and lower bounds of medium integers, and there are 6 to 7 significant decimal places. The upper and lower limits of the double decimal type are equal to the upper and lower limits of the long integer type, and the effective decimal places have reached 13 to 14 digits. There are also even more bizarre types of long double-precision decimals, with upper and lower bounds equal to those of 128-bit long integer types, with 20 to 21 significant decimal places. The initialized value is 0.0 .
复合之数
A complex number consists of its real and imaginary parts, usually in the form m+nj. If you only want to express imaginary numbers, omit m+. If you want to express the imaginary number 1, just use j. The initialized value is 0+0j.
What they all have in common
If you converts 0, 0.0000000000000000000000000000000000, 0.0, 0+0j, 0j to 布尔, you will get a 假, otherwise you will get a 真. When you try to convert 布尔 to 整数, 小数 or 复合之数, it will be:
- 假 to 整数: 0
- 假 to 小数: 0.0
- 假 to 复合之数: 0+0j
- 真 to 整数: 1
- 真 to 小数: 1.0
- 真 to 复合之数: 1+j
Chinese number chart
Chinese | Mathematical |
---|---|
十 | 10 |
百 | 100 |
千 | 1000 |
万 | 10000 |
亿 | 10^8 |
兆 | 10^12 |
京 | 10^16 |
垓 | 10^20 |
秭 | 10^24 |
穰 | 10^28 |
沟 | 10^32 |
涧 | 10^36 |
正 | 10^40 |
载 | 10^44 |
极 | 10^48 |
恒河沙 | 10^52 |
阿僧祇 | 10^56 |
那由他 | 10^60 |
不可思议 | 10^64 |
无量大数 | 10^68 |
Chinese | Mathematical |
---|---|
分 | 0.1 |
厘 | 0.01 |
毫、毛(because 兞 means mg) | 10^-3 |
丝 | 10^-4 |
忽 | 10^-5 |
微 | 10^-6 |
纤 | 10^-7 |
沙 | 10^-8 |
尘 | 10^-9 |
埃 | 10^-10 |
渺 | 10^-11 |
漠 | 10^-12 |
模糊 | 10^-13 |
逡巡 | 10^-14 |
须臾 | 10^-15 |
瞬息 | 10^-16 |
弹指 | 10^-17 |
刹那 | 10^-18 |
六德 | 10^-19 |
虚空 | 10^-20 |
清净 | 10^-21 |
阿赖耶 | 10^-22 |
阿摩罗 | 10^-23 |
涅槃寂静 | 10^-24 |
字
Variables of character type are enclosed by single quotation marks. Its value range is limited to 256 characters in ASCII. There is also a double-byte character type, which is equivalent to the wchar_t of C++, and supports plane 0 of the entire Unicode.
言
A string, as the name suggests, is made up of many characters. Both the string type and the character type support escaping characters, which are escaped by backslashes. In particular, lowercase n means new, lowercase t means horizontal tab, lowercase a means character 7 (BEL character), lowercase b means character 127 (DEL character), the number zero represents character 0 (NUL character), uppercase Q means double-quote, lowercase q means single-quote, variable wrap in a brace means output this variable(Only support by f string).
The 言 can only convert to 整数 or 小数, such as, "24" to be 24, "53.2" to be 53.2, but "0x10" to be an error instead of 16.
- \n ---- newline
- \t ---- horizontal tabulation
- \b ---- backspace
- \a ---- alarm
- \0 ---- NULL
- \x[hhhh] ---- Hexadecimal character
- \[ddddd] ---- Decimal character
- {var} ---- output the variable
- \Q ---- double quote
- \q ---- single quote
- \N[character name] ---- output the character named [character name]. For example, Cyrillic capital letter El outputs Л, CJKV Unified Ideogram 0x4E00 outputs 一, and so on.
- \v ---- vertical tabulation
Functions
Functions are defined by the following commands:
有术名曰“functionname”。(欲行其术必先得此参数:) { 注: CodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCode (得 returnvalue) }
二元
A bitset is a serie of bits.
类
Objects are defined by the following commands:
有类名之曰YourClassName. { 注: Define an attribute in the object. 有性为attr_1 者,其类为整数 注: Define some inits in the object. 有术名曰“初始化”。欲行其术必先得此参数:自我 { 注: CodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCode } 有术名曰“函数1”。欲行其术必先得此参数:自我 { 注: CodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCode } }
A variable inside an 类 can be used with [object_name].[variable_name].
A function inside an 类 can be used with [object_name].[function_name]((self), *args, **kwargs).
Definition of constants
Constants are defined by the following commands:
有恒物为[const]者,[value]也
Examples
Hello, world!
始于 1.3 书 "Hello, world!" 止