-
Notifications
You must be signed in to change notification settings - Fork 1
Home
LOLZ has 6 kinds of statements:
- Let
- Operator
- Function
- Variable
- Value
- Loop
A statement starts with the number of the statement type in the base-2 numeral system. o
represents 0
and l
represents 1
. Since maximum value of a statement type, lol
which belongs to loop, has 3 digits, the statement type numbers are written as 3 digits. i.e. ooo
means let
, loo
means value
. However z
might be used to write less digits and show where the statement type number ends. i.e. oz
means let
, loz
means function
.
After specifying the statement, rest of the statement is written according to specification of each type. After finishing a statement, next statement can be written right away without using any statement end indicator i.e. ;
or \n
like in other languages.
If given statement type number does not match to any of the types i.e. lll
, interpreter divides the given number with amount of statement types and uses remainder as the statement type number. Therefore lll
means operator statement.
Let statements starts with ooo
or oz
. Then it takes the block number and any other statement. During the execution, the second statement gets executed and result of it is written to given block number. Then let statement returns the result if it is also substatement of another statement.
Block number is a 8 digit number in base-2 numeral system i.e. ooloolol
. As in statement type number, it can be shortened with a z
i.e. lolz
.
Example: oz
tells this is let statement, oz
tells the target block is 0
, loololzz
tells the value of the block will be "1"
(this value statement will be examined in later parts).
Sample program that assigns "1"
to block 0
, then prints the value at block 0
:
ozozloololzzlozozllzoz
Output: 1
Operator statements starts with ool
or lz
. Then it takes a 3 digit operation type number (as in statement types, z
can be used to shorten the number), and two other statements of any kind. During the execution, first the two substatements are executed, then the result of operation is calculated, then operator statement returns the result.
Operation Numbers:
- Summation
- Subtraction
- Multiplaction
- Division
- Power
- IsEqual
- IsGreater
- IsSmaller
IsEqual
operation returns "1"
if two substatements return the same value. Rest of the operations tries to finds integer values of them. If any of the them does not have an integer value, operation returns an empty value, else it returns the result of the calculation. IsEqual
, IsGreater
and IsSmaller
either returns "0"
or "1"
.
Example: lz
tells this a operator statement, oz
tells the operation will be summation, loololzz
statement returns the value "1", loolollzz
statement returns the value "3".
Sample program that finds the summation of "1"
and "3"
, then prints it:
lozozlzozloololzzloolollzz
Output: 4
Function statements starts with loz
or olo
. Then it takes a 2-digit binary number as function type. If the given function requires a parameter, next it looks for any type of statement. There are 3 built-in functions. LOLZ does not allow to declare any other functions.
- print: requires parameter / returns an empty value
- scan string: does not require a parameter / returns the scanned value
- scan integer: does not require a parameter / returns the scanned value which guaranteed to has an integer value
Example: loz
tells this is a function statement, oz
tells the function is print
, looozlllzlzloozlzlollzlzlollzlzlllozllozlzlollolzlllozlzlooollzlollzlzllzlllolz
statement returns the value "Hello world!"
Example: olo
tells this is function statement, ol
tells the function is scan string
.
Sample program that prints "Hello world!":
lozozlooozlllzlzloozlzlollzlzlollzlzlllozllozlzlollolzlllozlzlooollzlollzlzllzlllolz
Output: Hello world!
Sample program that scans a string and saves it in block 0, prints "Hi ", then prints the value at block 0
:
ozozlozollozozloooooolllololooollooozlozozllzoz
Input: Cevat
Output: Hi Cevat
Variable statements starts with llz
or oll
. Then it takes a 8-digit binary number as target block number. On execution, it returns the value at the given block.
Example: llz
tells this is a variable statement, lolz
tells the target is block 5
.
Value statement starts with loo
. Then it takes a value to hold. On execution, it returns the value it holds. z
is used to indicate end of the value. Value is declared character by character. Each character is specified as following:
Character specification starts with 2-digit character type number.
oo
or oz
means the following character will be a upper case letter.
ol
or lz
means the following character will be a lower case letter.
lo
means the following character will be a number.
ll
means the following character either will be a sign or will be a white space.
Then it is followed by the character number. Character numbers are as following:
Number | Upper Case | Lower Case | Number | Sign & White Space |
---|---|---|---|---|
0 | A | a | 0 | space |
1 | B | b | 1 | new line |
10 | C | c | 2 | . |
11 | D | d | 3 | , |
100 | E | e | 4 | : |
101 | F | f | 5 | ! |
110 | G | g | 6 | ? |
111 | H | h | 7 | space |
1000 | I | i | 8 | |
1001 | J | j | 9 | |
1010 | K | k | 0 | |
1011 | L | l | 1 | |
1100 | M | m | 2 | |
1101 | N | n | 3 | |
1110 | O | o | 4 | |
1111 | P | p | 5 | |
10000 | Q | q | ||
10001 | R | r | ||
10010 | S | s | ||
10011 | T | t | ||
10100 | U | u | ||
10101 | V | v | ||
10110 | W | w | ||
10111 | X | x | ||
11000 | Y | y | ||
11001 | Z | z | ||
11010 | A | a | ||
11011 | B | b | ||
11100 | C | c | ||
11101 | D | d | ||
11110 | E | e | ||
11111 | F | f |
The digit amount is, for letters 5, for numbers 4 and for sign and white space 3. Again the number may be shortened with z
.
Example: loo
tells this is a value statement, oo
tells next character will be an upper case letter, lllz
means the character is H
, ol
tells the next character will a lower case letter, olooo
means the character is i
, ll
tells the next character will be sign or white space, lol
means the character is !
, z
tells this is the end of the value statement.
Sample program that prints "Hi!":
lozooloooolllzololooolllolz
Output: Hi!