Skip to content
Cevat Barış Yılmaz edited this page Jul 4, 2018 · 5 revisions

Tutorial

Statement Types

LOLZ has 6 kinds of statements:

  1. Let
  2. Operator
  3. Function
  4. Variable
  5. Value
  6. 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, an empty value statement is created.

Let Statement

Let statement 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 a 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 Statement

Operator statement 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 the operation is calculated, then operator statement returns the result.

Operation Numbers:

  1. Summation
  2. Subtraction
  3. Multiplication
  4. Division
  5. Power
  6. IsEqual
  7. IsGreater
  8. IsSmaller

IsEqual operation returns "1" if two substatements return the same value, else it returns "0". Rest of the operations try to find 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 Statement

Function statement 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.

  1. print: requires parameter / returns an empty value
  2. scan string: does not require a parameter / returns the scanned value
  3. scan integer: does not require a parameter / returns the scanned value which guaranteed to has an integer meaning

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 Statement

Variable statement 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

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!

Loop Statement

Loop statement starts with lol, then it takes a substatement as condition. Then until finding a z that is not part of any statement or upon coming at the end of the code, it takes all statements as body statement. On execution, as long as condition substatement returns the value "1", it keeps executing the body statements.

Example: ozozlooloozz puts "0" to block 0. lol tells next statement will be a loop statement, lz means conditional statement will be an operation statement, lll tells operation will be is smaller, llz means first parameter of the operation will be a variable, oz tells parameter will point to block 0, loo tells second parameter of the operation will be a value, lolllz means the first character will be "7", z means value ends here, lozozllzoz will print the value at block 0, lozozloolllzz will print a new line, ozozlzozllzozloololzz will add "1" to value at block 0, z tells this is the end of the loop.

Sample program that prints numbers from 0 to 6.

ozozlooloozzlollzlllllzozloololllzzlozozllzozlozozloolllzzozozlzozllzozloololzzz

Output: 0 1 2 3 4 5 6