BlobbieScript - Operators

Operators

Operators are at the epicentre of any kind of logical and mathematical processing. To facilitate the power that BlobbieScript will exhibit, many of the most common programming operators have been implemented. Some of the operators can be expressed in more than one way since not all programming languages use the same style. Remember operators will only be functional if found within a pure context, otherwise they are treated as part of the plain text input to the MUD's command interpreter.


Operator Description
 = 
Assign the right operand's value to the left operand (C style).
 := 
Assign the right operand's value to the left operand (Pascal Style).
 += 
Add the right operand to the left operand and assign the value to the left operand.
 -= 
Subtract the right operand from the left operand and assign the value to the left operand.
 /= 
Divide the right operand into the left operand and assign the value to the left operand.
 *= 
Multiply the left operand by the right operand and assign the value to the left operand.
 %= 
Assign to the left operand the remainder from dividing the right operand into the left operand. If the left operand and the right operand are both of the same sign then the remainder will be positive. Otherwise the remainder will be negative.
 ^^= 
Raise the left operand to the power of the right operand and assign the value to the left operand.
 &= 
Take the bitwise AND of the left operand with the right operand and assign to the left operand.
 |= 
Take the bitwise OR of the left operand with the right operand and assign to the left operand.
 ^= 
Take the bitwise XOR of the left operand with the right operand and assign to the left operand.
 <<= 
Shift the bits of the value of the left operand to the left by the value of the right operand and assign to the left operand.
 >>= 
Shift the bits of the value of the left operand to the right by the value of the right operand and assign to the left operand.
 .= 
Concatenate the right operand to the end of the left operand and assign the new value to the left operand.
 ++ 
When this operator preceds the operand it increments the value of the operand and returns the incremented value. When the operator follows the operand then it increments the value of the operand after returning the value.
 -- 
When this operator preceds the operand it decrements the value of the operand and returns the decremented value. When the operator follows the operand then it decrements the value of the operand after returning the value.
 || 
Return the the boolean value of taking the logical OR of the left and right operands.
 OR 
Same as '||'.
 && 
Return the the boolean value of taking the logical AND of the left and right operands.
 AND 
Same as '&&'.
 & 
Return the value of taking the bitwise AND of the left operand with the right operand.
 | 
Return the value of taking the bitwise OR of the left operand with the right operand.
 ^ 
Return the value of taking the bitwise XOR of the left operand with the right operand.
 == 
Return the the boolean value of comparing the values of the left and right operands.
 != 
Return the the boolean value of applying the logical NOT operator to the boolean value of comparing the values of the left and right operands.
 === 
Return the the boolean value of comparing the values of the left and right operands with datatype checking. In other words if the datatypes of the left and right operands differ then this will return false, even if the values would normally return true when using the == operator.
 !== 
Return the the boolean value of applying the logical NOT operator to the boolean value of comparing the values of the left and right operands with datatype checking. In other words if the datatypes of the left and right operands differ then this will return true, even if the comparison would normally return false when using the != operator.
 < 
Return the the boolean value of checking to see if the left operand is less than the right operand.
 > 
Return the the boolean value of checking to see if the left operand is greater than the right operand.
 <= 
Return the the boolean value of checking to see if the left operand is less than or equal to the right operand.
 >= 
Return the the boolean value of checking to see if the left operand is greater than or equal to the right operand.
 << 
Return the result of shifting the bits of the left operand to the left by the value of the right operand.
 >> 
Return the result of shifting the bits of the left operand to the right by the value of the right operand.
 . 
Concatenation operator if one existed :) Concatenation occurs invisibly when two operands are detected with no joining operator. Thus the following is legitimate: %( Random: 1d100 ) which will a string of the form "Random: 73".
 MIN 
The left operand is limited to a minimum value as defined by the right operand.
 MAX 
The left operand is limited to a maximum value as defined by the right operand.
 + 
Return the result of adding the right operand to the left operand. This may also be used as a unary operator; however, as such it's benefits are aesthetic only.
 - 
Return the result of subtracting the right operand from the left operand. This may also be used as a unary operator to signify the negation of the right operand.
 / 
Return the result of dividing the right operand into the left operand.
 * 
Return the result of multiplying the left operand by the right operand.
 % 
Return the remainder when the left operand is divided by the right operand. If the left operand and the right operand are both of the same sign then the remainder will be positive. Otherwise the remainder will be negative.
 ^^ 
Return the result of raising the left operand to the power of the right operand.
 D 
Given that the left operand signifies a number of die and the right operand signifies the number of faces for each dice. Return an entry from the set of all possible dice roll totals with these criteria.
 ! 
Return the logical NOT of the right operand.
 ~ 
Return the bitwise NOT of the right operand.
 -> 
Please see "The Resolution Operator" section below.
 ->+ 
The array add operator. This is used in conjunction with the = operator to add elements to an array with auto indexing (@foo->+ = @value).
 ( ) 
Force the evaluation of the expression within the parenthesis to occur before any other evaluation.

Precedence

As with all expression evaluation mechanism there must exist a set of rules of precedence to ensure that what the user expects to happen, actually happens. BlobbieScript uses the following order of precedence, from highest to lowest, for its evaluations -- operators on the same line are of equal precedence:


Order of Precedence
 ( ) 
 -> 
 !  ~  ++  --  + (unary)  - (unary) 
 D 
 ^^ 
 %  *  / 
 -  + 
 MIN  MAX 
 . (implicit and cannot be used explicitly) 
 << >> 
 ==  !=  === !== <  >  <=  >= 
 & 
 |  ^ 
 && 
 || 
 +=  -=  /=  *=  %=  ^^=  &=  |=  ^=  <<=  >>=  .= := ->+