Jack, but in better
Jack grammar :
- classes are declared the same way as in jack :
class ClassName { //class content.. }
- field variables are declared without the 'field' keyword :
int age; // type varIdentifier
- static variables are declared with the 'static' keyword :
static int ageAverage; // 'static' type varIdentifier
- simple functions are specified that way :
function bool isValidAge(int ageToCheck, int maxAge); // 'function' returnType functionName '(' parameters ')'
- the method's case :
method int birthdate(); // 'function' returnType functionName '(' parameters ')'
- last function type supported, the constructor :
ClassName (int age,string name,string surname) // className functionName
Make sure that the 'ClassName' identifier matches the Class name
Also, you must remember that new classes are initialized using the syntax a=classTypeOfA(arguments); classTypeOfA being the type of a, instead of a=classTypeOfA.constructorName(arguments);
- Statements
- unlike the jack language, 'let' and 'do' are not keywords in jack++ :
a=2; // no 'let' keyword before any statement
isAgeValid(a); // no 'do' keyword either
- 'else if' statements are supported :
if (expression to check...) { } else if (expression to check...) {} else{}
- you can also create a variable and assign it a value simultaneously :
int a=2,b=3; // in jack, this statement has to be split into at least three statements..
- As you're using jack++, incrementation statements are supported :
a++; // same as a=a+1;
a--; // same as a=a-1
- Let statements are more flexible (*=,/=,-= and += assignements are supported) :
a+=2; // same as a=a+2;
a*=4; // same as a=a*4
- The expression syntax in Jack++ is slightly different from Jack :
~a -> !a // NOT a
a & b // a AND b
a | b // a OR b
Practical notes (crucial to manipulate the language)
- To return a specific status code, you can set a value to the adress 16383 of the memory (can be done using a int var with a value of 16383 and access to the adress it points to via the syntax {var name}[0]). Warning : if the value becomes different from 0, the interpreter interrupts the execution, even if the binary was not fully executed.
- The screen pixels are controlled by the memory cells from position 16384 to 24575. Each cell controls 16 pixels and a line is controlled by 32 memory cells (pixel representation corresponds to binary representation of what's stored in the cell : 1=black,0=white)
- Memory cell 16383 can be used to exit execution abruptly : if the value 2 is stored, program exits normaly (the emulator informs you about that). If the value is 1, it exits and raises an exception (the emulator warns you as well, but with an error message)
- PLEASE, be aware that the primitive operations * and / are not implemented ! YOU must write the functions Math.multiply and Math.divide yourself (so you must write them in a "Math" class)
- To avoid the implementation of those operations, you can now include the Math library on our workspace just by typing the macro
#include<Math>. Further libraries might be added in the future, and will all be accessible throught the following directory : https://dev.diskloud.fr/FullTran/jackppLib/
The language is not heavily maintained, but it seems to be rather reliable and functional. I wish you happy discoveries !