Baz

Baz is a joke programming language created by User:OriginalOldMan. Variables can only have 3 values in Baz: true, false, or baz.
==Variables==
Variables are assigned like so:
 variablename = value
The following code would set the variable x equal to baz:
 x = baz
==Commands==
There are only a few commands in baz.
Command 	Description 	Example
show <variable>	Prints the value of a variable to the screen.	show x prints the value of x to the screen.
get <variable> 	Gets input from the user and stores it in a variable. 
Will only accept true, false or baz as valid input.	get x gets input from the user and stores it in x.
if <variable> 	Works the same way as if statements in most languages. 
If the variable is equal to baz, then there is a 
50% chance that the code inside of the if statement will run.	if x
show x
endif
 prints the value of x if x is equal to true (or sometimes baz).
if! <variable> 	The if! statement is the same as the if 
statement, except it executes when the variable is equal to false
(or sometimes baz...).	if! x
show x
endif
 prints the value of x if x is equal to false (or sometimes baz......).
goto <line> 	Jumps to a specific line in the program. 	show true
goto 1 
 prints true forever.
end 	Ends the program. 	
==Error Reporting==
Errors are reported like so:
 YOU ARE WRONG!@<linenumber>
An error at line 1 would look like this:
 YOU ARE WRONG!@1
==Programs==
===Cat Program===
 get x
 show x
===Truth-machine===
Note: Instead of 0 and 1, we use false and true.
 get x
 if x
 show true
 goto 3
 endif
 show false
 end
===Randomly print true and false===
 if baz
 show true
 goto 1
 endif
 show false
 goto 1
===Quine===
It is not possible to create a quine normally. However, one can create a quine-by-error.
 YOU ARE WRONG!@1
==Interpreter in Ruby==
 print Dir.pwd
 print " $ "
 $vars = {}
 $c = 0
 $vars ["baz"] = "baz"
 $vars ["true"] = "true"
 $vars ["false"] = "false"
 file = File.open(gets.delete("\n"),"r")
 $program = file.read
 $program = $program.split("\n")
 def tokenize(line)
 tokens = []
 if line.match(/.+=.+/)
 line = line.delete(" ")
 line = line.split("=")
 tokens[1] = line[0]
 tokens[0] = "setvar"
 tokens[2] = line[1]
 else
 tokens = line.split(" ")
 end
 return tokens
 end
 def exe(line)
 if line[0] == "setvar"
 if $vars[line[2]] == "true" or $vars[line[2]] == "false" or $vars[line[2]] == "baz"
 $vars[line[1]] = $vars[line[2]]
 else
 e = $c+1
 abort "YOU ARE WRONG!@#{e}"
 end
 elsif line[0] == "show"
 if line.count == 2
 puts $vars[line[1]]
 else
 e = $c+1
 abort "YOU ARE WRONG!@#{e}"
 end
 elsif line[0] == "get"
 if line.count == 2
 tvar = gets.delete("\n")
 if tvar == "true" or tvar == "false" or tvar == "baz"
 $vars[line[1]] = tvar
 else
 e = $c+1
 abort "YOU ARE WRONG!@#{e}"
 end
 end
 elsif line[0] == "if"
 if line.count == 2
 x = $vars[line[1]] == "baz" and rand(2) == 1
 if $vars[line[1]] == "false" or x
 l = $c
 b = 0
 while b == 0
 if $program[l] == "endif"
 b=1
 $c = l
 end
 l+=1
 end
 end
 else
 e = $c+1
 abort "YOU ARE WRONG!@#{e}"
 end
 elsif line[0] == "if!"
 if line.count == 2
 x = $vars[line[1]] == "baz" and rand(2) == 1
 if $vars[line[1]] == "true" or x 
 l = $c
 b = 0
 while b == 0
 if $program[l] == "endif"
 b=1
 $c = l
 end
 l+=1
 end
 end
 else
 e = $c+1
 abort "YOU ARE WRONG!@#{e}"
 end
 elsif line[0] == "goto"
 if line.count == 2
 $c = line[1].to_i - 2
 else 
 e = $c+1
 abort("YOU ARE WRONG!@#{e}")
 end
 elsif line[0] == "end"
 abort
 elsif line[0] == "endif"
 else
 e = $c + 1
 abort "YOU ARE WRONG!@#{e}"
 end
 end
 def run(program)
 while $c < program.count
 exe(tokenize(program[$c]))
 $c+=1
 end
 end
 run($program)
Category:2013
Category:Unknown computational class
Category:Implemented
Category:Languages