Tran is a programming language inspired by ternary operators like ?:. Besides a standard library for interfacing with std{in,out} and such, the entire language consists of no "words".
So far, I have yet to actually make an interpreter or compiler for it, but it's so far rules are as follows with example output code in Javascript.
In most cases when you see a simple set of {}s it means something like: function(){ ... }() in order to compress that block down to one instruction.
Conditional statements are only ternary conditional expressions.
bool ? {
// code for if bool is true
} : another_bool ? {
// code for if another_bool is true
} : {
// code for if neither another_bool nor bool are true
}This converts to:
if(bool) {
// code for if bool is true
} else if(another_bool) {
// code for if another_bool is true
} else {
// code for if neither another_bool nor bool are true
}Functions in tran almost mock coffeescript. Also the return keyword is <-.
function_name = (parameters) -> {
<- return_value;
}Converts(although akwardly) to:
var function_name = function(parameters) {
return return_value;
}Objects in Tran are very closely like javascript objects, although instead of using :s for defining attributes, it simply just uses the standard =.
object_name = {
method_name = (-><- "returned value from the method";),
attribute = 10
}
object_name.attribute // returns 10
object_name.method_name() // returns "returned value from the method"Will look like:
object_name = {
"method_name": function() { return "returned value from the method"; },
"attribute" = 10
}
object_name.attribute // returns 10
object_name.method_name() // returns "returned value from the method"Because anything other than while loops are for sissies. Also a / is a break, and automatically implies a semi-colon
bool ^ {
// will be rerun until bool == false or loop is broken
some_condition ? /
}to...
while(bool) {
// will be rerun until bool == false or loop is broken
if(some_condition) break;
}Its a little finicky to explain like this, so I'll let you read the code...But basically: ?& is one operator, no spaces in-betweeen.
some_var ?& {
"foo": /* some_var is "foo"! */ /
"bar": /* some_var is "bar"! */ /
: /* some_var is neither "foo" or "bar"... */
}in javascript:
switch(some_var) {
case "foo": /* some_var is "foo"! */ break;
case "bar": /* some_var is "bar"! */ break;
default: /* some_var is neither "foo" or "bar"... */
}