IntellePret Documentation

Operators supported ( in operator precedence order)

Operator Description Example
++ Post increment Loop++
-- Post decrement Loop--
() Function call Function()
++ Pre increment --Loop
-- Pre decrement ++Loop
! Logical Not !(A <= 10)
- Unary Minus A = - B
+ Unary Plus A = +B
** Compute exponent 123.45 ** 3
* Multiply 123.45 * 54.321
/ Divide 1000 / 5
% Remainder (Modulo) 1000 % 7
+ Numeric Add, String Concatenation 123.45 + 54.321, FirstName + " " + LastName
- Subtract 123.45 - 54.321
< Less than A < 123.45
<= Less than or equal to A <= 123.45
> Greater than 123.45 > A
>= Greater than or equal to 123.45 >= A
== Equal to A == 123.45
!= Not equal to A != 123.45
&& Logical And A && (B == 123.45)
|| Logical Or A || (B == 123.45)
= Assign A = B
**= Compute exponent and assign A **= 3
*= Multiply and assign A *= 123.45
/= Divide and assign A /= 3
%= Compute modulo and assign A %= 7
+= Add and assign, String Concatenation A += 123.45
-= Subtract and assign A -= 123.45


IntellePret Code Features

Reserved Words Symbol name (variable and function) must be different from the reserved key words.

The following key words are in current use.
bool, int, double, dbl, string, void, while, if, else, return, true, false.

The following key words are reserved for future use.
date, time, datetime, dttm, number, nbr, for, do, break, continue, switch, default, goto, class.
Symbol Names A symbol name is case sensitive and can be of unlimited length. Symbol names can contain both letters and digits but must begin with a letter.

Example:
SymName, A123 and Z0T0 and valid symbol names.
All internally generated symbol names are preceded with an underscore ( _ ).Variables and Functions are considered as symbols and adhere to the symbol naming conventions.
Comments C++ / Java style comments are supported. Comments do not impact the execution speed and can be used liberally.
Example:

// This is a command and terminates when a new line is encountered
/* This is a comment and terminates when an * followed by a / is encountered - This style of comments cannot be nested */
Statements All statements must be terminated with “;”

Example:
A = Sqrt(1234.0 / NewValue(B += 10)) * 8;
X = FunctionCall(A);
Data Types IntellePret supports the following data types.

bool - booleans have a value of true 1 or false 0.
int - integers are 4 byte (32 bit) signed values.
double - IEEE standard double precision (floating point) value.
string - string of characters. Does not support an embedded null (0) character. Any operation performed on a string having an embedded null character is undefined.

In the case of operations involving numeric values of different data types, the data type of the one with lesser precision is converted to the higher one before the operation takes place.
Example 1:
int i, j = 3;
double d = 1.34;
i = j * d;
// j is promoted to a double, the operation j * d is performed in double precision and the result is assigned to int i.
Example 2:
// In this case since both 22 & 7 are integers, the division performed is integer division resulting in an integer result of 3.
22 / 7;
// To return a floating point result (data type double) at least one of the value must be indicated as a double rather than an integer. 22.0 / 7 will return a result of type double.
22.0 / 7;

Variables Variables may be declared as

bool B = 1, C;
int A;
double D = 1.1;
string S, S2 = "ABC";

Values of uninitialized variables are undefined. In the above declarations, C, A & S will have undefined values.
String literal A string literal must be defined enclosed in quotes. "This is a string".

A string can contain a escape sequences to embed certain often uses control codes.
An escape sequence is preceded by a backslash - \
\t embeds a tab
\n embeds a new line (character 10)
\r embeds a carriage return (character 13)
\" embeds a quote "
\\ embeds a backslash \
\x embeds a character represented by the value of the next 2 hexadecimal digits.\x41 embeds an 'A'.
Function Definition Functions must be defined before they are used.

Example:
int F0(int X)
{
return X * 2;
}
Defines a function F0 which takes a single parameter, an integer, and returns an integer. All functions can return any of the data types or can return nothing by using void.
Passing by reference A function may declare that the argument is passed by reference, by prefixing the argument with an &. This allows the actual variable passed to be modified by the function. The regular method of declaring function arguments, pass by value not reference.

Example:
void F(string &Name)
{
Name = "Intellessence";
}

string N;
F(N); // Calls function F passing the variable N, which is passed by reference as specified by the function definition.
Note: F("ABC") is not permitted because a literal ("ABC"), cannot be passed by reference.
Function calling To call a function simply invoke the function passing appropriate parameters.

Example:
F0(100.2);
Calls function F0 passing 100.2 as the parameter.

CalculateProfitPercentage(Income, Expense);
Calls function CalculateProfitPercentage passing 2 parameters Income & Expense.
if / else

IntellePret supports the "if / else" construct in the same spirit as C.

Example:
if (Income > Expense)
Bonus = Salary * 0.15;
else
{
Bonus = 0;
StockOption = 0;
}

while IntellePret supports the while construct in the same spirit as C.

Example:
// Loops 10 times
string A;
LoopCount = 10;
while (LoopCount--)
{
A+= "x"
}
return IntellePret supports the return statement in the same spirit as C. Return passes control to the end of a function or the global code. If an expression or variable is part of the return statement the appropriate value is returned.

Example:

double Fnct1(double Value)
{
if (Value < 0)
return -1;

double RetVal = 0;

while (Value--)
RetVal *= Value;

return RetVal;
}

! (Logical Not) IntellePret supports the logical ! in the same spirit as C.

Example:
A = !B;
If B is zero (false) sets A = 1 (true).
If B is non-zero (true) sets B = 0 (false).
&& (Logical AND) IntellePret supports the logical && in the same spirit as C.

Example:
A = (B == C) && F2(X);

If B != C the right hand side of the statement is false irrespective of the value returned by F2().
Therefore in the spirit of efficiency the function F2() is not called.
Since the right hand side of the statement is a logical, the value of A is assigned either 0 (false) or 1 (true).
|| (Logical OR) IntellePret supports the logical || in the same spirit as C.

Example:
A = (B == C) || F2(X);

If B == C the right hand side of the statement is true irrespective of the value returned by F2().
Therefore in the spirit of efficiency the function F2() is not called.
Since the right hand side of the statement is a logical, the value of A is assigned either 0 (false) or 1 (true).
Important Note: IntellePret’s implementation of the order of evaluation of logical expressions strays slightly from that of C. In C the && operator binds more tightly that the ||.
So A || B && C || D is processed as A || (B && C) || D

IntellePret binds from left to right.
So A || B && C || D is processed as A || (B && (C || D))

To avoid surprises, when using logical operator always use parenthesis to provide the correct evaluation order.

Home: www.intellessence.com. Copyright © 1998 - 2000 Intellessence Inc. All rights reserved.