Syntax basics

Ginjo-Builder uses the .NET 3.5 Common Language Infrastructure (CLI), which is included in all versions of Microsoft Windows since Vista (SP1). By default mscorlib.dll and System.dll are included automatically in your project. (See compiler options for including other libraries.) In addition, a thin managed wrapper (GinjoIrrlicht3.dll) is included, which exposes the Irrlicht3D API through the GB namespace. The full Irrlicht3D API documentation can be found on the Irrlicht website: http://irrlicht.sourceforge.net/docu/index.html

Ginjo is a line oriented verbose language designed to be readable and maintainable. The syntax of the Ginjo language is deliberately similar to existing/popular programming languages. However, there are some key difference:

Line oriented

End of line is the end of an instruction or statement. The semi-colon (  ;  ) and braces (  {  }  ) are also recognized as the end of a statement, but we discourage the use of semi-colons. Only single line comments are recognized: //this is a comment

Case-insensitive

Ginjo is intended to be human parsable. Case-sensitivity in other languages makes them less human parsable and can introduce difficult to find bugs. For example, in C# the following code results in your program crashing with no stack trace:

//C# code:
private int myVar;
public int MyVar
{
    get { return MyVar; }
}
In Ginjo this gives an error, as myVar and MyVar are considered duplicate declarations.

Single quoted strings

String literals can be entered using either single or double quotes. "Hello Ginjo" and 'Hello Ginjo' are completely the same. There are no escape sequences in single quoted strings, thus 'C:\Users\Ginjo\' is a valid string. However, "C:\Users\Ginjo\" has three errors: Unrecognised escape sequences \U and \G, and unterminated string. The following escape sequences are recognized for double quoted strings:

Operator Description
\t Inserts a tab character.
\r Inserts a carriage-return character.
\n Inserts a LineFeed character.
\e Inserts a System.Environment.NewLine ('e' for 'enter'). On Windows systems this is the equivalent of \r\n.
\" Inserts a " character.
\\ Inserts a \ character.

+ needs toString

Adding two strings using + concatenates the two strings. Adding a string to something that is not a string throws an exception during runtime!
Note the fps.toString in device.SetWindowCaption().

while (device.Run()){
  if (device.WindowActive){
      driver.BeginScene(gb.video.ClearBufferFlag.All)
      smgr.DrawAll()
      driver.EndScene()

      var:Int32 fps = driver.FPS
      if (lastFPS != fps){
        device.SetWindowCaption('Quake 3 Map Example-Engine:'+ driver.Name + ' (' + fps.toString + ') fps')
        lastFPS = fps
      }
  }
}

Removed operators

The following operators are purposefully missing in Ginjo: ++  --  ==  ?:
The = operator is context dependant. It is a comparison operator inside conditional statements and an assignment operator otherwise. See Operators for further details.

Consistent syntax for declarations

Ginjo is designed to be verbose and readable, and consistently follows the modifier kind:type name convention for declarations. (See Modifiers for further details.) Consider the following C++ code:

//C++ code:
public static string myFunc()
Is it a function declaration? Is it a variable declaration? Is it a function prototype?
In Ginjo the kind of symbol being introduced is always explicitly marked; type is optional, but type inference is not currently supported and a type must always be present for variables:

var:string myStr="Hello Ginjo" //variable declaration; variable type is string
const:double PI=3.14159265358979323846264338327950288 //constant declaration
class:student myC //class declaration; class type is student (that is to say it extends the student class)
class myC2 //class declaration; class type is System.Object
private function myFunc(var:string myStr) returns Int32 //function declaration, returns System.Int32
public function myFunc(var:string myStr) //function declaration, no return type

Scopes are always explicitly marked

Scopes are always explicitly marked using brackets (  {  }  ).

if(a=2); //syntax error
if(a=2) dosomething(); //syntax error
if(a=2){dosomething()} //good

For example, the if and switch statements are properly used as follows:

//if statement
if(a=2){dosomething()} 
elseif(a=3) {dosomethingelse()} 
else{callerror()}
//select statement combined with for loop
for(var:Int32 i=0; i<12; i+=1){			
     switch(i)
     {
          case(0){continue}
          case(3){break}
          default{dosomething(i)}
     }
} 

See conditionals and loops for further details.