We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

VLLL

From Esolang
Jump to navigation Jump to search

VLLL (Variable Length Lexer Language) is an esolang invented by User:None1.

Introduction

Programs in most languages, esoteric or practical, can be processed into tokens before execution. VLLL is different: what the next token will be depends on the execution state, so it's impossible to tokenize the code before execution.

Memory

It has a tape with an infinite number of bit cells all initialized to zero except some cells to the left of pointer, which are mapped to the program (like self-modifying brainfuck. This makes self-modifying possible in VLLL and makes it even harder to tokenize.

<ZEROED CELLS><PROGRAM><ZEROED CELLS>
                        ^

It also has an output buffer and an input buffer used for bit I/O.

Commands

There are 14 commands. Each command consists of 1-3 characters (0 or 1), which are converted to bits before execution.

Command table
Command Meaning
0 Set current cell to 0
1 Set current cell to 1
00 Invert current cell
01 Bitwise AND current cell by the cell after it
10 Bitwise OR current cell by the cell after it
11 Bitwise XOR current cell by the cell after it
000 Output current cell to output buffer. When there are 8 bits in the buffer, output them as a big-endian ASCII character.
001 Input current cell from input buffer. When the buffer is exhausted, read an ASCII character and store it in the buffer.
010 If current cell is nonzero, skip the next bit.
011 If current cell is zero, skip the next bit.
100 Move the pointer to the right
101 Move the pointer to the left
110 Swap current cell with the cell after it
111 NOP.

The first command is always a 1-bit command. After executing a command, the current cell and the cell after it are checked: If both cells are 0, the program halts. Otherwise the number of bits in the next command is the binary number formed by the two cells (e.g.: If current cell is 1 and the cell after it is 0, the next command will be a 2-bit command because 10 in binary is 2 in decimal).

The control flow wraps around (i.e.: The next bit of the last bit in the program is the first and vice versa), but the tape isn't (the program's length never changes during execution).

Examples

Programming in VLLL seems hard, so currently there aren't many examples. If you have one, please add it!

Infinite loop

1

Explanation:

Command Tape (before executing command)
1       [0]0000...
11      [1]0000...
11      [1]0000...
11      [1]0000...
11      [1]0000...
11      [1]0000...
...