HALT

From Esolang
Jump to navigation Jump to search

HALT is a language designed for string processing which is currently under development.

Overview

HALT takes instructions, each prepended with a line number.

Comments

A line beginning with a # will make that line a comment. A line beginning with ---, denotes a second pass, taking the output as input.

Flow

HALT functions by keeping track of two main variables. HALT requires an input, it can even be a blank string. The pointer, and the instruction number.

Pointer

The pointer stores the index that the program is at in the input string. When the pointer reaches -1 or reaches past the string's end, the program is halted. If ht pointer never reaches these parameters, the program will trapped in an infinite-loop

Instruction

The instruction number is the current instruction being executed. The instruction number, is specified by the number preceding the line.

Functions

Name Arguments Description
Pointer
INCREMENT None Increments the pointer by 1
CONTINUE number Increments the pointer by n
SET number Sets pointer to the specific value
Flow
HALT None The HALT function stops the program (sets pointer to -1). The output is printed to STDOUT
NEXT None Sets pointer to the specific value
GOTO number Goes to instruction number n
Output Stack
STORE number Pushes character in string at pointer offset by n, to the output stack
TYPE string Pushes string to output stack
KEEP number Pushes character in string at pointer to output stack in index n
Other
IF string, number[, ELSE, number] If the characters, from the pointer are string. Goto line n1. Optionally, if ELSE exists as a third argument. If the expression instead evaluates to false Goto line n2
GET int, number[, ELSE, number] IF(char at index n1 in output stack, n2, ELSE, n3)

Examples

Hello World

1 TYPE "Hello, World!"; HALT;

Reversing Input

1 KEEP 0; INCREMENT;

Escaping Quotes

1 IF '"' 2 ELSE 7;
2 STORE 0; INCREMENT; IF "\\" 3 ELSE 4;
3 INCREMENT; GOTO 2;
4 IF '"' 5 ELSE 6;
5 HALT;
6 GOTO 2;
7 IF "'" 9 ELSE 8;
8 INCREMENT; GOTO 1;
9 STORE 0; INCREMENT; IF "\\" 10 ELSE 11;
10 INCREMENT; GOTO 9;
11 IF "'" 6 ELSE 12;
12 GOTO 9;

Interpreters