AH'TALIQUAE ENGLISH
AFTER WATCHING LOLCODE'S INTERFACE, I DECIDED THAT IT WASN'T EASY ENOUGH FOR PEOPLE TO UNDERSTAND, SO I DESIGNED AH'TALIQUAE_ENGLISH.
Command Table
Code | Comment |
---|---|
START WITH [version]
|
In all AH'TALIQUAE_ENGLISH programs, START WITH introduces the program and specifies the version (although it isn't used yet). |
EXEGESIS: Comment
|
Introduces a single line comment. |
MULTIEXEGESIS: Comment
|
Introduces a multi line comment. |
INCLUDES [library]
|
Imports library. There are a lot of library such as STDIO, STDLIB, MATH, TURTLE, IOSTREAM, WINDOWS, QUEUE, ALGORITHM, etc. |
PRINT [string]
|
Prints STRING to the standard output stream. If "WITHOUT NEWLINE" is added outside the string, no newline will be printed. |
INPUT [var] WITH [prompt] AS PROMPT
|
Reads any variation from the standard input stream into the variable. Default prompt is "Please input: ". |
DECLARE A VARIABLE [var]
|
Declares a variable without a value. Its type will be VOID. |
DECLARE A VARIABLE [var] AND INITIALIZE IT TO [value]
|
Declares a variable and assigns a value to it. |
DECLARE A VARIABLE [var] AND SET ITS TYPE TO [type]
|
Declares a variable of the specified type and assigns the initial value of that type to it. (See Types) |
DECLARE A VARIABLE [var], AND ITS TYPE IS SAME AS [other var]
|
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 OBJECT. |
SET VALUE OF [var] TO [value]
|
Assigns a value to a variable. |
[expression] EQUALS TO [expression]
|
Compares two expressions (a variable, a value or another comparison). Returns TRUE if both expressions have the same value. |
[expression] NOT EQUALS TO [expression]
|
Compares two expressions (a variable, a value or another comparison). Returns FALSE if both expressions have same value. |
[expression] GREATER THAN [expression]
|
Compares two expressions (a variable, a value or another comparison). Returns TRUE if expr1>expr2. |
[expression] NOT GREATER THAN TO [expression]
|
Compares two expressions (a variable, a value or another comparison). Returns TRUE if expr1≤expr2. |
[expression] LESS THAN [expression]
|
Compares two expressions (a variable, a value or another comparison). Returns TRUE if expr1<expr2. |
[expression] NOT LESS THAN [expression]
|
Compares two expressions (a variable, a value or another comparison). Returns TRUE if expr1≥expr2. |
MAXIMA OF [expression] AND [expression]
|
Returns the bigger of the two given expressions. |
MINIMA OF [expression] AND [expression]
|
Returns the smaller of the two given expressions. |
[expression] PLUS [expression]
|
Calculates [expression1] + [expression2] |
[expression] MINUS [expression]
|
Calculates [expression1] - [expression2] |
[expression] MULTIPLY BY [expression]
|
Calculates [expression1] × [expression2] |
[expression] DIVIDE BY [expression]
|
Calculates [expression1] ÷ [expression2], and remove the decimal places. |
[expression] MODULO BY [expression]
|
Calculates [expression1] modulo [expression2] |
CONCAT [argument1] AND [argument2] (AND [argument3] (AND [argument4] ...)) TOGETHER
|
Concatenates the given STRINGs. |
FORCIBLY CONVERTS THE VALUE OF [Expression] TO [Type].
|
Force the value of an expression to be converted to [type]. It's just a temporary conversion and can't affect all of these expressions. |
SET [variable] TO A [type] VARIABLE
|
Force the value of an variable to be converted to [type]. It's an eternal conversion and can affect all of these variable. |
INTERPRET [var]
|
Interprets a STRING variable as an identifier. |
IF [expr] IS TRUE THEN: CODE1 ELSE IF [expr2] IS TRUE THEN: CODE2 ELSE IF...... ELSE THEN: CODEn+1 ENDIF |
An if statement. If the expression can be evaluated to TRUE, do CODE1, else, if expression2 is TRUE, do CODE2, ... else, do CODEn+1. You can't omit the ENDIF, if so, you'll get an error. (The error info is SyntaxError: Endless if-statement) |
EXPRESSION TREE OF [expr]. CASE value1: code1 BREAK CASE value2: code2 BREAK --snip-- DEFAULT: codeN+1 ENDTREE. |
Compares the value returned by the [expr] with the value that follows the [CASE] statement. If an equal is found, the following block of code is executed. All blocks of code must end with [BREAK]. If the value returned by the [expr] is not equal to all of the above values, the code block after the [DEFAULT] statement will be executed. |
LOOP THE CODES FOR x TIMES: code ENDLOOP. |
A for loop. |
LOOP THE CODES UNTIL [expr] IS NOT TRUE: code ENDLOOP. |
A while loop. |
THE END
|
THE END terminates the program.
|
Types
VOID
The VOID 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 FALSE, or an integer value and return zero.
BOOLEAN
A BOOLEAN is a logical variable that has both TRUE and FALSE properties (either TRUE or FALSE). 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 FALSE. All other values return TRUE. The initialized value is FALSE.
Numeric Variable
INTEGER
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.
FLOAT
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 .
COMPLEX
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 BOOLEAN, you will get a FALSE, otherwise you will get a TRUE. When you try to convert BOOLEAN to INTEGER, FLOAT or COMPLEX, it will be:
- FALSE to INTEGER: 0
- FALSE to FLOAT: 0.0
- FALSE to COMPLEX: 0+0j
- TRUE to INTEGER: 1
- TRUE to FLOAT: 1.0
- TRUE to COMPLEX: 1+j
CHARACTER
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.
STRING
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 STRING can only convert to INTEGER or FLOAT, 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 Л, Sinhala letter Kantaja Naasikyaya outputs ඞ, CJKV Unified Ideogram 0x3400 outputs 㐀, and so on.
- \v ---- vertical tabulation
Functions
Functions are defined by the following commands:
DEFINE A FUNCTION NAMED YourFunctionName. THE FOLLOWING ARGUMENTS ARE ACCEPTED: *args, **kwargs { EXEGESIS: CodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCode }
Objects
Objects are defined by the following commands:
DEFINE A CLASS NAMED YourClassName. { EXEGESIS: Define an attribute in the object. DECLARE AN ATTRIBUTE attr_1 AND SET ITS TYPE TO INTEGER EXEGESIS: Define some inits in the object. DEFINE A INIT NAMED __init__. THE FOLLOWING ARGUMENTS ARE ACCEPTED: SELF { EXEGESIS: CodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCode } DEFINE A INIT NAMED func1. THE FOLLOWING ARGUMENTS ARE ACCEPTED: SELF { EXEGESIS: CodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCodeCode } }
A variable inside an OBJECT can be used with [object_name].[variable_name].
A function inside an OBJECT can be used with [object_name].[function_name]((self), *args, **kwargs).
Definition of constants
Constants are defined by the following commands:
DECLARE A CONSTANT [const]
Addition in the version 0.1
Built-in constants
- PI = 3.1415926535897932384626433832795
- EU = 2.7182818284590452353602874713527
- TAU = 2 * PI
- SQRT2 = 1.4142135623730950488016887242097
- SQRT3 = 1.7320508075688772935274463415059
- SQRT10 = 3.1622776601683793319988935444327
- PHI = 0.61804697156983930778739184177998
P.S.: The MATH library no longer provides mathematical constants, but only mathematical functions.
Error handling
These must don't omitted:
TRY TO DO THESE CODE: { Code1 } IF (EXCEPTION) IS CATCHED THEN: { Code2 }
These can be omitted:
ELSE THEN: { Code3 } EXECUTE THESE CODES ANYWAY AT FINAL: { Code4 }
Examples
Hello, world
START WITH 0.0 PRINT "Hello, World!" WITHOUT NEWLINE THE END
x bottle of beer
START WITH 0.0 DECLARE A VARIABLE value AND SET ITS TYPE TO INTEGER DECLARE A VARIABLE unit AND INITIALIZE IT TO "bottles" INPUT value WITH DEFAULT_PROMPT AS PROMPT DECLARE A VARIABLE template AND INITIALIZE IT TO value LOOP THE CODES UNTIL (value GREATER THAN 0) IS NOT TRUE: PRINT (CONCAT value AND " " AND unit AND " of beer on the wall, " TOGETHER) PRINT (CONCAT value AND " " AND unit AND " of beer. " TOGETHER) PRINT "Take 1 down and pass it around, " DECREASES THE value MULTIEXEGESIS: DECREASES THE [var] equivalent to SET THE VALUE OF [var] TO ([var] MINUS 1). Similarly, INCREASES THE [var] equivalent to SET THE VALUE OF [var] TO ([var] PLUS 1). END OF EXEGESIS. IF (value EQUALS TO 1) IS TRUE THEN: SET THE VALUE OF unit TO "bottle" ELSE THEN: SET THE VALUE OF unit TO "bottles" ENDIF PRINT (CONCAT value AND " " AND unit AND " of beer on the wall. \n\n" TOGETHER) WITHOUT NEWLINE ENDLOOP. PRINT "No more bottles of beer on the wall, no more bottles of beer." SET THE VALUE OF value TO template PRINT (CONCAT "Go to the store and buy some more, " AND value AND " bottles of beer on the wall." TOGETHER) THE END
Throw a dice for 10000 times
START WITH 0.0 FROM RANDOM.LIB INCLUDES EVERYTHING DECLARE A VARIABLE dices AND SET ITS TYPE TO LIST LOOP THE CODES FOR x TIMES: APPEND (RANDOM INTEGER FROM 1 TO 6) TO dices ENDLOOP. PRINT THE VALUE OF dices WITHOUT NEWLINE THE END
Greatest common divisor
START WITH 0.0 DEFINE A FUNCTION NAMED gcd. THE FOLLOWING ARGUMENTS ARE ACCEPTED: x -> INTEGER, y -> INTEGER { DECLARE A VARIABLE r AND INITIALIZE IT TO (x MODULO BY y) LOOP THE CODES UNTIL r IS NOT TRUE: SET VALUE OF x TO y SET VALUE OF y TO r SET VALUE OF r TO (x MODULO BY y) ENDLOOP. RETURN r } DECLARE A VARIABLE m AND SET ITS TYPE TO INTEGER DECLARE A VARIABLE n AND SET ITS TYPE TO INTEGER INPUT m WITH DEFAULT_PROMPT AS PROMPT INPUT n WITH DEFAULT_PROMPT AS PROMPT PRINT THE VALUE OF gcd(m, n) WITHOUT NEWLINE THE END
More examples are avaliable at AH'TALIQUAE ENGLISH/Examples.