FROM HERE TO THERE

From Esolang
Jump to navigation Jump to search

FROM HERE TO THERE is an esolang by User:PythonshellDebugwindow.

Syntax

Each line has the following syntax (lines can be separated by "\n", "\r\n", "\n ", "\r\n ", ";", "; ", ";\n", or ";\r\n", but "\n" is used on this page for consistency):

FROM x TO y

x can be LINE, IN, a file, an integer, a string, or a variable, and y can be anything x can (minus IN) as well as OUT, ERR, and a variable expression (a binary math operator and its operands).

Values of y

Value of y Effect
LINE Unconditionally jump to line x
OUT Output x with a newline to STDOUT
ERR Output x with a newline to STDERR
A file Write x to file y without a newline
An integer For every defined variable V: if V is equal to x, set it to y
A string Same as if y is an integer
A variable Set the variable named y to x (initialize it if necessary)
A variable expression For LHS (OP) RHS, set the variable named LHS to its offset for x (please see #Variables)

Special values of x

If x is equal to IN, then replace it with a line of user input read from STDIN as a string before executing the rest of the line.

Variables

FROM HERE TO THERE uses a reverse-operation notation to perform math on variables; standalone math is illegal. To create a variable myVar and set it to 20:

FROM 20 TO myVar

To increment it by n:

FROM myVar TO myVar - n

To decrement it by n:

FROM myVar TO myVar + n

To multiply it by n:

FROM myVar TO myVar / n

To divide it by n:

FROM myVar TO myVar * n

Literals

Type Example
File <path/to/file.txt>
Integer 123
String "Hello, World!"
Variable myVar

BNF

<program> ::= <line> ( <endl> <line> )*
<line>    ::= "FROM" <from> "TO" <to>
<from>    ::= "LINE" | "IN" | <file> | <int> | <str> | <id>
<to>      ::= "LINE" | "OUT" | "ERR" | <file> | <int> | <str> | <id> | <varexpr>
<file>    ::= "<" ( "~" | "." | <id> ) ( "/" <id> )* ( "." <id> )* ">"
<int>     ::= DIGIT DIGIT*
<str>     ::= "\"" ( ( ANY - "\"" ) | "\\\\" | "\\\"" | "\\n" )* "\""
<varexpr> ::= <var> " "? ( "+" | "-" | "*" | "/" ) " "? ( <id> | <int> )
<id>      ::= LETTER-UPPER | LETTER-LOWER | DIGIT | "_" | id id
<newline> ::= ( "\r" | "\r\n" ) ( "\r" | "\r\n" )*
<endl>    ::= ( ";" " "? | ";" <newline> | <newline> )

Examples

Hello, World!

FROM "Hello, World!" TO OUT

Infinite cat

FROM IN TO OUT
FROM 0 TO LINE

Truth-machine

FROM IN TO n
FROM "0" TO 6
FROM "1" TO 4
FROM n TO LINE
FROM 1 TO OUT
FROM 4 TO LINE
FROM 0 TO OUT

Create a variable, initialize it to 7, set it to 19, increment it, then divide it by 4 and print its value

FROM 7 TO myVar
FROM 19 TO myVar
FROM myVar TO myVar - 1
FROM myVar TO myVar * 4
FROM myVar TO OUT

Computational class

FROM HERE TO THERE is Turing-complete, as it has sufficient flow control using FROM myVar TO LINE and arbitrary-size signed integers which can be used with prime factorization to create arbitrary amounts of sub-variables.