CCLOLCODE

From Esolang
Jump to navigation Jump to search

CCLOLCODE is designed by PSTF. It is LOLCODE but in……文言文.

Keywords

These are the main keywords.

Code Comment
始于[version] In all CCLOLCODE programs, 始于[version] 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 STRING 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 STRUCT.
[var]者,[value]也 Assigns a value to a variable.
[expression]等于[expression] Compares two expressions (a variable, a value or another comparison). Returns TRUE if both expressions have the same value.
[expression]不等于[expression] Compares two expressions (a variable, a value or another comparison). Returns FALSE if both expressions have the same value.
[expression]大于[expression] Compares two expressions (a variable, a value or another comparison). Returns TRUE if exp1>exp2.
[expression]小于[expression] Compares two expressions (a variable, a value or another comparison). Returns TRUE if exp1<exp2.
[expression]不小于[expression] Compares two expressions (a variable, a value or another comparison). Returns TRUE if exp1≥exp2.
[expression]不大于[expression] Compares two expressions (a variable, a value or another comparison). Returns TRUE 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 STRINGs.
强改[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]者,(强改[expression]之类为[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]者,(强改[expression]之类为[type])也.
释[var] Interprets a STRING variable as an identifier.
若[expression]为真: 
	...SOMECODE
(
若非,而[expression2]为真: 
	...SOMECODE
...
)
若非: 
	...SOMECODE
云云
An if statement. If the expression can be evaluated to TRUE (equivalent of true) the IF branch is executed, otherwise the OTHERWISE 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 TRUE.
恒为是。若[expr]非真乃止:
	code
云云。
Do the code until expr returns FALSE. 止步于此 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.

小数

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:

  1. 假 to 数: 0
  2. 假 to 小数: 0.0
  3. 假 to 复数: 0+0j
  4. 真 to 数: 1
  5. 真 to 小数: 1.0
  6. 真 to 复数: 1+j

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.

  1. \n ---- newline
  2. \t ---- horizontal tabulation
  3. \b ---- backspace
  4. \a ---- alarm
  5. \0 ---- NULL
  6. \x[hhhh] ---- Hexadecimal character
  7. \[ddddd] ---- Decimal character
  8. {var} ---- output the variable
  9. \Q ---- double quote
  10. \q ---- single quote
  11. \N[character name] ---- output the character named [character name]. For example, Cyrillic capital letter El outputs Л, Sinhala letter Kantaja Naasikyaya outputs ඞ, CJKV Unified Ideogram 0x3400 outputs 㐀, and so on.
  12. \v ---- vertical tabulation

Functions

Functions are defined by the following commands:

吾有一术,名之曰“function”。(欲行此术,必先得此物:*args、**kwargs)
{
    注:CodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCode
    (返回 returnvalue)
}

二元之数

A bitset is a serie of bits.

类 are defined by the following commands:

此间有一类曰YourClassName。
{
    注:Define an attribute in the object.
    此有一性曰attr_1,为数
    
    注:Define some inits in the object.
    吾有一术,名之曰“__init__”。欲行此术,必先得此物:自我
    {
        注:CodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCode
    }
    吾有一术,名之曰“__init__”。欲行此术,必先得此物:自我
    {
        注: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

問天地好在

始于1.0
书 “問天地好在。”
终

More example

I don't have time to write them!

See also

欢声笑语

Categories