BRZRK

From Esolang

Jump to: navigation, search

BRZRK is an esoteric programming language invented on Saturday, April 19, 2008 by User:revcompgeek. BRZRK is a flexible language based on lisp, and is functional for now, but may become object-oriented in the future (see discussion page). Comments are specified between {} brackets.

Contents

[edit] Calling Functions

In BRZRK, all function names are either a single symbol, or an upper-case letter followed by a number lower-case letters (e.g. Fibonacci). Symbols are not allowed in the names of user defined functions. Unlike lisp, no parenthesis are needed as every function knows how many arguments it takes.

[edit] Variables

All variables in BRZRK start with an underscore(_), followed by any number of lower-case letters. Variables can either hold integers, lists or trees. Strings are represented as lists, but nothing else is allowed. The the _ variable is used as the return value when a function terminates, and _a through _i are the parameters passed to the function or program.

[edit] Numbers

Single digit numbers are the largest numbers that can be written into the language. You must use the math functions to produce higher numbers. For example, if you wanted to produce 42 in BRZRK you would have to add something like +*4*252 which is equivalent to (4*(2*5))+2 or simply *67.

[edit] Built in functions

There are only a few built in functions in BRZRK. The number in parenthesis is the number of arguments that function has. Names divided by | are synonyms: they do the same thing and take the same arguments.

Math:
 + = Add (2)
 - = Subtract (2)
 * = Multiply (2)
 / = Divide (2)
 ^ = Power function (2)
 % = Modulus function (2)
 ~ = Bit NOT (1)
 & = Bit AND (2)
 | = Bit OR (2)
Logical:
 !     = Logical NOT (1)
 <     = Logical LESS (2)
 >     = Logical GREATER (2)
 =     = Logical EQUAL (2)
 Or|O  = Logical OR (2)
 And|A = Logical And (2)
IO:
 $    = String print (1)
 #    = Integer print (1)
 Nl|N = newline (0)
 '    = String Input (0)
 ?    = Integer input (0)
Lists:
 .             = List head (1)
 ,             = List tail (1)
 Listappend|La = Append #2 to the end of #1 (2)
 Listconcat|Lc = Combine #1 with #2 (2)
 List|L        = Create empty list (0)
 Emptylist|El  = Empty list? (1)
Variables:
 Set|S       = Set variable (2)
 Exists|E    = Exists? (1)
 Islist|Il   = Is a list? (1)
 Isnumber|In = Is a number? (1)
 Istree|It   = Is a tree? (passed with `)(1)
Conditional and Loops:
 If|I      = If statement (2)
 Ifelse|Ie = If...Else statement (3)
 While|W   = While loop (2)
 Do|D      = Do...While loop (2)
 For|F     = For loop (3)
Other:
 \ = break out of loop (0)
 @ = terminate program or exit function (0)
 "..." = String (becomes a list)
 ` = Pass tree/run string (see below) (1)
 B = Evaluate both params (see below) (2)
 Func|Fc = Create function (see below) (3)
 Load|Ld = load from a file (see below) (1)

[edit] Notes

Anytime where code needs to be passed to a function a back quote(`) MUST be used. The exception to this rule is built-in functions do not need a back quote because the interpreter is smart.

The parameters to some of the built-in functions may be confusing. Here is a better explanation for some of them.

[edit] For loop

The first parameter to a for loop should be a variable. This is the variable that will be incremented each run through the loop. The variable should already be initialized to the value that the loop should start with. The next parameter is the value that the for loop should loop to. This can be above or below the variable's value because the loop will adjust. The last parameter is the code that should be run.

[edit] Tree passing

Some people will want to be able to pass sections of code that will be run periodically inside a function. The solution is to prefix the top of the tree with a back quote(`). The tree will be followed until all parameters are accounted for and then passed to the function as a variable. When that variable is prefixed with a back quote, the tree will be evaluated. Note that the tree will be evaluated every time that it is used with a back quote and that it executes in the same scope that it was used in, so it can use the same variables.

[edit] 'B' function

When creating functions, you may want to have multiple commands run at the top level. The solution is the 'B' function. There are only two parameters that are evaluated in order.

[edit] 'Func' function

Using the 'Func' function is the way to define new functions. The first parameter is the capitalized function name. The second parameter is the number of parameters that the function takes. The last parameter is the code that is to be run when it is called.

[edit] 'Listappend' and 'Listconcat'

'Listappend' and 'Listconcat' both do operations on the list in the first argument, but the difference is that 'La' can take a list or an integer as the second argument while 'Lc' takes only a list as the second argument. If both arguments are lists, then 'La' will put the second list inside the first as a nested list while 'Lc' will simply tack the second list to the end.

[edit] Examples

Hello World:

$"Hello, World!"

Cat (assuming -1 is EOF):

S_v0S_eof-01While!=_v_eof`BS_v'$_v

or a more obfuscated:

D!=_-01`BS_'$_

[edit] Interpreter status

The interpreter should be on its way soon.

I have a few questions that I would like answered. Please see the discussion page.

Personal tools