BRZRK
From Esolang
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. Comments are specified between {} brackets.
Contents |
[edit] Calling Functions
In BRZRK, all functions 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 or lists. 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 thru _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 arithmetic 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 or exit function (0) @ = terminate program (0) "..." = String (becomes a list) ` = Pass tree / run tree (see below) (1) B = Evaluate both params (see below) (2) Func = Create function (see below) (3) Load = load from a file (see below) (1)
[edit] Notes
Anytime where code needs to be passed to the compiler a back-tick(`) MUST be used. For example, the If function takes 2 parameters, the expression to evaluate, and the code to run if the expression is true. Since the expression needs to be evaluated no matter what, it is okay to leave out the back-tick. However, the code to evaluate will not necessarily be run all the time and so must have a back-tick.
The parameters to some of the builtin 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/evaluating
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-tick(`). 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-tick, the tree will be evaluated.
[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] Examples
Hello World:
$"Hello, World!"
Cat (assuming ascii 26 is EOF):
S_v0S_eof*2+67While!=_v_eof`BS_v'$_v
or a more obfuscated:
S_0W!=_*2+67`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.

