HAN

From Esolang
Jump to navigation Jump to search

HAN is an interpreted, single-type esoteric programming language created by User:Aryantech123. It was created to act as a syntax for many smaller projects involving computer architecture. It is a simple language, with 3 basic types of commands and uses strict prefix notation. Only floating point variables are supported.

Language structure

Each program is made up of commands, separated by newline characters. Indentation is strictly not allowed, and neither are blank lines. Programs are, thus, always a solid list of instructions. Commands are made up of tokens, which are separated by spaces. Overall, in HAN 1.3 patch 2, there are 3 basic types of commands- variable, algebra, and control.

Commands are structures similar to sentances. In general command follow the following syntax-

command arg1 seperator arg2 separator arg3

Here, command is the command, arg1, arg2, arg3 are the arguments, and seperator are used to space everything out.

Variables

Variables are initialized at the time of declaration. They are declared using the let command. Variable names can include nearly every ASCII character except for spaces In code, variables are always referred to by placing $ before their name. Example: A variable A is declared by let A is 10 and refers to as pr $A

Commands

The current commands in the language:

Command General syntax Description
pr pr sometext Prints sometext. Can also print variables, bu placing $varname
let let varname is value Declares a variable varname, and initializes its value. Variables are always floating point.
set set $varname to value Sets value of variable varname
add add $v1 is $v2 and $v3 Adds v2 and v3, and stores result in v1. add can be replaced by sub, mul, div, or mod for other operations.
skipif skipif $a <= $b n If a <= b, it skips the next n lines. Any comparison operator can be used.
doif doif $a <= $b n SImmilar to skipif, except executes the next n lines if condition is true.
goto goto lineno Jumps to a given line. Lines are indexed from 1.
end end Ends the program. Mandatory.

Examples

Hello world

pr Hello, world!
end

Infinite loop

pr Forever!
goto 1
end

Times table

let a is 1
let n is 7
let t is 0
doif $a < 11 4
mul $t is $a and $n
pr $t
add $a is $a and 1
goto 4
end


External links

Interpreters in both Rust and Python