GorillaScript  
About GorillaScript

API Reference
········································
Language Reference
········································
Visit SourceForge.net

 

What is it?
········································································································································································

GorillaScript (GS) is a script programming language suitable for use in C++ applications (especially games), and provides statically typed, object-oriented procedural programming.

It also provides a number of standard libraries that can be bound to the virtual machine.  It is designed to be highly flexible and easy to interface to the C++ application in which it is embedded.

The application programming interface (API) natively includes template based binding for ease of use.  As mentioned the API is written in C++ for maximum performance and as the library progresses, will be available on different platforms such as Linux and Mac OS and also 64-bit versions of Windows and these other operating systems.

The virtual machine implementation is designed to be non-intrusive on the functional structure of the host application.  It provides flexible but easy to use functionality for managing the virtual machine, memory management, binding and data management and most importantly, script compilation and execution.

Like a lot of scripting APIs, GS uses a compile-before-execution method to dramatically improve performance over interpreted languages.  The language is based on a number of languages; most notably C/C++.

GorillaScript uses the same declaration ordering system as C++ which requires objects and variables to be declared before they are used. For example:

// GorillaScript
// decl.ape

group math {
  class vector2d { real x, y; }
}

math:vector2d vec (10, 25);


script {
  vec.x = 1;
}

This is due to the fact that the compiler collects all the information about the constructs (read: classes, functions, variables..) before checking types and variable names.

 

What's it look like?
········································································································································································

GorillaScript has lots of similarities to C++ and VisualBasic, to name two. It uses braces for code blocks with an exception on single-line statements; it allows for global, shared, and local scoped variables, classes, functions, script entry-points, and a new feature called protocols. Protocols allow the programmer to enforce specific function guidelines on a set of functions so that any implementations of that protocol will use the same function prototypes. Its similar to virtual classes in C++, minus the classes.

Here is the most basic program, the Hello World program in GorillaScript:

// GorillaScript
// hello_world.ape


script {
  console:printf (
"Hello, world!\n");
  console:pause ();
}

The first two lines "// GorillaScript" and "// hello_world.ape" are comments, like C++, which are removed before compiling.

script {

The third line opens up the default script entry-point. As GorillaScript is similar to C++ and VisualBasic in code structure, executable code must be placed in functions or entry-points, unlike Lua which runs the whole script as its entry-point. script is the keyword used to start this construct. An entry-point is the same as a function that takes no arguments and returns no values and is used when a script is "run" from the API.

console:printf ("Hello, world!\n");
console:pause ();

The next line is a function call. It calls the function print inside the console group (or namespace in C++) with the text "Hello, World!\n" with a newline character at the end. As GorillaScript includes native conversion and concatenation on strings, adding "X is " and 1.23 will result in "X is 1.23" and therefore doesn't need the C++ printf style formatting functionality.

The second line then calls the console pause function which pauses the console until a key is pressed. This function calls the Windows "PAUSE" console function.

}

The last line, as you may have thought, closes the script entry-point function.

Here is the script in C++:

// C++
// hello_world.cpp


int main () {
  printf (
"Hello, world!\n");
  system ("pause");
  
return false;
}

 

 

Sidebar Heading:
Sidebar text

     

This website is made by Nicholas Bedford.
Please contact me at gorillascript@gmail.com for questions or comments concerning this website.